Sign in to follow this  
Followers 0
advis0r

hotkeys should only with certain windows

3 posts in this topic

hi there,

i want to control an app with my keyboard (usually you have to use the mouse), everything works allright but i want the hotkeys only to work within certain windows (indicated by their title)

i started using

IF WinActive($WINDOW_TEXT) THEN ...

and it semi-works, functions wont be called in other windows, but the problem is, that the hotkeyed keys are not usuable in the other windows either (like when i switch to the script editor i cannt move the cursor with the arrow keys since they are bound in my script)

is there a way to get around that i.e. make hotkeys only available under given conditions (window handle, window title etc) ?

would be really useful, sorry if i didnt find it in the forums yet

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Something like this should work.

$winTitle = "Title of window where I want the hotkeys"

While 1
    sleep(100);don't max-out CPU
    If WinActive($winTitle) Then
        EnableHotKeys()
    Else
        DisableHotkeys()
    EndIf
WEnd

Func EnableHotkeys()
    HotKeySet("!^a", "foo")
    HotKeySet("!^b", "foo")
EndFunc

Func DisableHotkeys()
    HotKeySet("!^a")
    HotKeySet("!^b")
EndFunc

Func foo()
;...
EndFunc

Func bar()
;...
EndFunc
Edited by CyberSlug

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

thanks, i loaded the hotkeys from an ini file and so i had to make variables for the bound key globally in order to not read from harddisc every 100ms :o

Edited by advis0r

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0