TerryF Posted May 26, 2015 Share Posted May 26, 2015 (edited) I have a working database application (using SQLite and Excel) and decided that I would speed up data entry by mapping a couple of keyboard keys to two of the GUI buttons so as cut down on mouse movement back and forth across the screen. I used the GUISetAccelerators() function to map the forward slash (\) and back slash (/) keys to a couple of button handles and this works OK except that the mouse has to move (even a pixel will do) after the accelerator key is pressed before the code will respond to the key press. I can press the key, nothing happens, wait 10 seconds, still nothing, move the mouse pointer and immediately the program responds to the key press.Whilst the app is over 6000 lines of code and has taken me several months to develop (so well tested by now), this is the first time I have tried to use GUISetAccelerators(). What trick am I missing here?I will post more code if anybody thinks this will help, but I thought that somebody might have come across this effect before (yet a search turned up nothing useful)Thanks, TerryLocal $CTRL_Van_Save = GUICtrlCreateButton("SAVE" & @CRLF & "and" & @CRLF & "\/ NEXT \/" & @CRLF & "( \ )", 1335, 375, 150, 100, $BS_MULTILINE ) GUICtrlSetFont(-1, 11) ... ; Set GUIAccelerator for the SAVE & NEXT button Local $aAccelKeys[2][2] = [["\", $CTRL_Van_Save],["/", $CTRL_Work_But]] GUISetAccelerators($aAccelKeys) $Refresh = 1 While 1 $key = Get_Click() Switch ($key) Case $CTRL_Work_But If GUICtrlRead($CTRL_Work_But) = 0 Then GUICtrlSetData($CTRL_Work_But, $aDataIn[$index][12]) ... Case $CTRL_Van_Save ;does DataIn array have correct lookup values from radio and Attention? $Prop_ID = $aDataIn[$index][0] $aDataIn[$index][2] = GUICtrlRead($CTRL_Van_Notes) $aDataIn[$index][2] = StringReplace($aDataIn[$index][2], "'", "''") ;escape any apostrophes ... Edited May 26, 2015 by Melba23 Added code tags Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 26, 2015 Moderators Share Posted May 26, 2015 TerryF,Welcome to the AutoIt forums.What is inside the Get_Click function? I would have expected to see a GUIGetMsg at that point and I wonder if that might be a possible problem.M23 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...
TerryF Posted May 26, 2015 Author Share Posted May 26, 2015 (edited) Melba23,Thanks for the welcome. I should have included the function, but it is straightforward:Func Get_Click() ;get user input ;get user click or key press Local $msg Do $msg = GUIGetMsg() Until $msg <> 0 Return $msg EndFuncI have just written a little test prog and this does not exhibit the same issue, it works fine, so it looks like it is something in my code that is causing the problem.expandcollapse popupLocal $CTRL_Screen = GUICreate("Test Screen", 450, 400, 275, 200, BitOR($WS_SYSMENU, $WS_CAPTION, $WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX), $WS_EX_APPWINDOW ) Local $CTRL_Van_Save = GUICtrlCreateButton("SAVE" & @CRLF & "and" & @CRLF & "\/ NEXT \/" & @CRLF & "( \ )", 150, 100, 150, 100, $BS_MULTILINE ) GUICtrlSetFont(-1, 11) Local $CTRL_Exit = GUICtrlCreateButton("EXIT", 150, 350, 150, 40 ) GUICtrlSetFont(-1, 11) Local $CTRL_Count = GUICtrlCreateLabel("0", 200, 260, 50, 30) GUICtrlSetFont(-1, 11) Local $Count = 0 GUISetState(@SW_SHOW, $CTRL_Screen) ; Set GUIAccelerator for the SAVE & NEXT button Local $aAccelKeys[1][2] = [["\", $CTRL_Van_Save]] GUISetAccelerators($aAccelKeys) While 1 $key = Get_Click() Switch ($key) Case $CTRL_Van_Save $Count += 1 GUICtrlSetData($CTRL_Count, $Count) Case $CTRL_Exit Exit Endswitch Wend Exit Func Get_Click() ;get user input ;get user click or key press Local $msg Do $msg = GUIGetMsg() Until $msg <> 0 Return $msg EndFuncRegards, Terry Edited May 26, 2015 by Melba23 Added code tags Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 26, 2015 Moderators Share Posted May 26, 2015 TerryF,I have just written a little test prog and this does not exhibit the same issue, it works fine, so it looks like it is something in my code that is causing the problemSo did my test - so I can only agree with you.M23P.S. When you post code please use Code tags - see here how to do it. Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. 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...
TerryF Posted May 26, 2015 Author Share Posted May 26, 2015 M23,Thanks for the response and advice. Further experimenting has fixed the issue, my original code calls the GetClick() function and then refreshes the screen by updating a lot of fields and only then gets to a Switch($key) statement where it uses the $key value provided by the GetClick() call to correctly process the user input. Because the $key variable held the user input during the screen processing I would not have expected any issue, and did not have any until now. However, moving the GetClick() call to immediately before the Switch($key) statement solves the problem. Perhaps something has changed within the Windows internals during the delay that was causing the issue?expandcollapse popup; lots of screen update code $key = Get_Click() Switch ($key) ;works OK ;rather than: $key = Get_Click() If $Refresh > 0 Then ;display the correct rows in each listview For $top = 1 to 12 $ptr = ($index + $top - 13) If $ptr < 1 Then GUICtrlSetData($a_h_Top[$top], " | | | | | | | | | | | | " ) Else $pay_type = " " $pay_amt = Format2str($aDataIn[$ptr][9]) Switch $aDataIn[$ptr][10] Case "" $pay_type = " " Case 0 $pay_type = " " Case 1 $pay_type = "Cash" Case 2 $pay_type = "Cheque" Case 3 $pay_type = "Split" $pay_amt = Format2str($aDataIn[$ptr][9] + $aDataIn[$ptr][15]) EndSwitch $Flag = " " If $aDataIn[$ptr][11] = 1 Then $Flag = " X" $PrePay = "" If $aDataIn[$ptr][20] < 0 Then $PrePay = " CR" GUICtrlSetData($a_h_Top[$top], $aDataIn[$ptr][1] & "|" & $aDataIn[$ptr][2] & " | " & $aDataIn[$ptr][3] & "| " & $aDataIn[$ptr][4] & "| " & $aDataIn[$ptr][5] & "| " & $aDataIn[$ptr][6] & "| £" & $aDataIn[$ptr][7] & "| ¦ | " & $aDataIn[$ptr][8] & "| " & $pay_amt & "|" & $pay_type & "| " & $Flag & "| £" & $aDataIn[$ptr][20] & $PrePay) Endif Next For $btm = 1 to 12 $ptr = ($index + $btm) If $ptr > $aDataIn[0][0] Then GUICtrlSetData($a_h_Btm[$btm], " | | | | | | | | | | | | " ) Else $pay_type = " " $pay_amt = Format2str($aDataIn[$ptr][9]) Switch $aDataIn[$ptr][10] Case "" $pay_type = " " Case 0 $pay_type = " " Case 1 $pay_type = "Cash" Case 2 $pay_type = "Cheque" Case 3 $pay_type = "Split" $pay_amt = Format2str($aDataIn[$ptr][9] + $aDataIn[$ptr][15]) EndSwitch $Flag = " " If $aDataIn[$ptr][11] = 1 Then $Flag = " X" $PrePay = "" If $aDataIn[$ptr][20] < 0 Then $PrePay = " CR" GUICtrlSetData($a_h_Btm[$btm], $aDataIn[$ptr][1] & "|" & $aDataIn[$ptr][2] & " | " & $aDataIn[$ptr][3] & "| " & $aDataIn[$ptr][4] & "| " & $aDataIn[$ptr][5] & "| " & $aDataIn[$ptr][6] & "| £" & $aDataIn[$ptr][7] & "| ¦ | " & $aDataIn[$ptr][8] & "| " & $pay_amt & "|" & $pay_type & "| " & $Flag & "| £" & $aDataIn[$ptr][20] & $PrePay) Endif Next ;refresh middle bit $Label = GUICtrlSetData($CTRL_Property, $aDataIn[$index][1]) $Label = GUICtrlSetData($CTRL_Van_Notes, $aDataIn[$index][2]) $Label = GUICtrlSetData($CTRL_Prev_2_Work, $aDataIn[$index][3]) $Label = GUICtrlSetData($CTRL_Prev_2_Paid, $aDataIn[$index][4]) $Label = GUICtrlSetData($CTRL_Prev_1_Work, $aDataIn[$index][5]) $Label = GUICtrlSetData($CTRL_Prev_1_Paid, $aDataIn[$index][6]) $Label = GUICtrlSetData($CTRL_Curr_Balance, Number($aDataIn[$index][7])) If $aDataIn[$index][15] <> 0 AND $aDataIn[$index][14] <> 1 Then ;cannot split $Label = GUICtrlSetState($CTRL_Split_But, $GUI_DISABLE) Else $Label = GUICtrlSetState($CTRL_Split_But, $GUI_ENABLE) Endif ; $Label = GUICtrlSetData($CTRL_Now_Work, Number($aDataIn[$index][8])) ; $Label = GUICtrlSetData($CTRL_Now_Paid, Number($aDataIn[$index][9])) $Work = $aDataIn[$index][8] If $Work = " " Then $Work = "" $Paid = $aDataIn[$index][9] If $Paid = " " Then $Paid = "" $Label = GUICtrlSetData($CTRL_Now_Work, $Work) $Label = GUICtrlSetData($CTRL_Now_Paid, $Paid) $Label = GUICtrlSetData($CTRL_Work_But, $aDataIn[$index][12]) $Label = GUICtrlSetData($CTRL_Paid_But, $aDataIn[$index][12]) If $aDataIn[$index][10] = 1 Then $Label = GUICtrlSetState($CTRL_Now_Cash, $GUI_CHECKED) Else $Label = GUICtrlSetState($CTRL_Now_Cash, $GUI_UNCHECKED) Endif If $aDataIn[$index][10] = 2 Then $Label = GUICtrlSetState($CTRL_Now_Chq, $GUI_CHECKED) Else $Label = GUICtrlSetState($CTRL_Now_Chq, $GUI_UNCHECKED) Endif If $aDataIn[$index][10] = 3 Then $Label = GUICtrlSetState($CTRL_Now_Split, $GUI_CHECKED) Else $Label = GUICtrlSetState($CTRL_Now_Split, $GUI_UNCHECKED) Endif If $aDataIn[$index][11] = 1 Then $Label = GUICtrlSetState($CTRL_Attn, $GUI_CHECKED) Else $Label = GUICtrlSetState($CTRL_Attn, $GUI_UNCHECKED) Endif $Refresh = 0 ; set cursor in Work edit field $Label = GUICtrlSetState($CTRL_Now_Work, $GUI_FOCUS) Endif Switch ($key) 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