slightly_abnormal Posted March 24, 2006 Share Posted March 24, 2006 (edited) I'm making a window, when i hit enter it will close, right now the hotkey is not working because it is globably and it just doesn't work like it should, hitting enter while the window "about" window is active should close it.., if the window is not active then ignore you know like most windows with the okay, or done button.. #include <GUIConstants.au3> $Form2 = GUICreate("About", 323, 239, 302, 218) GUISetIcon("D:\006.ico") $co = GUICtrlCreateGroup("", 8, 8, 305, 185) $cd = GUICtrlCreatePic("", 16, 24, 105, 97) GUICtrlCreateLabel("Product Name", 152, 24, 72, 17) GUICtrlCreateLabel("Version", 152, 48, 39, 17) GUICtrlCreateLabel("Copyright", 16, 136, 48, 17) GUICtrlCreateLabel("Comments", 16, 160, 53, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $bt = GUICtrlCreateButton("&OK", 112, 208, 75, 25) GUISetState(@SW_SHOW) hotkeyset("{enter}", "_x") While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $bt exit ;;;;;;; EndSelect WEnd Exit Func _kill() Exit 0 EndFunc Func _x() Exit EndFunc Edited March 24, 2006 by slightly_abnormal Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 24, 2006 Moderators Share Posted March 24, 2006 (edited) I'm making a window, when i hit enter it will close, right now the hotkey is not working because it is globably and it just doesn't work like it should, hitting enter while the window "about" window is active should close it.., if the window is not active then ignore you know like most windows with the okay, or done button.. #include <GUIConstants.au3> $Form2 = GUICreate("About", 323, 239, 302, 218) GUISetIcon("D:\006.ico") $co = GUICtrlCreateGroup("", 8, 8, 305, 185) $cd = GUICtrlCreatePic("", 16, 24, 105, 97) GUICtrlCreateLabel("Product Name", 152, 24, 72, 17) GUICtrlCreateLabel("Version", 152, 48, 39, 17) GUICtrlCreateLabel("Copyright", 16, 136, 48, 17) GUICtrlCreateLabel("Comments", 16, 160, 53, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $bt = GUICtrlCreateButton("&OK", 112, 208, 75, 25) GUISetState(@SW_SHOW) hotkeyset("{enter}", "_x") While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $bt exit ;;;;;;; EndSelect WEnd Exit Func _kill() Exit 0 EndFunc Func _x() Exit EndFuncYou pretty much answered your own question didn't you?Func _x() If WinActive($Form2) Then Exit EndFunc Edited March 24, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
slightly_abnormal Posted March 24, 2006 Author Share Posted March 24, 2006 You pretty much answered your own question didn't you?Func _x() If WinActive($Form2) Then Exit EndFunc Man.. i tried nearly everything, i tried that but it disables enter when a different window is active.. Link to comment Share on other sites More sharing options...
slightly_abnormal Posted March 24, 2006 Author Share Posted March 24, 2006 Man.. i tried nearly everything, i tried that but it disables enter when a different window is active.. maybe a simple way would be giving the "okay" button focus.. but how? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 24, 2006 Moderators Share Posted March 24, 2006 You could always reset the hotkeyexpandcollapse popup#include <GUIConstants.au3> $Form2 = GUICreate("About", 323, 239, 302, 218) GUISetIcon("D:\006.ico") $co = GUICtrlCreateGroup("", 8, 8, 305, 185) $cd = GUICtrlCreatePic("", 16, 24, 105, 97) GUICtrlCreateLabel("Product Name", 152, 24, 72, 17) GUICtrlCreateLabel("Version", 152, 48, 39, 17) GUICtrlCreateLabel("Copyright", 16, 136, 48, 17) GUICtrlCreateLabel("Comments", 16, 160, 53, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $bt = GUICtrlCreateButton("&OK", 112, 208, 75, 25) GUISetState(@SW_SHOW) HotKeySet('{ENTER}', "_x") While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $bt exit ;;;;;;; EndSelect WEnd Exit Func _kill() Exit 0 EndFunc Func _x() If BitAND(WinGetState($Form2), 8) Then Exit Else HotKeySet('{ENTER}') Send('{ENTER}') HotKeySet('{ENTER}', "_x") EndIf EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
slightly_abnormal Posted March 24, 2006 Author Share Posted March 24, 2006 this is much better! thanks smoke_n once again. 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