computergroove Posted May 28, 2008 Posted May 28, 2008 This program requires an ini file named barcode.ini and the ini file looks like: [AviCodes] 12345=avi1.avi 123456=movie1.wmv My script so far: expandcollapse popup#include <GUIConstants.au3> Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") $Form1 = GUICreate("Scan Barcode", 150, 22, 1, 1); creats a GUI window (Width, Height, Left, Top,) $edit_field = GUICtrlCreateInput("", 0, 0, 148, 21); ( "text", left, top , width , height) GUISetState(@SW_SHOW); shows the GUI window? Found reference to @SW_HIDE Func Start_Script() Local $user_input; is this necessary and formatted correctly? While 1 WinActivate("Barcode.exe") $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $edit_field $user_input = GUICtrlRead($edit_field); does this set $user_input to the user defined value or the other way around? If IniRead("barcode.ini", "AviCodes", $user_input, "no entry") = "no entry" Then MsgBox(16, "Code not found", "The code you entered "&$user_input&" was not found in the database",3) Else ShellExecute(@ScriptDir & "\" & IniRead("barcode.ini", "AviCodes", $user_input, "no entry")) Sleep (2000); wait for the movie to start playing Send ("{ALTDOWN}") Send ("{ENTER}") Send ("{ALTUP}"); maximizes the windows media player window after the movie starts to play Exit EndIf EndSwitch WEnd EndFunc Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc When the program starts, I get a user input window and I can enter a number and hit enter but nothing happens. I want the program to either tell me that the code I entered was not found or I want the computer to start playing the avi file attached to the code in the ini file. Help! Another issue I am having is that after I enter a code and hit enter I want the information in the text box to disappear so I can enter another code without having to hit backspace or anything else. What is happening now is if I type '12345' in the user input box and hit enter, the text box highlights just '2345' and when i begin to enter a new number the 1 stays there. 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
someone Posted May 28, 2008 Posted May 28, 2008 (edited) I changed around a little in the code but it should be working for you. Putting in a code and pressing enter does work correctly for me... are you sure that barcode.ini exsists in the same location as the script? Here is the code, expandcollapse popup#include <GUIConstants.au3> Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") $Form1 = GUICreate("Scan Barcode", 150, 22, 1, 1); creats a GUI window (Width, Height, Left, Top,) $edit_field = GUICtrlCreateInput("", 0, 0, 148, 21); ( "text", left, top , width , height) GUISetState(); @SW_SHOW is the default ;Func Start_Script() ;Local $user_input; is this necessary and formatted correctly?;depends on how your final script will look - read in the help file While 1 ;WinActivate("Barcode.exe") $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $edit_field $user_input = GUICtrlRead($edit_field); sets $user_input to whatever was typed in the edit box If IniRead("barcode.ini", "AviCodes", $user_input, "no entry") = "no entry" Then MsgBox(16, "Code not found", "The code you entered "&$user_input&" was not found in the database",3) GUICtrlSetData($edit_field, "");erases not successful input Else ShellExecute(@ScriptDir & "\" & IniRead("barcode.ini", "AviCodes", $user_input, "no entry")) ;~ Sleep (2000); wait for the movie to start playing ;~ Send ("{ALTDOWN}") ;~ Send ("{ENTER}") ;~ Send ("{ALTUP}"); maximizes the windows media player window after the movie starts to play Exit EndIf EndSwitch WEnd ;EndFunc Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc Let us know if you have questions EDIT: not so clear.... Edited May 28, 2008 by someone While ProcessExists('Andrews bad day.exe') BlockInput(1) SoundPlay('Music.wav') SoundSetWaveVolume('Louder') WEnd
computergroove Posted May 28, 2008 Author Posted May 28, 2008 #include <GUIConstants.au3> Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") $Form1 = GUICreate("Scan Barcode", 150, 22, 1, 1); creats a GUI window (Width, Height, Left, Top,) $edit_field = GUICtrlCreateInput("", 0, 0, 148, 21); ( "text", left, top , width , height) GUISetState(); @SW_SHOW is the default ;Func Start_Script() ;Local $user_input; is this necessary and formatted correctly?;depends on how your final script will look - read in the help file While 1 WinActivate("Barcode.exe") $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE I modified the above code to: Func Start_Script() ; Local $user_input WinActivate("Barcode.exe") MsgBox(4096, "Window Activated", 1) While 1 MsgBox(4096, "event1", 1) $user_input = GUIGetMsg($edit_field) and I am not getting a msgbox "window activated". I do not know how to initiate the start_script function if my program isnt moving past "create gui window". Help! 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
someone Posted May 28, 2008 Posted May 28, 2008 You know that when you encase something in a func/endfunc it doesn't execute automatically right? For instance if you really want to have your code as a function, you have to add Start_Script() where you want the function to execute. But I'm not sure you actually want one. While ProcessExists('Andrews bad day.exe') BlockInput(1) SoundPlay('Music.wav') SoundSetWaveVolume('Louder') WEnd
computergroove Posted May 28, 2008 Author Posted May 28, 2008 I needed to change "Winactivate("Barcode.exe")" to "WinActivate("Scan Barcode")" and then everything worked. Thank You 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
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