Joanna
Just started using AutoHotKey  desktop automation. I've seen AutoHotKey mentioned in the forums here and there, but it's been a while, and so many links are dead. Would be nice to combine useful scripts together.

For starters (nothing impressive I know, and not limited to TheBrain, but hey, I am a newbie and I found it widely useful for my time tracking):

Code that inserts
* current date when user types ]d  
* current time on ]t
* both on ]l




:*:]l::  ; This hotstring replaces "]l" with the current date and time via the commands below.
FormatTime, CurrentDateTime,, M/d/yyyy h:mm tt  ; It will look like 9/1/2005 3:53 PM
SendInput %CurrentDateTime% `
return

:*:]d::  ; This hotstring replaces "]d" with the current date 
FormatTime, CurrentDateTime,, M/d/yyyy ;
SendInput %CurrentDateTime% `
return

:*:]t::  ; This hotstring replaces "]t" with the current time 
FormatTime, CurrentDateTime,, h:mm tt  
SendInput %CurrentDateTime% `
return


My next step is to have a hotkey for posting time elapsed (since last hotkey) and for starting a pomodoro

This is not really specific to the Brain, because I am yet to figure out how to automate Brain navigation. For instance, how do I find out who my thought's parents and children are? 

Also - I recall from the evaluation version that one possible attachment was an AutoHotKey. Is it so, and if so, was it executed when double-clicked, or was there something else? 


Quote
zenrain
Quote:
This is not really specific to the Brain, because I am yet to figure out how to automate Brain navigation. For instance, how do I find out who my thought's parents and children are? 

This isn't really possible. Ok, it actually is, but would be a pain to implement. It would require using AHK to select all a thought's children (using the crawl brain and modify selection, selecting the choices you need). Then from the selected thoughts, copy to an outline, then use AHK to parse the outline and use the results for the navigation. I don't think it would save much, if any time based on the interactions AHK would have to do to get a list of thoughts.


Quote:
I recall from the evaluation version that one possible attachment was an AutoHotKey. Is it so, and if so, was it executed when double-clicked, or was there something else? 

This definitely is possible. I haven't used AHK in a while, but there is a way to convert the .ahk script to an executable (perhaps right-clicking?). Then just attach the .exe as you would normally add any attachment to TheBrain. Then clicking the .exe or Shift-Enter when the thought is selected would run the script.
[smile]
macOS 10.14.6
TheBrain 11.0.119
Quote
Joanna
zenrain wrote:
Quote:
This is not really specific to the Brain, because I am yet to figure out how to automate Brain navigation. For instance, how do I find out who my thought's parents and children are? 

This isn't really possible. Ok, it actually is, but would be a pain to implement. It would require using AHK to select all a thought's children (using the crawl brain and modify selection, selecting the choices you need). Then from the selected thoughts, copy to an outline, then use AHK to parse the outline and use the results for the navigation.

That assumes there are no thoughts with duplicate names, right?

Exporting a thought and its children into XML and parsing the XML seems a more feasible option to me. This way, we get children's GUID and can navigate by GUID. I can think of a couple ways of fetching a thought by its GUID, one is by converting a GUID to a URL; another, by generating an XML and importing it.

This seems tricky though; would be really nice if the developers of The Brain developed something to support such an effort. Wonder if there is any interest at all in turning The Brain into a platform?
Quote:

 I don't think it would save much, if any time based on the interactions AHK would have to do to get a list of thoughts.

I have not played with it, but I suspect an Autohotkey script can be very fast if animation speed is turned to Fast. Anything other than animation slowing it down?
Quote
zenrain
Yes, that is a possibility, and I had done some work on scripting AHK to use the xml exported by TheBrain for bookmarking (creating and accessing) thoughts. This was before you could use a keyboard accelerator for pinned thoughts.
Parsing the xml for navigation would be tougher as you would have to identify the thought GUID, then all the links GUIDs that have the child relation and assigned to that thought GUID. Then the use those same link GUIDs with a parent relation to get the GUIDs of the child thoughts, so you can get the name.

It could be quicker than manual navigation, but the speed is limited as you have to script AHK to select menu items, which tend to slow things down. I'm also not sure that the time it would take to script and test all that would be worth it. But that depends on what it's being used for. [smile]

I agree it would be really nice if if TheBrain was accessible via APIs, and I think I saw Patrick mention in another post that it would be easier to support app introduction in the next version (not that they were being included). Baby steps. [smile]
macOS 10.14.6
TheBrain 11.0.119
Quote
Joanna
You can get XML by right clicking on a thought -> Copy Thought. There is an XPath parser AHK script readily available, so parsing XML and finding the right nodes should be easy.

Yes, I know it's not worth it, but it can be fun. Maybe I'll get to it some day. 

If someone else does it, please post the script.
Quote
Joanna
zenrain wrote:
Yes, that is a possibility, and I had done some work on scripting AHK to use the xml exported by TheBrain for bookmarking (creating and accessing) thoughts. This was before you could use a keyboard accelerator for pinned thoughts.

Mind sharing the code? I know it's less useful now than it used to be, but it would be interesting to take a look at.
Quote
zenrain
Attached. 

All the macros are now sorely out of date, I think they were created to work with PersonalBrain 5 or 6.
The first few were to enter dates or text into notes. This worked a few versions ago as there was a keyboard accelerator to switch note view into HTML view, but that was removed in version 7 or 8.

The largest one is one I worked on with another forum member, Dyslucksia to bookmark thoughts, show a list of the thoughts that were bookmarked, and go to the bookmarked thought via a shortcut. 
I no longer used it after TheBrain implemented allowing keyboard accelerators to be assigned to the first 10 pinned thoughts (which I use all the time now I might add). 

Finally the inbox one was to assign a thought as a quick capture inbox and then add notes or possibly web sites to it quickly without having to drag and drop stuff. 

Hopefully you find some useful stuff in here.


txt TheBrainAHK.txt     
macOS 10.14.6
TheBrain 11.0.119
Quote
Joanna
Thank you! very interesting. I wonder if there is an alternative to waiting 200 millis?
Quote
zenrain
This was a few years ago so my machine was slower at that time. If a delay wasn't added it would sometimes miss steps. It could probably be adjusted depending on the machine, but I found a delay was required any time the macro interacted with the menu to give the OS time to register the step before continuing to the next one.
macOS 10.14.6
TheBrain 11.0.119
Quote

Newsletter Signup  Newsletter        Visit TheBrain Blog   Blog       Follow us on Twitter   Twitter       Like Us on Facebook   Facebook         Watch Us on Youtube  YouTube       

TheBrain Mind Map & Mindmapping Software     Download TheBrain Mind Mapping Software