Jump to content

Recommended Posts

Posted

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

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!
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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...