maikelmeyers Posted October 11, 2008 Share Posted October 11, 2008 Hi, can anyone tell me how to control keys in a gui? For example: if I press ESC the gui closes. How can I avoid this? Second example: If a combobox is in focus, how is it possible to do some action when ENTER is pressed. Is it possible to get a message? In the moment if I press ENTER it activates another checkbox which has not the focus. I don't find any functions related to keyboard except hotkeyset, but this is not usable because then you can not run multiple instances of that script. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted October 11, 2008 Share Posted October 11, 2008 Opt("GUICloseOnESC", 0) .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
maikelmeyers Posted October 11, 2008 Author Share Posted October 11, 2008 Opt("GUICloseOnESC", 0) thanks, first question solved but I think I found a bug. Please have a look at the following example code. First click on the combobox and press ENTER. A message box will be displayed telling you the current focus. It is "Edit1". That is ok. Now press on the button. A message box informs you that the button was pressed. Then the button turns green. NOW, click the combobox and press ENTER again. Now both Items seems to be pressed, although the combobox has the focus. Why? CODE #Include <Misc.au3> #include <GUIConstants.au3> #include <WindowsConstants.au3> #Include <GuiButton.au3> $gui_window_main = GUICreate ("Test",500,500,100,100,$WS_SYSMENU) $gui_button = GUICtrlCreateButton ("test button",0,0,200,200) $gui_combo = GUICtrlCreateCombo ( "test combo",0,250,200,200) GUISetState (@SW_SHOW) while 1 if(_IsPressed("0D")) then MsgBox(1,"",ControlGetFocus ($gui_window_main)) endif $msg = GUIGetMsg(1) if($msg[0] = 0) then ContinueLoop endif if ($msg[1] = $gui_window_main) then if ($msg[0] = $gui_button) then MsgBox(1,"","button pressed") GUICtrlSetBkColor ( $gui_button, 0x88ff88 ) elseif $msg[0] = $GUI_EVENT_CLOSE then guidelete() endif endif wend Link to comment Share on other sites More sharing options...
maikelmeyers Posted October 11, 2008 Author Share Posted October 11, 2008 This does not happen when GUICtrlSetBkColor is not used Link to comment Share on other sites More sharing options...
ProgAndy Posted October 11, 2008 Share Posted October 11, 2008 use GUISetAccelerators to set a dummy control to ENTER. Then, in the Case / Func of the dummy you can make custom Handling for ENTER key on your gui *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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now