Jump to content

Recommended Posts

Posted

The difficulty I am experiencing is I would like to use the enter key to do different functions when the focus is on a specific control.

I must admit it works very well until you change the focus from the gui created to a different window like internet explorer. Now the enter key doesn't work at all because it is still being captured by the created gui. Is there a way for the hotkey to be localized to the gui?

I have supplied some sample code.

CODE
#include <GUIConstants.au3>

HotKeySet("{Enter}", "captureEnter")

Opt("GUIOnEventMode", 1)

$Form1 = GUICreate("Form1", 271, 375, 193, 125)

GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")

$Input1 = GUICtrlCreateInput("Input1", 48, 24, 121, 21)

GUICtrlSetOnEvent(-1, "Input1Change")

$Input2 = GUICtrlCreateInput("Input2", 48, 69, 121, 21)

GUICtrlSetOnEvent(-1, "Input2Change")

$Input3 = GUICtrlCreateInput("Input3", 48, 114, 121, 21)

GUICtrlSetOnEvent(-1, "Input3Change")

$Input4 = GUICtrlCreateInput("Input4", 48, 158, 121, 21)

GUICtrlSetOnEvent(-1, "Input4Change")

$Input5 = GUICtrlCreateInput("Input5", 48, 203, 121, 21)

GUICtrlSetOnEvent(-1, "Input5Change")

$Edit1 = GUICtrlCreateEdit("", 48, 248, 185, 89)

GUICtrlSetData(-1, "Edit1")

GUICtrlSetOnEvent(-1, "Edit1Change")

GUISetState(@SW_SHOW)

While 1

Sleep(100)

WEnd

Func Edit1Change()

MsgBox(0, "", "Edit1")

EndFunc

Func Form1Close()

Exit

EndFunc

Func Input1Change()

MsgBox(0, "", "Input1")

EndFunc

Func Input2Change()

MsgBox(0, "", "Input2")

EndFunc

Func Input3Change()

MsgBox(0, "", "Input3")

EndFunc

Func Input4Change()

MsgBox(0, "", "Input4")

EndFunc

Func Input5Change()

MsgBox(0, "", "Input5")

EndFunc

Func captureEnter()

$text = ControlGetFocus("Form1")

MsgBox(0, "", $text)

EndFunc

Posted

Either:

  • Check if your GUI has focus and register/unregister the hotkey, or
  • Use GUISetAccelerators() instead, they are by nature for only one GUI

Thanks very much for your help

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