Hi, just started using AHK, and have written my first little script for MS OneNote but am having trouble with the second. I'm pretty lost with this stuff, to be honest.
I find that OneNote has pretty weak hyperlinking commands, so I want to make a couple of tweaks.
First, I wanted to be able to quickly link two pages to each other. This little script copies the hyperlink to the current page, inserts that hyperlink to the
previous page (at wherever the insertion point was left) and then inserts a hyperlink to that second page back on the first page where you started. IOW, it creates mutually linking pages.
Code:
#c::
Send !ehg!{Left}^v^t!ehg!{Right}^v
;copies hyperlink to current page
;back to last page
;paste
;move to page header
;copies hyperlink to current page
;forward to earlier page
;paste
return
OK, so it's a pretty simple code. How could it be improved upon? I don't even know how to make it work exclusively in OneNote.
But here's my question. I'd like to make another script to copy text formatted with a hyperlink to its current section. IE, the pasted item contains a link to its original position (similar to what happens when you paste a clip from a web site, in fact).
I was going to do a simple macro of keyboard commands like the previous script. Something like the following commands, which I could use when I have something selected: "Copy hyperlink to current section" > "insert hyperlink" > "paste" > "enter" > "copy" > "AppsKey" > "remove hyperlink".
Again, not very sophisticated, I'm sure, but I don't see why it wouldn't work.
The only problem is that after closing the hyperlink dialog box, the text that was originally selected is no longer selected, (ie, between "enter" and "copy" in my little sequence). So, I'm thinking I need AHK to remember what I had originally selected, and then reselect it before going on to the next set of commands.
So how would i do that? Or am I going about this all wrong?