Jump to content
Sign in to follow this  
computergroove

$GUGetMsg() only getting 1 number in a string Help

Recommended Posts

computergroove

I get an output message from the code below but it doesn't read the input in its entirety. For instance I type in 123 and the msgbox states just the 3. Heres the working code.

Func Get_user_input()
    $msg = 0
    While $msg <> $GUI_EVENT_CLOSE
        $user_input = GUIGetMsg()
        Select
            Case $user_input > 0
                MsgBox(0, $user_input, $user_input)
                ExitLoop
        EndSelect
    WEnd
EndFunc

Also when I click ok on the window that says 3 the window closes and the script terminates. I need it to stay up so I can enter another number.


Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Share this post


Link to post
Share on other sites
Valuater

Show the entire code...please

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
computergroove

#include <GUIConstants.au3>
Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
Global $user_input

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("AForm1", 400, 229, 193, 115); creats a GUI window (Width, Height, Left, Top,)
$edit_field = GUICtrlCreateInput("", 40, 52, 245, 21); creats a blank textbox in the GUI window 
$btn_test = GUICtrlCreateButton("Submit", 308, 52, 75, 21, 0); creates a button labeled Submit in the GUI window
GUISetState(@SW_SHOW); shows the GUI window? Found reference to @SW_HIDE
#EndRegion ### START Koda GUI section ### Form=

; ################################### Check for Database.txt###########################

Func Start_Script()
Local $f_in = @ScriptDir & "\database.txt"; search for and scan database.txt for validity
        $fh_in = FileOpen($f_in, 0) 
        If $fh_in = -1 Then; Check if file opened for reading OK
            MsgBox(0, "Error 1", "Can't find database.txt.") 
            exit;
        EndIf 
EndFunc
; ################################### End Check for database.txt #########################

; ################################### Get User Input #################################
Func Get_user_input()
    $msg = 0
    While $msg <> $GUI_EVENT_CLOSE
        $user_input = GUIGetMsg()
        If $user_input > 0 Then
            MsgBox(0, $user_input, $user_input)
        EndIf
    WEnd
EndFunc
; ################################## End Get User Input ###############################

Func Compare_Barcode()
Local $fh_in
While 1
$line = FileReadLine($fh_in)
    If @error = -1 Then 
    MsgBox(4096, "Error 2", "Error reading database file.")
    ExitLoop

ElseIf StringInStr($line, ";") = $user_input Then 
    MsgBox(4096, "Search result:", $line)
    Exit

    EndIf
WEnd
EndFunc

FileClose($fh_in)
call(Start_Script)

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

Edited by computergroove

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Share this post


Link to post
Share on other sites
computergroove

Ok I got it to not exit after showing the msg box with the user input in it but I still need the entire user input to be 1 value no matter how long. How do I do that?


Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Share this post


Link to post
Share on other sites
GEOSoft

I agree with Valuater that more code is needed but Im going to take a wild guess that what you are trying to do is read an input control.

While 1
   $Msg = GUIGetMsg();; Don't know why you need to have it in a function but that's your choice.
   While GUICtrlRead($myInput) <> ""
      $User_Input = GUICtrlRead($myInput)
      If $Msg = $GUI_EVENT_CLOSE Then ExitLoop(2)
   Wend
   If $Msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.