Sign in to follow this  
Followers 0
iCode

HotKeySet bug?

4 posts in this topic

When Alt+e is pressed to show the second GUI, and the "e" key is the last to be released, the first press of Esc will not close the GUI

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("", 100, 100, 100, 100)
$Form2 = GUICreate("", 200, 200, 200, 200)
GUISetState(@SW_SHOW, $Form1)

HotKeySet("!e", "_form2")

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func _form2()
    GUISetState(@SW_SHOW, $Form2)
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
    GUISetState(@SW_HIDE, $Form2)
EndFunc

FUNCTIONS: WinDock (dock window to screen edge) | EditCtrl_ToggleLineWrap (line/word wrap for AU3 edit control) | SendEX (yet another alternative to Send( ) ) | Spell Checker (Hunspell wrapper) | SentenceCase (capitalize first letter of sentences)

CODE SNIPPITS: Dynamic tab width (set tab control width according to window width)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

That's odd.

If is send Alt+e, without focus on the first window, the esc works fine on the second window.

If i have focus on the first window, I need to press esc 2x to get it to register with the new window.

Tried playing around with WinActivate, and created controls in the second window to focus on, but the above is always the case.

This works (removes focus from first form)

$Form1 = GUICreate("", 100, 100, 100, 100)
$Form2 = GUICreate("", 200, 200, 200, 200)
GUISetState(@SW_SHOW, $Form1)

HotKeySet("!e", "_form2")

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func _form2()
    WinSetState($Form1,"",@SW_MINIMIZE )
    GUISetState(@SW_SHOW, $Form2)
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
    GUISetState(@SW_HIDE, $Form2)
    WinSetState($Form1,"",@SW_RESTORE )
EndFunc
Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Figured it out.  Since your hot key is with the alt, when you bring focus to the new window, the 'file' menu (top left icon) is enabled, so first escape is to deselect that (if you press space, it will open the menu...just to prove my point) then escape to exit the window.

Change the hotkeyset to ^e

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

I see what you mean, but that still seems strange. Maybe i don't understand how HotKeySet works, but it seems to me that the alt key shouldn't focus the context menu on the 2nd window until it is released and pressed again. In other words, if i set a hotkey for a function, it seems like the hotkey should not be able to be used by anything else until it is released and pressed again by itself, or with any other key than "e".

No big deal as i can change the keys, and thanks for spotting that the context menu was focused (verified with the space key). I think that sheds light on another intermittent problem i'v been having with hotkeys.


FUNCTIONS: WinDock (dock window to screen edge) | EditCtrl_ToggleLineWrap (line/word wrap for AU3 edit control) | SendEX (yet another alternative to Send( ) ) | Spell Checker (Hunspell wrapper) | SentenceCase (capitalize first letter of sentences)

CODE SNIPPITS: Dynamic tab width (set tab control width according to window width)

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