computergroove Posted May 21, 2014 Share Posted May 21, 2014 (edited) expandcollapse popup$timer = TimerInit() ;Returns a timestamp (in milliseconds) ;Global $iIdleTime = _TimerGetIdleTime();returns the time since the last keyboard or mouse activity (for the ramdom videos to start playing after inactivity) $Form1 = GUICreate("Video Player", 2000, 1800, -20, -200, $WS_EX_TOPMOST) $edit_field = GUICtrlCreateInput("", 25, 25, 0, 0); ( "text", left, top , width , height) GUISetState(@SW_SHOW) ;sets window to show even while not playing a file on program startup GUISetBkColor(0x000000) ; sets background on GUI window While 1 $msg = GUIGetMsg();listen to the GUI Window for a barcode to be scanned Switch $msg Case $GUI_EVENT_CLOSE FileClose(@ScriptDir & "\" & "Videos.ini") Exit Case $edit_field $user_input = GUICtrlRead($edit_field); sets $user_input to whatever was typed in the edit box $video_file = (@ScriptDir & "\Videos\" & IniRead("Videos.ini", "Videos", $user_input, "no entry")) If IniRead("Videos.ini", "Videos", $user_input, "no entry") = "no entry" Then;If a barcode is not found then send a message saying do MsgBox(262144, "Code not found", "The Barcode you entered " & $user_input & " does not have a video.", 2);Error message on screen for user that will close in 2 seconds WinActivate("Video Player") ; makes the scan barcode user input window the active window GUICtrlSetData($edit_field, "");erases data in the user input field ElseIf IniRead("Videos.ini", "Videos", $user_input, "no entry") <> "no entry" Then GUICtrlSetData($edit_field, "");erases input in gui window ProcessClose("mpc-hc64.exe") Sleep(100) Run(@ScriptDir & '\MPC-HC\mpc-hc64.exe /play /fullscreen /close "' & $video_file & '"') WinActivate("Video Player") --Here--> Else FileDelete("C:\BestOptionBeta\Videos\*.sfl");Removes ghost files from the Videos Folder - I think they are error logs from crashed MPC $aFileList = _FileListToArray(@ScriptDir & "\Videos", "*.mpg");reads all files from videos directory and places them into a numbered 1d array $arrNum = UBound($aFileList, 1);counts the total number of entrys in the array Const $iRandom = Random(1, $aFileList[0], 1);creates a random number between 1 and the counted number of array list items. $aFile[0] is the first entry in the array which is a count of all the items in the array $RandomVideo = ('"' & @ScriptDir & "\Videos\" & $aFileList[$iRandom] & '"');creates a random video file name with " around it $RandomCommandPath = (@ScriptDir & "\MPC-HC\mpc-hc64.exe /play /fullscreen /close " & $RandomVideo);plays random file from videos Run($RandomCommandPath) WinActivate("Video Player") WinWaitClose("[CLASS:MPC-HC64]", "", 4) EndIf EndSwitch WEnd My question is in the last section after Else. What I want, from the top, is the program to listen for a bar code and if a bar code is entered and is wrong, an error message shows up. If a bar code that is found is entered I want a video to play other wise I want a random video to play. While the video is playing I need to be able to scan a bar code and have the program immediately determine whether the bar code is good or not and act accordingly. Everything above the last Else works perfectly. A black window shows up and I can type a bar code into the program and a new video window opens and plays the file. If I type a bad bar code I get an error message and the video continues to play. I get all kinds of weird results with the random area of the program (at the bottom). Videos.ini expandcollapse popup[Videos] 83948100026=Annihilator.mpg 83948100263=Dragon Slayer.mpg 83948100079=Belond Belief.mpg 83948100279=Beyond Compare.mpg 83948100021=Big Bertha Two.mpg 83948100075=Breath Taker.mpg 83948100281=Chrysanthemum Hodge Podge.mpg 83948100282=Cielo LO Da Sogno.mpg 83948100082=Colorful Battle.mpg 83948100295=Diamonds in the Sky.mpg 83948100081=Double Decker.mpg 83948100263=Dragon Slayer.mpg 83948100072=Energetic Moment.mpg 83948100698=Forbidden Pleasure.mpg 83948100691=Four Times as Fun.mpg 83948100692=Glitters Galore.mpg 83948100268=head Head.mpg 83948100533=High Flier.mpg 83948100604=Its a Dilly.mpg 83948100238=Its a Winner.mpg 83948100296=Killer Spider.mpg 83948100080=Mind Blower.mpg 83948100240=morning star.mpg 83948100284=Night Blitz.mpg 83948100237=No Fear.mpg 83948100697=Not so Gentle.mpg 83948100073=Spine Tingler.mpg 83948100076=Super Collider 1.mpg 83948100029=Tails Crackles.mpg 83948100602=Tails of Color.mpg 83948100085=The Big One.mpg 83948100023=The Professional 1.mpg 83948100244=The Three Woes.mpg 83948100609=the Wrath to Come.mpg 83948100278=The Yeti.mpg 83948100251=This is it .mpg 83948100239=Top This.mpg 83948100693=Total Sub.mpg 83948100203=Touch Down.mpg 83948100260=Tribulation Force.mpg 83948100254=Triple Crown.mpg 83948100259=Vial of Wrath.mpg 83948100078=Weapons.mpg 83948100241=What a Hit.mpg 83948100243=Home Run.mpg 83948100603=Patriotic Machine Gun.mpg 83948100270=225 Super Saturn.mpg 83948100247=Warning- May Cause Heart problems.wmv 8052531307518=(1)_1st and 10.mpeg 01011110001=9 shot no 2.mpg 87242109236=Apocalypse.mpeg 66666102872=Asteroid Hunter.mpeg 8145270145319=25 shot Festival Ball.mpg 8052531312611=Bada Bing.mpg 66666010104=Black Knight.mpg 70897275102=Coconut Tree.mpeg 70897240601=Crashing Rainbow.mpg 82010110002=Dark Knight.mpeg 82010110007=Demons Eyes.mpeg 80525302907=Fist Pump.mpg 8052531514718=Gorilla Warfare.mpeg 82009100003=Hot and Spicy.mpeg 88880000065=Imagination.mpeg 8145270144510=Live Wire.mpg 66666102848=Midlife Crisis.mpeg 80525363246=Motor Mouth.mpg 80525315160=poison.mpg 82010110008=Swarm.mpeg 8052531328315=That is your Problem.mpg 85186601208=The Good Stuff.mpeg 81145101097=Walk on the Wild Side.mpeg 8145270151112=War Hawk.mpeg 8145270155318=Weapons of Choice.mpeg 01011110003=9 shot no 3.mpg 01011110004=9 shot no 4.mpg 85186601698=10 Million Fire Flies.mpg 8052531326618=Boiling Point.mpg 66666107050=Boomerang.mpg 80525343138=Cycle.mpg 68014900941=Dominator Rocket.mpg 8052530016626=Double Ring Rocket.mpg 93948100002=Fiery Fantasia.mpg 93948100012=Firing Squad.mpg 93948100001=Goblin Perform.mpg 82009100024=Mack Ten.mpg 80525313087=One Bad Mother.mpg 82009100015=Pound Rocket.mpg 83948100465=Red and White Display Candle.mpg 91219212828=Super Candle.mpg 93948100003=World Champion.mpg 8052531339014=Big Boss.mpg 66666102531=noshow/200 Proof.mpg 66666102545=noshow/Electric Storm.mpg I am using Media Player Classic. MPC-HC.com 64 bit edition. Edited May 21, 2014 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 Link to comment Share on other sites More sharing options...
Mobius Posted May 21, 2014 Share Posted May 21, 2014 (edited) Hi, I could be wrong on this but is there any reason why $iRandom is being declared as a const? Const $iRandom = Random(1, $aFileList[0], 1) Because doing so means that $iRandom will only be assigned the result of the Random function once. Try $iRandom = Random(1, $aFileList[0], 1) Ed: Someones padding their post count again. Edited May 21, 2014 by Mobius Link to comment Share on other sites More sharing options...
JohnOne Posted May 21, 2014 Share Posted May 21, 2014 How many times are you going to post this question, I've seen it answered many times. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
computergroove Posted May 21, 2014 Author Share Posted May 21, 2014 (edited) I have to keep trying until I get it right. Each one of my posts is a different question. One problem is that once a post has had a few replies, no one looks at it anymore and I have to post again. Again there is only one problem and I dont have the experience to figure it out. I have put 2 days into getting this to function properly and after I have exhausted what I know in order to figure it out I post. I make progress and I learn different things about autoit but it has it's quirks and I need help navigating them. Thanks for your patience. @mobius - I only added const because that was in the documentation of the array wiki and it worked when I tested it so I didn't change it. Edited May 21, 2014 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 Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted May 21, 2014 Moderators Share Posted May 21, 2014 One problem is that once a post has had a few replies, no one looks at it anymore and I have to post again. This is not why your threads are not getting responses, it is because you keep posting multiple times. If you have asked a question and still need help, and you've waited 24 hours, just bump your thread instead of starting a new one for the same question. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Bert Posted May 21, 2014 Share Posted May 21, 2014 This is not why your threads are not getting responses, it is because you keep posting multiple times. If you have asked a question and still need help, and you've waited 24 hours, just bump your thread instead of starting a new one for the same question. agreed The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
computergroove Posted May 21, 2014 Author Share Posted May 21, 2014 OK agreed. Now is there an post regarding my original problem? 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 Link to comment Share on other sites More sharing options...
computergroove Posted May 21, 2014 Author Share Posted May 21, 2014 While 1 $msg = GUIGetMsg();listens for user input (bar code) Switch $msg Case $edit_field $user_input = GUICtrlRead($edit_field); sets $user_input to whatever was typed in the edit box $video_file = (@ScriptDir & "\Videos\" & IniRead("Videos.ini", "Videos", $user_input, "no entry")) If IniRead("Videos.ini", "Videos", $user_input, "no entry") = "no entry" Then;If a barcode is not found then send a message saying do MsgBox(262144, "Code not found", "The Barcode you entered " & $user_input & " does not have a video.", 2);Error message on screen for user that will close in 2 seconds WinActivate("Video Player") ; makes the scan barcode user input window the active window GUICtrlSetData($edit_field, "");erases data in the user input field ElseIf 1 Then GUICtrlSetData($edit_field, "");erases input in gui window ProcessClose("mpc-hc64.exe") Sleep(100) Run(@ScriptDir & '\MPC-HC\mpc-hc64.exe /play /fullscreen /close "' & $video_file & '"') WinActivate("Video Player") Else MsgBox(0, "13", "test") EndIf EndSwitch WEnd Im trying to figure out the If ElseIf Else logic so I am trying to send a msgbox to the screen after the last else. When I run the program a msgbox should appear immediately and it doesn't. Can anyone tell me why? 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 Link to comment Share on other sites More sharing options...
sahsanu Posted May 21, 2014 Share Posted May 21, 2014 You won't reach the last Else... never because of ElseIf 1 Then That will be always True so your last Else has no sense in that code. Werty 1 Link to comment Share on other sites More sharing options...
computergroove Posted May 21, 2014 Author Share Posted May 21, 2014 (edited) While 1 $msg = GUIGetMsg();listens for user input (bar code) Switch $msg Case $edit_field $user_input = GUICtrlRead($edit_field); sets $user_input to whatever was typed in the edit box $video_file = (@ScriptDir & "\Videos\" & IniRead("Videos.ini", "Videos", $user_input, "no entry")) If IniRead("Videos.ini", "Videos", $user_input, "no entry") = "no entry" Then;If a barcode is not found then send a message saying do MsgBox(262144, "Code not found", "The Barcode you entered " & $user_input & " does not have a video.", 2);Error message on screen for user that will close in 2 seconds WinActivate("Video Player") ; makes the scan barcode user input window the active window GUICtrlSetData($edit_field, "");erases data in the user input field ElseIf 1 Then MsgBox(0,"second","second case") Else GUICtrlSetData($edit_field, "");erases input in gui window ProcessClose("mpc-hc64.exe") Sleep(100) Run(@ScriptDir & '\MPC-HC\mpc-hc64.exe /play /fullscreen /close "' & $video_file & '"') WinActivate("Video Player") EndIf EndSwitch WEnd This doesnt display a msgbox either. but if I enter a wrong code I get the error message. Edited May 21, 2014 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 Link to comment Share on other sites More sharing options...
BrewManNH Posted May 21, 2014 Share Posted May 21, 2014 ElseIf 1 is ALWAYS going to be true so it will ALWAYS execute the second msgbox code if the first one fails. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
computergroove Posted May 21, 2014 Author Share Posted May 21, 2014 OK I seem to only have a couple of choices here. I can get the script to msgbox an error if a code is not found. I can also play a video if the code is found. I need one final element - I want the random videos to play on the script start up and if I scan something right I want the program to stop the video playing and begin playing the new video. If a bad scan is read then I want the program to display an error message. The problem seems to be in the if logic. How can I add a if/elseif/else to: Listen to the GUICtrlRead 1. If a bad scan is received then display msgbox saying so 2. If a good scan is received then stop whatever video is playing and play the video the scan is linked to 3. If nothing is scanned and the last video has stopped playing, begin playing a random video, If a scan is entered then either stop the random video and start playing the scanned video and if there is a bad scan then display an error and continue playing the current video. 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 Link to comment Share on other sites More sharing options...
BrewManNH Posted May 21, 2014 Share Posted May 21, 2014 This rewrite will handle 1 and 2, #3 I don't know how the software works so I guess you'll have to figure that out. While 1 $msg = GUIGetMsg();listens for user input (bar code) Switch $msg Case $edit_field $user_input = GUICtrlRead($edit_field); sets $user_input to whatever was typed in the edit box $video_file = IniRead("Videos.ini", "Videos", $user_input, "no entry") If $video_file = "no entry" Then;If a barcode is not found then send a message saying do MsgBox(262144, "Code not found", "The Barcode you entered " & $user_input & " does not have a video.", 2);Error message on screen for user that will close in 2 seconds WinActivate("Video Player") ; makes the scan barcode user input window the active window GUICtrlSetData($edit_field, "");erases data in the user input field Else $video_file = @ScriptDir & "\Videos\" & $video_file GUICtrlSetData($edit_field, "");erases input in gui window ProcessClose("mpc-hc64.exe") Sleep(100) Run(@ScriptDir & '\MPC-HC\mpc-hc64.exe /play /fullscreen /close "' & $video_file & '"') WinActivate("Video Player") EndIf EndSwitch WEnd If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
computergroove Posted May 21, 2014 Author Share Posted May 21, 2014 (edited) The following is what I wrote to randomize the videos being played back. It does have one problem which is that there is no mechanism that plays every video at least once before re-randomizing the list. @BrewManNH I have basically the same code and the problem is the same. I dont know how to have the random videos play in the main gui window so someone can watch the video and still scan a new barcode. I feel like I need to add the randomize code into the case loop in order to keep the characteristics the same as the other 2 main functions, displaying an error and playing a video. I can get the program to play random videos I just cant get them to play within the other gui window like the others where I can scan during playback. I keep looking at the code and I cannot get it. FileDelete(@ScriptDir & "\Videos\*.sfl");Removes ghost files from the Videos Folder - I think they are error logs from crashed MPC $aFileList = _FileListToArray(@ScriptDir & "\Videos", "*.mpg");reads all files from videos directory and places them into a numbered 1d array $arrNum = UBound($aFileList, 1);counts the total number of entrys in the array $iRandom = Random(1, $aFileList[0], 1);creates a random number between 1 and the counted number of array list items. $aFile[0] is the first entry in the array which is a count of all the items in the array $RandomVideo = ('"' & @ScriptDir & "\Videos\" & $aFileList[$iRandom] & '"');creates a random video file name with " around it $RandomCommandPath = (@ScriptDir & "\MPC-HC\mpc-hc64.exe /play /fullscreen /close " & $RandomVideo);plays random file from videos GUICtrlSetData($edit_field, "");erases input in gui window ProcessClose("mpc-hc64.exe") Sleep(100) Run($RandomCommandPath) WinActivate("Video Player") WinWaitClose("[CLASS:MPC-HC64]", "", 4) Edited May 21, 2014 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 Link to comment Share on other sites More sharing options...
computergroove Posted May 24, 2014 Author Share Posted May 24, 2014 BUMP 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 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