Pennyworth Posted October 7, 2014 Share Posted October 7, 2014 I'd like a workflow that can search Microsoft OneNote for Mac (notebooks, sections, pages) and possibly also create notes. Alternatively, how would I be able to build this myself? Link to comment
rice.shawn Posted October 8, 2014 Share Posted October 8, 2014 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
Pennyworth Posted October 8, 2014 Author Share Posted October 8, 2014 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
rice.shawn Posted October 8, 2014 Share Posted October 8, 2014 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
dfay Posted October 8, 2014 Share Posted October 8, 2014 (edited) 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 Edited October 8, 2014 by dfay Link to comment
Pennyworth Posted October 9, 2014 Author Share Posted October 9, 2014 (edited) 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 October 9, 2014 by Pennyworth Link to comment
Pennyworth Posted October 9, 2014 Author Share Posted October 9, 2014 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. TomBenz and manan 2 Link to comment
jtheun Posted May 1, 2016 Share Posted May 1, 2016 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
ctw Posted January 12, 2017 Share Posted January 12, 2017 hi guys, is there any updates on this? thank you! Link to comment
zac Posted March 5, 2019 Share Posted March 5, 2019 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
TomBenz Posted July 12, 2022 Share Posted July 12, 2022 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now