AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

my IfWinActive line isn't working

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Da Rossa



Joined: 06 Dec 2007
Posts: 206

PostPosted: Wed Feb 13, 2008 8:30 am    Post subject: my IfWinActive line isn't working Reply with quote

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? Smile
_________________
AHK is perfect.
Back to top
View user's profile Send private message
dmatch



Joined: 15 Oct 2007
Posts: 113

PostPosted: Wed Feb 13, 2008 5:15 pm    Post subject: Reply with quote

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
View user's profile Send private message
Da Rossa



Joined: 06 Dec 2007
Posts: 206

PostPosted: Wed Feb 13, 2008 7:08 pm    Post subject: Reply with quote

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. Smile
_________________
AHK is perfect.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group