Jump to content
TekWeis

Scanning for keyboard selection

Recommended Posts

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.

    

While 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

Share this post


Link to post
Share on other sites

Don't use GUIGetMsg with _IsPressed, just check for the keypress directly. Something like this would work.

While 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 Gude
How 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

Share this post


Link to post
Share on other sites
Posted (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 by TekWeis

Share this post


Link to post
Share on other sites

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

 

 


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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.

eKitchenInstaller.jpg

qsrBumpBar.jpg

eKitKVS.jpg

Share this post


Link to post
Share on other sites

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


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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. 

Share this post


Link to post
Share on other sites
Posted (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.

 

CMCKit.png

Edited by TekWeis

Share this post


Link to post
Share on other sites

@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

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites

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.

 

Share this post


Link to post
Share on other sites
Posted (edited)

@TekWeis

Happy to have helped!

Post what you got if you need further assistance :)

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites

@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!

Share this post


Link to post
Share on other sites

@TekWeis

Happy to have helped :)


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...