Skip to content

Instantly share code, notes, and snippets.

@CodeCharm
Last active September 15, 2020 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CodeCharm/97c69914cc5c4c129801e65b03a9fd9c to your computer and use it in GitHub Desktop.
Save CodeCharm/97c69914cc5c4c129801e65b03a9fd9c to your computer and use it in GitHub Desktop.
Onetastic Macros

Onetastic Macros

Macros that I created for the Onetastic add-in for Microsoft OneNote.

<?xml version="1.0" encoding="utf-16"?>
<Macro id="M285D04693B3542ADA8FCF9B77483028F" name="Automatic Color" category="Color" description="" version="25">
<Metadata lastModifiedDate="2020-08-05T03:36:33.000Z" />
<Expression>$selectedTextSectionsCount = 0</Expression>
<Expression>$sIndex = 0</Expression>
<Expression>$allTextSections = QueryObjects("Text", GetCurrentPage())</Expression>
<ForEach var="TextSection">
<Array>$allTextSections</Array>
<If>
<Condition>$TextSection.selected</Condition>
<Expression>$selectedTextSectionsCount = ($selectedTextSectionsCount + 1)</Expression>
</If>
</ForEach>
<ForEach var="TextSection">
<Array>$allTextSections</Array>
<Expression>$sIndex = ($sIndex + 1)</Expression>
<If>
<Condition>$TextSection.selected</Condition>
<Expression>$TextSection.fontColor = "#000000"</Expression>
<Expression>$TextSection.highlightColor = "automatic"</Expression>
</If>
</ForEach>
</Macro>
<?xml version="1.0" encoding="utf-16"?>
<Macro id="M0E5BE48837A341908D4404ED6B3B1D2E" name="Create section groups from list of titles" category="Sections" description="Creates section groups in the current notebook (or section group) from a given list of titles separated by semicolon (;)" version="25">
<Metadata lastModifiedDate="2020-07-16T02:38:54.000Z" />
<Comment text="----------------------------------------------------------------------------------" />
<Comment text=" Create section groups from list of titles" />
<Comment text="----------------------------------------------------------------------------------" />
<Comment text="Get list of section names from the user" />
<Expression>$dialog_box = DialogBox_Create("Enter section group names, separated by semicolons (;). Names must be unique.")</Expression>
<Expression>DialogBox_AddTextBox($dialog_box, "Section Group Names", "names", "first;second;third", false)</Expression>
<Expression>DialogBox_Show($dialog_box)</Expression>
<Expression>$names = $dialog_box.controls["names"]</Expression>
<Comment text="Insert sections to the current notebook or section group" />
<Expression>$folder = GetCurrentSectionGroup()</Expression>
<ForEach var="name">
<Array>String_Split($names, ";")</Array>
<Expression>InsertObject($folder, "SectionGroup", -1).name = $name</Expression>
</ForEach>
</Macro>
<?xml version="1.0" encoding="utf-16"?>
<Macro id="MA51BE96A4B774683ACD30BB4C1D31DDA" name="Selection Negative Color" category="Color" description="Changes the color of the selection so that the background is set to the normal foreground color, and the foreground is set to the normal background color" version="25">
<Metadata lastModifiedDate="2020-09-15T18:22:37.000Z" />
<Expression>$currentPage = GetCurrentPage()</Expression>
<Expression>$pageTitle = $currentPage.title</Expression>
<Expression>$pageTitleParagraph = $pageTitle.paragraph</Expression>
<Expression>$pageTitleContentText = $pageTitleParagraph.content[0]</Expression>
<Expression>$newForeColor = $pageTitleContentText.highlightColor</Expression>
<Expression>$newBackColor = $pageTitleContentText.fontColor</Expression>
<If>
<Condition>$newBackColor == Color("automatic")</Condition>
<Expression>$newBackColor = Color("black")</Expression>
</If>
<If>
<Condition>$newForeColor == Color("automatic")</Condition>
<Expression>$newForeColor = Color("white")</Expression>
</If>
<Expression>$allTextSections = QueryObjects("Text", $currentPage)</Expression>
<ForEach var="textSection">
<Array>$allTextSections</Array>
<If>
<Condition>$textSection.selected</Condition>
<If>
<Condition>GetParentOfType($textSection, "Paragraph", $parentParagraph)</Condition>
<Expression>$textSection.fontColor = $newForeColor</Expression>
<If>
<Condition>GetParentOfType($parentParagraph, "Cell", $parentCell)</Condition>
<Expression>$parentCell.backgroundColor = $newBackColor</Expression>
</If>
<Else>
<Expression>$textSection.highlightColor = $newBackColor</Expression>
</Else>
</If>
</If>
</ForEach>
</Macro>
<?xml version="1.0" encoding="utf-16"?>
<Macro id="MAE255BDA8CC049D9993FFD5A8A74C918" name="Show All Table Borders" category="Table" description="Finds all tables on the page and sets the borders so they are all visible" version="25">
<Metadata lastModifiedDate="2020-08-04T23:54:02.000Z" />
<Expression>$page = GetCurrentPage()</Expression>
<Expression>$allTables = QueryObjects("Table", $page)</Expression>
<ForEach var="table">
<Array>$allTables</Array>
<If>
<Condition>!$table.bordersVisible</Condition>
<Expression>$table.bordersVisible = true</Expression>
</If>
</ForEach>
</Macro>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment