BryonR Posted August 22, 2008 Share Posted August 22, 2008 I'm using a barcode scanner that will scan a numnber then do a line feed. Once that line feed is done I want it to click ok on the Autoit GUI. Should be simple, its just a friday. Case $Msg = $OK or @CRLF Link to comment Share on other sites More sharing options...
enaiman Posted August 24, 2008 Share Posted August 24, 2008 Some code will definitely help here ... SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
BryonR Posted August 25, 2008 Author Share Posted August 25, 2008 Below is the full code that I have. expandcollapse popup#include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Portable Charge Program", 330, 209, 193, 125) $Label1 = GUICtrlCreateLabel("Scan Exam Barcode", 16, 56, 159, 22) GUICtrlSetFont(-1, 11, 800, 0, "Bookman Old Style") $mtbarcode = GUICtrlCreateInput("", 24, 80, 201, 21) $OK = GUICtrlCreateButton("OK", 16, 152, 113, 33, 0) $Exit = GUICtrlCreateButton("Exit", 184, 152, 97, 33, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $Msg = GUIGetMsg() Select Case $Msg = $GUI_EVENT_CLOSE Or $Msg = $Exit ExitLoop Case $Msg = $OK;or @CRLF If StringStripWS(GuiCtrlRead($mtbarcode), 8) = "" Then MsgBox(16, "Required", "Please fill out all fields or EXIT the program") ContinueLoop EndIf if fileexists("c:\temp") then fileinstall("I:\speedtest\connect.ini", "c:\temp\connect.ini", 1) Else DirCreate("c:\temp") fileinstall("I:\speedtest\connect.ini", "c:\temp\connect.ini", 1) EndIf ; ************Database write***************** $reqnumber = GUICtrlRead($mtbarcode) $t = (@hour & ":" & @min) $d = (@mon & "/" & @mday & "/" & @year & " ") $file = FileOpen("c:\temp\connect.vbs", 2) $db = IniRead("c:\temp\connect.ini", "Examnumber", "Full Database Path", "") $table = IniRead("c:\temp\connect.ini", "Examnumber", "Table Name", "") FileWriteLine($file, 'Dim adoCon, rsAddInfo, strSQL') FileWriteLine($file, 'Set adoCon = CreateObject("ADODB.Connection")') FileWriteLine($file, 'adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=' & $db & '"') FileWriteLine($file, 'Set rsAddInfo = CreateObject("ADODB.Recordset")') FileWriteLine($file, 'strSQL = "SELECT * FROM ' & $table & ';"') FileWriteLine($file, 'rsAddInfo.CursorType = 2') FileWriteLine($file, 'rsAddInfo.LockType = 3') FileWriteLine($file, 'rsAddInfo.Open strSQL, adoCon') FileWriteLine($file, 'rsAddInfo.AddNew') FileWriteLine($file, 'rsAddInfo.Fields("examnum") = ' & '"' & $reqnumber & '"') FileWriteLine($file, 'rsAddInfo.Fields("datetime") = ' & '"' & $d & $t & '"') FileWriteLine($file, 'rsAddInfo.Update') FileWriteLine($file, 'rsAddInfo.Close') FileWriteLine($file, 'Set rsAddInfo = Nothing') FileWriteLine($file, 'Set adoCon = Nothing') FileWriteLine($file, 'Set strSQL = Nothing') ; Close our .vbs file FileClose($file) ; Call Wscript.exe to run the .vbs file RunWait("Wscript.exe " & '"' & "c:\temp\connect.vbs" & '"') ; ***********Datebase compelete wite************ ; Delete our .vbs file when done FileDelete("c:\temp\connect.vbs") FileDelete("c:\temp\connect.ini") guictrlsetdata($mtbarcode,"") Send("{tab}{tab}") ContinueLoop ExitLoop EndSelect WEnd GUIDelete() Exit Thanks! Bryon Link to comment Share on other sites More sharing options...
youknowwho4eva Posted August 25, 2008 Share Posted August 25, 2008 So what's it not doing that you want it to do, I think "if fileexists("c:\temp") then" should be "if DirGetSize("c:\temp") = -1 then". And I don't see where $mtbarcode is defined. Giggity Link to comment Share on other sites More sharing options...
BryonR Posted August 25, 2008 Author Share Posted August 25, 2008 When a barcode is scanned with a scanner it does a line feed after each scan. What i'm looking for is once it does that line feed is to click OK. -Bryon Link to comment Share on other sites More sharing options...
enaiman Posted August 25, 2008 Share Posted August 25, 2008 Some info is missing here; I don't see how your barcode ends up on that inputbox. Is your scanner software sending it directly to that control? What I can think of is: you need to continuously monitor your inputbox content, once a line feed is detected there it can start the function associated with "OK" button and clear the inputbox content once the data is processed. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
BrettF Posted August 26, 2008 Share Posted August 26, 2008 GUICtrlSetState ( controlID, $GUI_DEFBUTTON) Maybe? Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
youknowwho4eva Posted August 26, 2008 Share Posted August 26, 2008 Well that would make it so if he hit enter it would run right? If the barcodes are all the same length you could do a charcount and have it call the function when the charcount is met. If they are of different lengths, you could have it read the line every 5 seconds or so and if the line is the same after 5 seconds (and not "" of course), then it knows the code is in there, then have it call the function. If I'm understanding the issue that is. Giggity Link to comment Share on other sites More sharing options...
BrettF Posted August 27, 2008 Share Posted August 27, 2008 Maybe something like then? #include <GUIConstants.au3> $timestamp = TimerInit () #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Portable Charge Program", 330, 209, 193, 125) $Label1 = GUICtrlCreateLabel("Scan Exam Barcode", 16, 56, 159, 22) GUICtrlSetFont(-1, 11, 800, 0, "Bookman Old Style") $mtbarcode = GUICtrlCreateInput("", 24, 80, 201, 21) $OK = GUICtrlCreateButton("OK", 16, 152, 113, 33, 0) $Exit = GUICtrlCreateButton("Exit", 184, 152, 97, 33, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $Msg = GUIGetMsg() $buffer = TimerDiff ($timestamp) Select Case $Msg = $GUI_EVENT_CLOSE Or $Msg = $Exit ExitLoop Case $buffer >= 50 $timestamp = TimerInit () If StringInStr (GUICtrlRead ($mtbarcode), @CRLF) Then ;Do what you need to. EndIf EndSelect WEnd I think that the fact that it's a SINGLE line input may have a factor in it. See about experiment with a style to get a edit control looking like your input box. Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! 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