TekWeis Posted May 24, 2019 Share Posted May 24, 2019 I am creating an installation tool for installing kitchen video controllers. One of my prompts is to select the configuration on which station the user is installing. I do not have a touchscreen or mouse on these controllers and must use keyboard input (keys 1-4 and a-d). Is the _IsPressed() function the only or best way to do this? I am using While and Select/Case to detect input. I have noticed that sometimes I may need to tap the key a couple of times to be accepted. My sample is below and would appreciate any feedback if this is correct or there is a more efficient method. expandcollapse popupWhile 1 $guimsg = GUIGetMsg() Select Case $guimsg = $GUI_EVENT_CLOSE $term = 99 ExitLoop Case _IsPressed("31", $hDLL) GUIDelete() $term = 1 ExitLoop Case _IsPressed("32", $hDLL) GUIDelete() $term = 2 ExitLoop Case _IsPressed("33", $hDLL) GUIDelete() $term = 3 ExitLoop Case _IsPressed("34", $hDLL) GUIDelete() $term = 4 ExitLoop Case _IsPressed("41", $hDLL) GUIDelete() $term = 5 ExitLoop Case _IsPressed("42", $hDLL) GUIDelete() $term = 6 ExitLoop Case _IsPressed("43", $hDLL) GUIDelete() $term = 7 ExitLoop Case _IsPressed("44", $hDLL) GUIDelete() $term = 8 ExitLoop EndSelect WEnd Thank you Link to comment Share on other sites More sharing options...
BrewManNH Posted May 25, 2019 Share Posted May 25, 2019 Don't use GUIGetMsg with _IsPressed, just check for the keypress directly. Something like this would work. expandcollapse popupWhile 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then $term = 99 ExitLoop EndIf If _IsPressed("31", $hDLL) Then GUIDelete() $term = 1 ExitLoop ElseIf _IsPressed("32", $hDLL) Then GUIDelete() $term = 2 ExitLoop ElseIf _IsPressed("33", $hDLL) Then GUIDelete() $term = 3 ExitLoop ElseIf _IsPressed("34", $hDLL) Then GUIDelete() $term = 4 ExitLoop ElseIf _IsPressed("41", $hDLL) Then GUIDelete() $term = 5 ExitLoop ElseIf _IsPressed("42", $hDLL) Then GUIDelete() $term = 6 ExitLoop ElseIf _IsPressed("43", $hDLL) Then GUIDelete() $term = 7 ExitLoop ElseIf _IsPressed("44", $hDLL) Then GUIDelete() $term = 8 ExitLoop EndIf WEnd If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
TekWeis Posted May 25, 2019 Author Share Posted May 25, 2019 (edited) I should have shown the previous line. There is a local variable $guitmsg =GuiGetMsg() that is being called. Your example lets me reduce an extra line that is not needed. Thanks. I added that so the application and GUI could be exited when I was testing with a mouse. Edited May 25, 2019 by TekWeis Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 25, 2019 Moderators Share Posted May 25, 2019 Hi all, Just to point out that this is a good example of what we mean when we talk about a "check for a few keys being pressed" in this announcement - and so the thread is perfectly legal. 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...
TekWeis Posted May 27, 2019 Author Share Posted May 27, 2019 My question had nothing to do with keylogging in the least, but trying to figure out how to have single response to a menu. (See attached images for screenshot of the script in use, the bumpbar keypad which is a limited keyboard input device being used, and the final application installed and running) for a restaurant kitchen video controller installer I am trying to construct. I am just trying to make sure I am approaching this correctly and to figure out why sometimes my inputs are not being read even though the keypad beeps when pressed. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 27, 2019 Moderators Share Posted May 27, 2019 TekWeis, Quote My question had nothing to do with keylogging I know that, and never said that it did. But it is a good example of a thread where the script, although looking for multiple keys being pressed, does not break the forum rules as set out in the announcement to which I linked - which is why I made the point of mentioning it. 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...
kaisies Posted May 27, 2019 Share Posted May 27, 2019 Looks very similar to a kitchen setup program I wrote for Aloha. Looks nice! I took mine a step further when I was comfortable, and it auto-set to a kitchen station if one was down on the network. Imaged controllers sent to sites, and then they just had to hit OK and magically it was setup for them. Link to comment Share on other sites More sharing options...
TekWeis Posted May 27, 2019 Author Share Posted May 27, 2019 (edited) @kaisies This setup tool scans for other kitchen controllers that are online and greys those button options, and the buttons that are green show valid selections of controllers that are not online so you will know which one to select as a valid choice. The names of the controllers are pulled from the POS configuration on the BOH so the names match the station ID. Also, Aloha Command Center is loaded on the controller by polling information from the BOH and setting correct NodeID values and key numbers within CMC. Nice to know there is someone else here that may be in my same field. Edited May 27, 2019 by TekWeis Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted May 27, 2019 Share Posted May 27, 2019 @TekWeis _IsPressed() is one of many way to do what you're trying to do; the thing is that you need to continuousely polling the state of a key pressed in the main loop, and this could cause the behaviour you were describing before. You could use GUISetAccelerators(), which associate a specific key to a ControlID in your GUI. There are many ways to accomplish the task you're trying to manage; tell us as much as you can so we can (at least try) to help you Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
TekWeis Posted May 27, 2019 Author Share Posted May 27, 2019 I wasn't aware of GUISetAccelerators(). Interesting reading. I'll take a look at this as it seems promising. I'll let you know how it goes. Thanks for bringing that to my attention. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted May 27, 2019 Share Posted May 27, 2019 (edited) @TekWeis Happy to have helped! Post what you got if you need further assistance Edited May 27, 2019 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
TekWeis Posted May 27, 2019 Author Share Posted May 27, 2019 @FrancescoDiMuro After studying GUISetAccelerators(), my utility is functioning much better. Also, when I do have a mouse connected, I get the best of both worlds now. The lagging I was experiencing before is gone. Took me a few minutes to understand the array, but this is definitely an improvement to what I started with. Thank you! Xandy and FrancescoDiMuro 2 Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted May 28, 2019 Share Posted May 28, 2019 @TekWeis Happy to have helped Xandy 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette 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