Verssuss Posted April 12, 2017 Share Posted April 12, 2017 hey guys. here is simple example with keys pressed. after u click button: press a - working good press 1 - working good press F1 - working good but after u click buton and press SPACEAR it wont work good. what is problem ??? expandcollapse popup#include <Misc.au3> #include <MsgBoxConstants.au3> #include <GUIConstantsEx.au3> $GUI = GUICreate("set hotkeys", -1,-1) GUISetState() $button_hotkey = (GUICtrlCreateButton("", 80, 30, 150, 25)) Local $hDLL = DllOpen("user32.dll") $start = False While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE Exit Case $button_hotkey $start = True GUICtrlSetData($button_hotkey, "Press Hot Key") EndSwitch If $start = True And _IsPressed('20', $hDLL) Then $start = False $klawisz1 = "SPACEBAR" GUICtrlSetData($button_hotkey, $klawisz1) $start = False ;~ Beep(500) EndIf If $start = True And _IsPressed('31', $hDLL) Then $klawisz1 = "1" GUICtrlSetData($button_hotkey, $klawisz1) $start = False EndIf If $start = True And _IsPressed('41', $hDLL) Then $klawisz1 = "a" GUICtrlSetData($button_hotkey, $klawisz1) $start = False EndIf If $start = True And _IsPressed('70', $hDLL) Then $klawisz1 = "F1" GUICtrlSetData($button_hotkey, $klawisz1) $start = False EndIf WEnd Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 12, 2017 Moderators Share Posted April 12, 2017 Verssuss, Pressing the Spacebar actions the default control - this is a Windows default, nothing to do with AutoIt. I suggest creating a dummy control to which you can give focus so that the main button does not get actioned: expandcollapse popup#include <Misc.au3> #include <MsgBoxConstants.au3> #include <GUIConstantsEx.au3> $GUI = GUICreate("set hotkeys") GUISetState() $button_hotkey = (GUICtrlCreateButton("", 80, 30, 150, 25)) $cDummy = GUICtrlCreateButton("Dummy", 80, 100, 150, 25) ; Here is your dummy control <<<<<<<<<<<<< Local $hDLL = DllOpen("user32.dll") $start = False While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE DllClose($hDLL) ; If you open it then you must close it <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Exit Case $button_hotkey $start = True GUICtrlSetData($button_hotkey, "Press Hot Key") GUICtrlSetState($cDummy, $GUI_FOCUS) ; Give focus to the dummy <<<<<<<<<<<<<<<<<<<<<<<<< EndSwitch If $start = True And _IsPressed('20', $hDLL) Then $start = False $klawisz1 = "SPACEBAR" GUICtrlSetData($button_hotkey, $klawisz1) $start = False ;~ Beep(500) EndIf If $start = True And _IsPressed('31', $hDLL) Then $klawisz1 = "1" GUICtrlSetData($button_hotkey, $klawisz1) $start = False EndIf If $start = True And _IsPressed('41', $hDLL) Then $klawisz1 = "a" GUICtrlSetData($button_hotkey, $klawisz1) $start = False EndIf If $start = True And _IsPressed('70', $hDLL) Then $klawisz1 = "F1" GUICtrlSetData($button_hotkey, $klawisz1) $start = False EndIf WEnd M23 232showtime and Verssuss 2 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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