Bookman Posted October 27, 2005 Share Posted October 27, 2005 I am trying to use a scanner (barcode and credit card) with a database app. for order entry. With much appreciated help from other users at this forum, I have the following code that works...sort of. Global Const $DB='FileMaker Pro Advanced - [Price_List]' HotkeySet("{F6}", 'Search') HotkeySet("{F9}", 'Card') WinWait ($DB) WinWaitClose($DB) Func Search() Local $Input = InputBox('Scanning', 'Incoming data:') If @Error Then Return WinActivate($DB) Send("^s") Sleep(300) Send($Input, 1) Send("{ENTER}", 0) EndFunc Func Card() WinActivate($DB) Send("^h") EndFunc I still have two problems. 1. The script is not triggered by input from the scanners (USB Keyboard type output) The scanners are set with preambles of the F6 and F9 keys, but that does not trigger the scripts. Pressing the keys does. 2. After a short period of time (maybe 10 minutes, 15 scans or triggers) the DB program and the entire computer become unstable. Programmed functions don't work. Keyboard output is garbled, Mouse Clicks have unintended results. The only remedy is to close all programs and reboot. Then everything works fine again...for a while. Any Ideas? Link to comment Share on other sites More sharing options...
Valuater Posted October 27, 2005 Share Posted October 27, 2005 (edited) to start with cleaning up the crashing effect 1 i would suggest you change the f-keys to something different than the scanner f-keys 2 tried to clean-up the code a little Dim $DB='FileMaker Pro Advanced - [Price_List]' HotkeySet("{F6}", 'Search') HotkeySet("{F9}", 'Card') ;Run("C:\ProgramDB.exe").... maybe? WinWait ($DB) Sleep(1000) While 1 If Not WinExists($DB) Then Exit EndIf Sleep(50) WEnd Func Search() Local $Input = InputBox('Scanning', 'Incoming data:') If @Error Then Return WinActivate($DB) Send("^s") Sleep(300) Send(GUICtrlRead($Input), 1) Send("{ENTER}") EndFunc Func Card() WinActivate($DB) Send("^h") EndFunc 8) Edited October 27, 2005 by Valuater Link to comment Share on other sites More sharing options...
Bookman Posted October 27, 2005 Author Share Posted October 27, 2005 Thanks, I'll try it. I'll also try switching hte F keys for brackets or something. Link to comment Share on other sites More sharing options...
Valuater Posted October 27, 2005 Share Posted October 27, 2005 i used _is_Pressed() to replace the f-keys here... give it a try expandcollapse popup#include <Misc.au3> Dim $DB='FileMaker Pro Advanced - [Price_List]' ;Run("C:\ProgramDB.exe").... maybe? WinWait ($DB) Sleep(1000) While 1 ; same as F6 If _IsPressed("75") Then Search() EndIf ; same as F9 If _IsPressed("78") Then Card() EndIf If Not WinExists($DB) Then Exit EndIf Sleep(50) WEnd Func Search() Local $Input = InputBox('Scanning', 'Incoming data:') If @Error Then Return WinActivate($DB) Send("^s") Sleep(300) Send(GUICtrlRead($Input), 1) Send("{ENTER}") EndFunc Func Card() WinActivate($DB) Send("^h") EndFunc 8) Link to comment Share on other sites More sharing options...
Bookman Posted October 31, 2005 Author Share Posted October 31, 2005 I tried to run this script, but the IsPressed command is not recognized. I cannot find it in the Auto-IT v3 help file either. Is this perhaps a command from an older version of Auto-It? Link to comment Share on other sites More sharing options...
Valuater Posted October 31, 2005 Share Posted October 31, 2005 beta... its in the Developers section herehttp://www.autoitscript.com/forum/index.php?showtopic=10256#8) Link to comment Share on other sites More sharing options...
LxP Posted October 31, 2005 Share Posted October 31, 2005 When you have a copy of the beta version installed, I would suggest giving your original code a try again because there's nothing in it that should be causing the behaviour that you describe. Link to comment Share on other sites More sharing options...
Bookman Posted November 1, 2005 Author Share Posted November 1, 2005 When you have a copy of the beta version installed, I would suggest giving your original code a try again because there's nothing in it that should be causing the behaviour that you describe.I tried both with the beta version, and the newest one (using _IsPressed) will not load. Reporting a probelm with Misc.au3. Everything was fine using the older script (with Hot Keys, then towards the end of the session it went haywire again. When it goes, even my DB app starts acting funny. None of the commands work as they should. Re-booting solves the problem, and nothing is permanently scrambled, though Link to comment Share on other sites More sharing options...
LxP Posted November 1, 2005 Share Posted November 1, 2005 Have you tried rebooting the computer with only the software required to get the job done loaded (probably just scanner driver, database software, AutoIt script)?Have you tried operating the computer without using the scanner? Try manually pressing the hotkeys and acting the part of the scanner to the AutoIt script. Do things go erratic after a while if you do this?In my opinion the only script commands that could possibly be causing trouble (from the original script) are Send() and HotkeySet(). Try adding the following lines to the top of the script, which will slow down key sending:Opt('SendKeyDownDelay', 50) Opt('SendKeyDelay', 50)and you might want to try changing the hotkeys again.I think that perhaps you haven't officially installed AutoIt -- if you want to try Valuater's rendition again, try placing Misc.au3 in the same folder as your script and change the #Include line to use double quotes instead of angled brackets:#Include "Misc.au3" Link to comment Share on other sites More sharing options...
jefhal Posted November 1, 2005 Share Posted November 1, 2005 (edited) WinActivate($DB) sleep(3000) Send("^s") I would put a sleep (or a winwait/winwaitactive) in between these two lines to give the DB time to actually activate before you send the ^s. Otherwise you're sending ^s into the Windows interface, wherever it happens to be. Just a thought! If that works, try smaller and smaller values for sleep until you have it just right, or just use winwait/winwaitactive... Edited November 1, 2005 by jefhal ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format Link to comment Share on other sites More sharing options...
LxP Posted November 1, 2005 Share Posted November 1, 2005 That's a good idea. Here's another way of achieving this: WinActivate($DB) WinWaitActive($DB) Send('^s') It's not equivalent but for most software (all that I have ever used it with) it does the right thing. Link to comment Share on other sites More sharing options...
Bookman Posted November 1, 2005 Author Share Posted November 1, 2005 The only things running are the DB and AutoIt. The scanners are keyboard output(USB) so the driver is native in Windows. I've only been using the key presses, because I haven't been able to get the script to recognize the scanner sending the F-keys. I'll try the suggestions and let you know. Link to comment Share on other sites More sharing options...
Bookman Posted November 1, 2005 Author Share Posted November 1, 2005 Have you tried rebooting the computer with only the software required to get the job done loaded (probably just scanner driver, database software, AutoIt script)?Have you tried operating the computer without using the scanner? Try manually pressing the hotkeys and acting the part of the scanner to the AutoIt script. Do things go erratic after a while if you do this?In my opinion the only script commands that could possibly be causing trouble (from the original script) are Send() and HotkeySet(). Try adding the following lines to the top of the script, which will slow down key sending:Opt('SendKeyDownDelay', 50) Opt('SendKeyDelay', 50)and you might want to try changing the hotkeys again.I think that perhaps you haven't officially installed AutoIt -- if you want to try Valuater's rendition again, try placing Misc.au3 in the same folder as your script and change the #Include line to use double quotes instead of angled brackets:#Include "Misc.au3"I tried the above and got hte following error:Line 64Local $p=DllStructCreate ($struct)Local $p=^ErrorError: Unknown function nameI'll try it without the Misc.au3 now. Link to comment Share on other sites More sharing options...
LxP Posted November 1, 2005 Share Posted November 1, 2005 The problem is that you are running the script using the release version of AutoIt. Try getting the beta and running the script with that -- ironically it's far more stable than the release version anyway. Link to comment Share on other sites More sharing options...
Bookman Posted November 2, 2005 Author Share Posted November 2, 2005 The problem is that you are running the script using the release version of AutoIt. Try getting the beta and running the script with that -- ironically it's far more stable than the release version anyway.Will this transfer when compiled into an exe file for other computers? Also, I've put together a script that changes printers in the DB I have. Can these few lines be added to this script and still work? It waits for a Print Setup window, then sends 1 parameter and a return key.Greg Link to comment Share on other sites More sharing options...
LxP Posted November 2, 2005 Share Posted November 2, 2005 Will this transfer when compiled into an exe file for other computers?If you compile your script using the copy of Aut2EXE supplied with a beta distribution then that will be fine.Can these few lines be added to this script and still work? It waits for a Print Setup window, then sends 1 parameter and a return key.This is definitely possible although it would require a small amount of modification to both pieces of code. Please feel free to post the new lines and I'll throw it into the original code. Link to comment Share on other sites More sharing options...
Bookman Posted November 2, 2005 Author Share Posted November 2, 2005 (edited) Thanks for your help. I've attached a zip file with both scripts. One is the scanning scripts, the other changes printers via Print Setup window. I still can't get hte _IsPressed to be recognized. I'm running the beta (I toggled it twice to make sure) and I still get an Unrecognized Command failure notice. I'm currently using the HotKeySet commands to use the hot keys and testing for stability when compiled with the beta version.Scripts.zip Edited November 3, 2005 by Bookman Link to comment Share on other sites More sharing options...
LxP Posted November 3, 2005 Share Posted November 3, 2005 I've assumed that you will want the script to process the Print Setup window whenever it appears, even if it appears more than once during the life of the script. I hope that's okay. You can always right-click the tray icon and Pause Script if you ever need to access the dialogue manually.I took out the _IsPressed() calls because they don't seem to be the problem and also they would be less likely to 'see' the buttons being pressed by the scanner.expandcollapse popup; Title of main program Global $DB = 'FileMaker Pro Advanced - [Price_List]' ; Title of Print Setup window Global $PS = 'Print Setup' ; Hook hotkeys HotkeySet('{F6}', 'Search') HotkeySet('{F9}', 'Card') ; Loop indefinitely ; Script can be closed using the tray menu While True If WinExists($PS) Then WinActivate($PS) WinWaitActive($PS) Send($CmdLine[1] & '{ENTER}') WinWaitClose($PS) EndIf ; Briefly pause to avoid intensive CPU usage ; Script will still process hotkeys Sleep(250) WEnd Func Search() Local $Input = InputBox('Scanning', 'Incoming data:') If @Error Then Return WinActivate($DB) WinWaitActive($DB) Send('^s') Sleep(300) Send($Input, True) Send('{ENTER}') EndFunc Func Card() WinActivate($DB) WinWaitActive($DB) Send('^h') EndFunc Link to comment Share on other sites More sharing options...
Bookman Posted November 3, 2005 Author Share Posted November 3, 2005 That is a correct assumption. The Print Setup Window will probably be accessed many times during the operation fo the DB. I have used this to automate this function for the users so they don't choose the wrong printer. I have never been able to get the _IsPressed function to work, the loading is always interrupted with a "Unrecognized" window on loading. The Hot Keys work fine though. I'll be doing som actual testing over the next few days, I'll let you know how it comes out. Thanks again for all of your help. Link to comment Share on other sites More sharing options...
Bookman Posted November 9, 2005 Author Share Posted November 9, 2005 I've been working with the scripts and everything is working fine. The Hot Keys work perfectly. I now have discovered a new dilemma. I have two scripts that work separately, but can they be combined? The first waits for the Print Setup Screen and sends a change CmdLine. The second waits for the Print window and changes three settings. I've combined them as follows, will this work? Each part will only be used occasionally, so the script can exit between uses. WinWaitActive("Print Setup") Send ($CmdLine[1]) Sleep(50) Send ("{ENTER}") Exit ;This script requires three paramaters ;Parameter one determines all ®ecords or ©urrent WinWaitActive("Print") Send("!r") If $CmdLine[1] = "R" Then Send ("{HOME}") ElseIf $CmdLine[1] = "C" Then Send ("{HOME}") Send("{DOWN}") EndIf Send ("{TAB}") ;the next parameter must be sufficient determine the printer to be used(usually 1 character) Send ($CmdLine[2]) Send ("!A") ;The final parameter is the number of copies Send("!c") Send ($CmdLine[3]) Send ("{ENTER}") Exit 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