| View previous topic :: View next topic |
| Author |
Message |
Da Rossa
Joined: 06 Dec 2007 Posts: 206
|
Posted: Wed Feb 13, 2008 8:30 am Post subject: my IfWinActive line isn't working |
|
|
Hi
Since I edit my main script too much, I assigned a hotkey (NumpadEnter) to have it saved then reloaded, like the following:
| Code: | ; SAVE & RELOAD
NumpadEnter::
IfWinActive, TextPad - [D:\Docs\AHK\scripts\Script.ahk *]
WinActivate ; Automatically uses the window found above.
WinMaximize ; same
Send, ^s
Reload
return |
But most of the body of that piece of code has been copied from I don't know where. I'd like it to have the NumpadEnter key have the specified function only when the Textpad Window with the script file loaded on it is active, not only existent. I'd like to keep the original function of the NumpadEnter key when the Textpad window is not the foremost one. An attempt was this one...
| Code: | ; SAVE & RELOAD
NumpadEnter::
IfWinActive, TextPad - [D:\Docs\AHK\scripts\Script.ahk *]
{
Send, ^s
Reload
return
}
else
{
send {enter}
return
} |
... but it didn't work - the NumpadEnteer key kept triggering the reload of the script, no matter the textpad window was active or not. I could see the AHK icon vanishing and reappearing on the tray.
What's wrong?  _________________ AHK is perfect. |
|
| Back to top |
|
 |
dmatch
Joined: 15 Oct 2007 Posts: 113
|
Posted: Wed Feb 13, 2008 5:15 pm Post subject: |
|
|
FWIW, On the system I am currently running (Windows Me) AutoHotKey can't tell the difference between NumPadEnter and Enter.
Perhaps #SingleInstance Force at the top of you script(s) would do what you want. Then all you have to do is send a ^1 (TextPad-run script on my version on tool menu). The setup for tools is in configure-preferences-tools in Textpad. TextPad automatically saves a file before it applies a tool to it.
You Add the tool (configure-preferences-tools), Apply, and then click on its name in the navigation tree at left to set its properties.
dmatch |
|
| Back to top |
|
 |
Da Rossa
Joined: 06 Dec 2007 Posts: 206
|
Posted: Wed Feb 13, 2008 7:08 pm Post subject: |
|
|
but in XP there is the difference between NumpadEnter and the regular Enter. In here, the main one works normally while the NumEnter only does what I told it to do. But it's doing it 'too much': I only want the NumEnter key to do the save&reload when the active (foremost) window is the textpad with the script loaded in it..
And it doesn't have anything to do with the #singleinstance thing, trust me. I'm almost sure it's all about the syntax I wrote.  _________________ AHK is perfect. |
|
| Back to top |
|
 |
|