This first snippet shows the start of the script including the hotkey.
Code: Select all
#m:: ;
IfWinExist, Scrivener
SetKeydelay, 100
InputBox, AHKronym, Enter AHKronym, type AHKronym
Code: Select all
if AHKronym = h1 ; scrivener heading 1
{ SetKeyDelay, 20
Send !rra{Down}{Down 1}{Enter}
}
if AHKronym = h2 ; scrivener heading 2
{ SetKeyDelay, 20
Send !rra{Down 2}{Enter}
}
if AHKronym = h3 ; scrivener heading 3
{ SetKeyDelay, 20
Send !rra{Down 3}{Enter}
}
if AHKronym = h4 ; scrivener heading 4
{ SetKeyDelay, 20
Send !rra{Down 4}{Enter}
[b] exit ; i have started adding this to terminate the whole thing after the desired If has run. [/b]
}
if AHKronym = vt
{ SetKeyDelay, 20
Send !v{Up}{Enter}
}
if AHKronym = fave ; open, then move and resize Scriv Favorites windows
Send !dfm
{ SetKeyDelay, 100
WinMove, DoMM,,1536,156,DEFAULT, 440
}
if AHKronym = start ; goes to specified folder
{ Run C:\ProgramData\Microsoft\Windows\Start Menu\Programs
}
For example, when I enter h1, h2, or h3 in the Input box, the corresponding If routine runs, but then it continues down to the WinMove statement that follow in the the IF below (next to last from bottom), where the WinTitle parameter matches the window that gets moved and resized (when it was just supposed to be a dialog box within that app that gets moved, and only when the appropriate If gets called.)
I've found that as in the h4 example, if I put in an Exit statement, the execution stops. I more or less understand why this is happening, but this has only started recently, and I've been adding to this script for almost a year, so there's something I'm not getting.
Should I be adding Exit at the end of all the If sequences? Or is there something I can do with the brackets within each of the Ifs, for example, putting the first one to the left of the If itself, making the entire thing self contained? Or should I be using Return in some way.
Thanks for any help on this. And apologies for the noobness of the question. I hope I've explained it clearly.