Jump to content

Recommended Posts

Posted

We can define a hot key in our scripts by HotKeySet(), but, it is a global hot key, I now need to make a private one, which is only work when the AutoIt GUI is activated? How to do this?

Posted

In your GUI's while loop make a condition:

Global $hotKeyIsSet

;Create $GUI here

While 1
    If WinActive("Title of window") AND $hotKeyIsSet = 0 Then 
        HotkeySet("^+Q", "hotkeyfunc")
        $hotKeyIsSet = 1
    EndIf
    If Not WinActive("Title of window") AND $hotKeyIsSet = Then
        HotkeySet("^+Q")
        $hotKeyIsSet = 0
    EndIf

WEnd

Regards,Josh

Posted (edited)

Use GUISetAccelerators muttley

Or do the Check in

WM_ACTIVATEAPP 0x001C

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Posted

HotKetSet("key" , "func")

Func func()
HotKeySet("key")
Send("key")
If WinActive($yourgui) then
;action
EndIf
HotKetSet("key" , "func")
EndFunc

When are you suggesting calling that function? If you do it every time it loops through the while, then you are doing a ton of redundant hotkeysets. Also why the Send? (Not being critical, just curious)

That also seems to be redundant because you are clearing the hotkey, then resetting it if the window is open instead of setting the hotkey once when the window becomes active, and clearing it once when it isn't.

Regards,Josh

Posted

Why is everyone putting too much thought into this?

$hGUI = GUICreate("Test", 500, 500)
$hDummy = GUICtrlCreateDummy()
$hDummy2 = GUICtrlCreateDummy()
Dim $azAccelerators[2][2] = [["^e", $hDummy],["^y", $hDummy2]]
GUISetAccelerators($azAccelerators)
GUISetState()
While 1
    Switch GUIGetMsg()
        Case - 3, $hDummy
            Exit
        Case $hDummy2
            MsgBox(0, "Hey", "Sup")
    EndSwitch
WEnd

Ctrl+E Exits, Ctrl+Y Greets you.

Posted

Why is everyone putting too much thought into this?

$hGUI = GUICreate("Test", 500, 500)
$hDummy = GUICtrlCreateDummy()
$hDummy2 = GUICtrlCreateDummy()
Dim $azAccelerators[2][2] = [["^e", $hDummy],["^y", $hDummy2]]
GUISetAccelerators($azAccelerators)
GUISetState()
While 1
    Switch GUIGetMsg()
        Case - 3, $hDummy
            Exit
        Case $hDummy2
            MsgBox(0, "Hey", "Sup")
    EndSwitch
WEnd

Ctrl+E Exits, Ctrl+Y Greets you.

My AutoIt claim the error:

ERROR: GUISetAccelerators(): undefined function.

Why?

Posted

My AutoIt claim the error:

ERROR: GUISetAccelerators(): undefined function.

Why?

You must have an old version. Update.

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
×
×
  • Create New...