Jump to content
Sign in to follow this  

Media player in full screen until I make my userinput window active

Recommended Posts


I have made a script that does 2 things:

1. When I start the program it brings up a window that asks for a user input. When the user enters some input (scans a barcode in a hand scanner) the script identifies the movie associated with that barcode and plays it on the screen.

2. When the video is done playing the user input screen becomes the active screen again so a user can scan another barcode to play a video.

The customer has requested that after 20 seconds of inactivity the program start playing all the video files in random order. I have made a lot of progress on this. One of the problems I am having is that while the movie files are playing in random mode, I cannot make the user input field active without causing the video to exit full screen mode. I want the ability to accept user input at anytime and if a movie is playing I want the script to immediately start playing the new user video request. Here's my code so far:

#Region;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstants.au3>
#include <string.au3>
#Include <File.au3>
#Include <Array.au3>
Global $Paused
Global $file
Global $AviList = _FileListToArray(@ScriptDir,"*.wmv") 
Global $time = 10;sec
$timer = TimerInit()
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)

; 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(@ScriptDir & "\" & "barcode.ini") Then;deletes the temp file barcode.ini in case of a computer crash
   FileDelete(@ScriptDir & "\" & "barcode.ini")

FileOpen("temp.ini", 0); calls the file temp.txt for reading later
; Check if file opened for writing OK
If $file = -1 Then
    MsgBox(0, "Error 101", "Cant find barcode.ini.")
$file = FileRead("temp.ini"); 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
        FileClose(@ScriptDir & "\" & "barcode.ini")
        FileDelete(@ScriptDir & "\" & "barcode.ini")
    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
                $video_file = (@ScriptDir & "\" & IniRead("barcode.ini", "AviCodes", $user_input, "no entry"))
                RunWait (@ProgramFilesDir & "\Windows Media Player\mplayer2.exe /play /fullscreen /close "&$video_file&"")
                WinActivate("Scan Barcode")
                GUICtrlSetData($edit_field, "");erases not successful input
        If TimerDiff($timer) > 20000 Then

Func _PlayRandom()
Local $ArrayNumber; first item in the array which is the total number of listed names in the array
Local $RandomArrayNo; The random array number for specifying which video file to play
    $ArrayNumber=$AviList[0]; the [0] specifies the first item in the array
    $RandomArrayNo = Random(2,$ArrayNumber); creates a number between 2 and the number represented by $ArrayNumber
    RunWait (@ProgramFilesDir & "\Windows Media Player\mplayer2.exe /play /fullscreen /close "&$AviList[$RandomArrayNo]&"")

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        ToolTip('Script is "Paused"',0,0)

Func Terminate()
    Exit 0
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

Share this post

Link to post
Share on other sites

you would need a $pid when you start the external player so you can Kill it with the PID

;waits until no instance of notepad.exe exists


; This will wait until this particular instance of notepad has exited

$PID = Run("notepad.exe")


now for detecting the 20 sec idle i would add an adlib function to check if mouse or keyboard is pressed with _ispressed()

or check in the main message loop (whatever works better)

when idle for 20 sec - start a random movie with PID , if mouse is moving , kill process PID and display input again




Func myadlib()


Share this post

Link to post
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

Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.