Sign in to follow this  
Followers 0
Aiakonai

Handle keyboard Input in and Input Box

2 posts in this topic

Hello,

I am trying to create an input box that when a user types something like the character "." that it will prevent that character from entering the input box and display a message 

stating why the input was prevented. Something like what $ES_NUMBER style does for the input box, but for a floating point number. I can work out the logic of how to do that, but

I am not yet sure how to correctly capture keyboard input before it arrives IN the input box. This should only run on the particular input box in question as it is an aid to help clean 

up user input before it gets sent to a SQL query.

 

I was hoping for something like:

 

$msg = GUIGetMsg()
 
 Switch $msg
    Case $keyboardInput
       ; pre processing function called here

I have searched for something similar to this but I cannot seem to find one that does exactly what I am looking for. Any help is appreciated.

 

Thanks,

K


hmm... I wonder which key is the any key :O

Share this post


Link to post
Share on other sites



try this

 

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#Region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("Form1", 177, 82, 192, 124)
Global $Input1 = GUICtrlCreateInput("Input1", 16, 24, 121, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUIRegisterMsg(0x0111, "_WM_COMMAND")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func _WM_COMMAND($hWnd, $iMsg, $WParam, $LParam)
    #forceref $hWnd, $iMsg
    Local $iCode = BitShift($WParam, 16)
    Switch $hWnd
        Case $Form1
            Switch $LParam
                Case GUICtrlGetHandle($Input1)
                    Switch $iCode
                        Case $EN_CHANGE
                            $ri = GUICtrlRead($Input1)
                            If StringInStr($ri, ",") Then
                                GUICtrlSetData($Input1, StringReplace($ri, ",", ""))
                                ToolTip("illegal character!!!")
                            EndIf
                    EndSwitch
            EndSwitch
    EndSwitch
    Return 'GUI_RUNDEFMSG'
EndFunc   ;==>_WM_COMMAND

 

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
Sign in to follow this  
Followers 0

  • Similar Content

    • way1000
      By way1000
      i'm trying to create a program that let's the user type a word in an input field (gui) and when a button is pressed the letters of the word are replaced by 1 word each from a list of words in a text file
      i created the gui for it but i need help to add some more code to make it work like intented

      each letter of a word should be replaced by a word from a text file
      the text file is a source for replacing letters is a file with 2 columns separated by tab that contains the entire alphabet (26 rows)
       
      please help if possible
       
      i posted an example gui screenshot

    • myspacee
      By myspacee
      Hello,
      need help to remap '<' button and SHIFT+'<'
      I made a little editor that allows to my users to write using proprietary codes.
      In production we have 2 keys/symbols that i want to 'emulate'. So, when is press on my keyboard :
      < = « SHIFT+< = » Try to use help example _IsPressed :
       
      #include <Misc.au3> #include <MsgBoxConstants.au3> Local $hDLL = DllOpen("user32.dll") While 1 If _IsPressed("10", $hDLL) Then ConsoleWrite("_IsPressed - Shift Key was pressed." & @CRLF) ; Wait until key is released. While _IsPressed("10", $hDLL) Sleep(250) WEnd ConsoleWrite("_IsPressed - Shift Key was released." & @CRLF) ElseIf _IsPressed("1B", $hDLL) Then MsgBox($MB_SYSTEMMODAL, "_IsPressed", "Close the application.") ExitLoop EndIf Sleep(250) WEnd DllClose($hDLL) but how manage keys combination ?
      thank you for any help,
      m.
    • nacerbaaziz
      By nacerbaaziz
      hello
      Greetings to all
      dears i have a big problem in the bass.dll
      e.g
      If you play an audio file using the bass.dll
      and  You changed the audio output
      Such as setting or removing headphones
      The sound output of bass.dll does not change
      Is there any solution
      If it exists, please give it to me
      Greetings and thanks in advance
      I apologize for my bad English
    • zetaimmersion
      By zetaimmersion
      I have 2 items (a field box and a bypass checkbox). every time the box is checked i need the field to become writable. unchecked is read only displaying some text.
      this is as far as i got as I am stuck at making it read/write toggle
      #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("Test", 500, 500) Global $hCombo = GUICtrlCreateInput("", 10, 10, 200, 20, BitOR($ES_AUTOHSCROLL,$ES_READONLY)) GUICtrlSetBkColor($hCombo,0xe7e5e5) Global $cbox = GUICtrlCreateCheckbox ("", 40,50,10,20) GUICtrlSetState($cbox, $GUI_Unchecked) GUISetState() Global $sCurrCombo = "" While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cbox If GUICtrlRead($cbox) <> $sCurrCombo Then $sCurrCombo = GUICtrlRead($cbox) GUICtrlSetStyle ($hCombo, $SS_LEFTNOWORDWRAP) GUICtrlSetBkColor($hCombo,0xFFFFFF) MsgBox(0, "Choice", "PLease enter the text") EndIf EndSwitch WEnd  
    • Tarakesh
      By Tarakesh
      Hi,
      First of all I would like say infinite thanks to the team involved in designing this great tool.
      Here is my problem
      1. Press windows button
      2. ESC
      3. TAB
      4. It will take me to the first pinned icon in the taskbar
      5. If I I do SHIFT F10 which usually opens context menu like  right click of the mouse.
      6. For one of the application I am using it does not support  Shift + F10 context menu rather it listens to only mouse right click event.
      7. I do a search in a tree view of my application and the search item is selected or focused
      8. For eg

           User1

           User2
           User3
      Now if I search for User1 the tab or focus move to User 1 (Red)
           User1

           User2
           User3
      If I search for User3 the tab or focus moves to User 3
      Now my question is how can I move the mouse automatically go to the focused item on the window. Such that during automation I can issue MoveClick("{RIGHT}") as {SHIFT F10} is not working from the keyboard. It is a java app, unfortunately it is not honoring the right click events from keyboard to open the context

      WinMinimizeAll();
      Send("^{ESC}")
      Sleep(200)
      Send("{ESC}")
      Send("{TAB}")

      the above scripts take the tab to the first pinned icon in the taskbar. Now i want
      MouseMove( "move to tab" selection")

      Regards,
      Tarakesh