Jump to content

There's not enough room in the title to describe what I need.


Recommended Posts

I have an ini file that looks like:

[AviCodes]

12345=ab.avi

123=avi.avi

123454234=good.avi

The user inputs one of the strings of numbers and the script plays the avi file. What I want is if no one inputs any data for 2 minutes then I want the program to start playing all the avi files randomly back to back until someone tries to enter a new number into the script. Each of the movies are different lengths of time. Is there a way to tell my script to wait for the wmplayerc.exe to end before it starts playing another avi file? Here is my existing code:

#include <GUIConstants.au3>
#include <string.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()

; temp.txt is a file that has the encrypted file string stored in it
; barcode.ini is a file that is used as a temp file for storing the data

If FileExists("barcode.ini") Then;deletes the temp file barcode.ini in case of a computer crash
   FileDelete("barcode.ini")
EndIf

Local $file
FileOpen("temp.txt", 0); calls the file temp.txt for reading later
; Check if file opened for writing OK
If $file = -1 Then
    MsgBox(0, "Error", "Cant find barcode.ini.")
    Exit
EndIf
$file = FileRead("temp.txt"); reads temp.txt and assigns the data to $file

    FileOpen("barcode.ini", 2);opens the file in write mode (it will create the file if it doesn't exist)
    $Decrypted_Data = _StringEncrypt (0 , $file, "1234"); decrypts the string "$file" - Tested
    FileWrite("barcode.ini", $Decrypted_Data); writes the data to barcode.ini
    FileClose("barcode.ini");closes the file

While 1 
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
        FileDelete("Barcode.ini")
        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 Barcode you entered "&$user_input&" does not have a video.",2)
                WinActivate("Scan Barcode")
                GUICtrlSetData($edit_field, "");erases not successful input
            Else
                $video_file = (@ScriptDir & "\" & IniRead("barcode.ini", "AviCodes", $user_input, "no entry"))
                Run (@ProgramFilesDir & "\K-Lite Codec Pack\Media Player Classic\mplayerc.exe " & Chr(34) & $video_file & Chr(34) & " -close")
                Sleep (5000)
                WinActivate("Scan Barcode")
                GUICtrlSetData($edit_field, "");erases not successful input
            EndIf
EndSwitch
WEnd

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

Link to comment
Share on other sites

This is the last one I believe. Everything else works now. Sorry for any inconvenience.

What part of this do you not know how to do?

Time the delay with TimerInit()/TimerDiff().

Read the section with IniReadSection.

Pick the order with Random().

Play the selection.

Put it in a loop.

...?

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Many replies within the first hour of the post. None after your remark about my posting methods. Guess you know why I separate my different issues. They seem to get answered.

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

Link to comment
Share on other sites

How do I get the program to recognize that a movie file has stopped playing so it finishes every movie and doesnt have any long pauses?

That depends on the player you are working with and how you interface with it. If you have a COM interface to whatever player it is, then there are probably .TimeRemaining or .TimeElapsed and .RunTime properties or some such. If you are working on the GUI then there will be other ways.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...