Jump to content

[REQUEST] Microsoft OneNote Workflow


Recommended Posts

I can't help you with building it, but I can point you in the right direction.

 

Basically, you'll need to write the workflow in AppleScript. To start off, just write the AppleScripts that will be able to do these things. Create the functions to search and to create notes. You'll be able to find what is possible by opening up the application "Script Editor"; then "Open Dictionary..."; and select "Microsoft OneNote." That will give you a reference of commands and objects that OneNote makes available to use, and those are the ones you'll need.

 

After that, just read up on AppleScript enough to figure out how to implement them.

Link to comment

Basically, you'll need to write the workflow in AppleScript.

 

Thanks for the feedback. Unfortunately, OneNote doesn't have an AppleScript dictionary. Just to confirm, I Googled around and found others complaining of this too. Is that game-over as far as Alfred is concerned?

Link to comment

Is that game-over as far as Alfred is concerned?

 

Probably.

 

The other route to go would be to see how OneNote stores its data. More than likely, the data is stored in ~/Library/Application Support/Microsoft/OneNote or somewhere in ~/Documents. I don't know... you just have to poke around.

 

If you can find the folder, then you'll probably find some files with some strange extension ".onenotedb" or "modb" or something (I really have no idea). Or, perhaps easier, it'll just be ".db." However, the data might be spread across multiple data bases. The next thing to find out is what type of database it is. With any luck, it'll be a sqlite3 database. Otherwise, it might be some sort of MS database. If it's sqlite3, then you can read / write data to get your workflow that way. If it's an MS database, then you'll have to see if there is some sort of command line tool available to read from / write to the db. Then, reverse engineer the structure, and you're good to go.

 

If the latter way works out, then make sure you make a copy of the db to test on (when writing) so that you don't muss it up.

Link to comment

If it's an MS database, then you'll have to see if there is some sort of command line tool available to read from / write to the db. Then, reverse engineer the structure, and you're good to go.

 

If the latter way works out, then make sure you make a copy of the db to test on (when writing) so that you don't muss it up.

 

Since it's a Mac App Store app, the note files are containerized in the following directory:

 

~/Library/Containers/com.microsoft.onenote.mac/Data/Library/Application Support/Microsoft User Data/OneNote/

 

They're stored as an offline cache (synced to the master file on Microsoft OneDrive) in a proprietary .onecache extension, with assets of each note stored separately as .onebin files.

 

It's not pretty and I don't have enough skills to reverse engineer this. Command-line tools are available for Windows, and they're limited to repairing the database and other maintenance tasks.

Edited by Pennyworth
Link to comment

If you just want to get Alfred to open a search for you, and not display the search results in Alfred, you can do it with Applescript UI scripting.  Here is a basic workflow that searches all notebooks:

 

https://www.dropbox.com/s/bknw2b8xv93m7zf/Search%20Microsoft%20OneNote.alfredworkflow?dl=0

 

Thanks dfay! Your solution gets me most of the way there! If there was only a way to pass through the search results to Alfred, we'd be golden.

Link to comment
  • 1 year later...

That little script works great.  Except when Onenote is minimized... how would you change the applescript to first activate the window (reopen)?  One note just seems to stay minimized, even if I change the applescript by adding activate and reopen.

Link to comment
  • 8 months later...
  • 2 years later...

Try using this as an AppleScript action. It'll copy whatever you have selected (in any window/app), open OneNote, create a new note, and paste into that note's body. 

 

on alfred_script(q)
  tell application "System Events" to keystroke "c" using {command down}
  delay 1
  tell application "Microsoft OneNote" to activate
  tell application "System Events" to keystroke "n" using {command down}
  tell application "System Events" to keystroke tab
  tell application "System Events" to keystroke "v" using {command down}
end alfred_script

 

Link to comment
  • 3 years later...
On 5/1/2016 at 9:54 PM, jtheun said:

That little script works great.  Except when Onenote is minimized... how would you change the applescript to first activate the window (reopen)?  One note just seems to stay minimized, even if I change the applescript by adding activate and reopen.

Any solution to this? The UI script takes some time to run. Is there a way to make it faster by using Javascript or something else. 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...