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 

Only process hotkeys if certain window is active

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
kiwijunglist



Joined: 26 May 2009
Posts: 8

PostPosted: Tue Oct 06, 2009 2:26 pm    Post subject: Only process hotkeys if certain window is active Reply with quote

Hi

I made this script that allows me to cancel a recent reload when i press the left mouse button. I only want to run the script when the game window is active, what would the best way of acheiving that be?

Many thanks

Code:

#SingleInstance force
#InstallMouseHook
#InstallKeybdHook

Cancel_Reload = 0

*~r::
  Cancel_Reload = 1
  Sleep 1500
  Return

*~f::
  Cancel_Reload = 0
  Return

*~WheelDown::
  Cancel_Reload = 0
  Return

*~LShift::
  Cancel_Reload = 1
  Return

*~LShift Up::
  Sleep 500
  Cancel_Reload = 0
  Return

*~RButton::
  Cancel_Reload = 0
  Return

*~LButton::
  If Cancel_Reload = 1
  {
     Send, 1
     Send, 1
     Cancel_Reload = 0
  }
  Return
Back to top
View user's profile Send private message
doyle



Joined: 14 Nov 2007
Posts: 325
Location: London, England

PostPosted: Tue Oct 06, 2009 2:28 pm    Post subject: Reply with quote

#IfWinActive
Back to top
View user's profile Send private message Visit poster's website
Carcophan



Joined: 24 Dec 2008
Posts: 1308
Location: :noitacoL

PostPosted: Tue Oct 06, 2009 2:28 pm    Post subject: Reply with quote

IfWinActive?

IfWinNotActive, IfWinExist
Back to top
View user's profile Send private message
aaffe



Joined: 17 May 2007
Posts: 1002
Location: Germany - Deutschland

PostPosted: Tue Oct 06, 2009 2:29 pm    Post subject: Reply with quote

Try this.
Put the game window name instead of <GAME WINDOW>
Code:


#SingleInstance force
#InstallMouseHook
#InstallKeybdHook
SetTitlematchmode, 2

Cancel_Reload = 0

#IfWinActive,<GAME WINDOW>
*~r::
  Cancel_Reload = 1
  Sleep 1500
  Return

*~f::
  Cancel_Reload = 0
  Return

*~WheelDown::
  Cancel_Reload = 0
  Return

*~LShift::
  Cancel_Reload = 1
  Return

*~LShift Up::
  Sleep 500
  Cancel_Reload = 0
  Return

*~RButton::
  Cancel_Reload = 0
  Return

*~LButton::
  If Cancel_Reload = 1
  {
     Send, 1
     Send, 1
     Cancel_Reload = 0
  }
  Return
#IfwinActive
Back to top
View user's profile Send private message
kiwijunglist



Joined: 26 May 2009
Posts: 8

PostPosted: Tue Oct 06, 2009 3:35 pm    Post subject: Reply with quote

thank you
also thanks for settitlematchmode
Back to top
View user's profile Send private message
Display posts from previous:   
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