Jump to content

Need Help With Puting A Background In The Video Gui


amdead
 Share

Recommended Posts

Need help with puting a background in the video GUI, i want to make a player like WMP, so users can change the look of the player. I just dont know how to put the script in the main bit of code

[Video code]

#include <GuiConstants.au3>

Opt("WinTitleMatchMode",2)

Opt("OnExitFunc","_exit")

Opt("GuiOnEventMode",1)

Global $mystatus = "Paused"

Global $pause = 0

Global $wintitle = "none"

$GUI = GuiCreate("VideoPlayer",400,35,350,300,-1)

$PLAY = GUICtrlCreateButton("Play",41,2,40,30)

$PAUSEBUT = GUICtrlCreateButton("Pause",82,2,40,30)

$STOP = GUICtrlCreateButton("Stop",123,2,40,30)

$LOAD = GUICtrlCreateButton("Load",164,2,40,30)

$STATUS = GUICtrlCreateLabel("Status: "&$mystatus&@CRLF,206,0,-1,30)

GuiSetState()

GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit")

GUISetOnEvent($GUI_EVENT_MINIMIZE,"_Minimize")

GUISetOnEvent($GUI_EVENT_RESTORE,"_Restore")

GuiCtrlSetOnEvent($PLAY,"_Play")

GuiCtrlSetOnEvent($STOP,"_Stop")

GuiCtrlSetOnEvent($LOAD,"_Load")

GuiCtrlSetOnEvent($PAUSEBUT,"_Pause")

HotKeySet("^{DEL}","_Exit")

While 1

$stateplayer = WinGetState("VideoPlayer", "")

if BitAnd($stateplayer ,8) Then

$statemovie = WinGetState("VideoMovie", "")

If BitAnd($statemovie, 16) Then

WinSetState("VideoMovie","",@SW_RESTORE)

EndIf

EndIf

sleep(50)

Wend

Func mciSendString($string)

Local $ret

$ret = DllCall("winmm.dll","int","mciSendString","str",$string,"str","","int",65534,"hwnd",0)

If Not @error Then Return $ret[2]

EndFunc

Func _Exit()

mciSendString("Close myvideo")

Exit

EndFunc

Func _Play()

$pause = 0

mciSendString("play myvideo repeat")

$mystatus = "PLAYING"

Guictrlsetdata($STATUS,"Status: "&$mystatus&@CRLF)

WinSetTitle($wintitle,"","VideoMovie")

EndFunc

Func _Stop()

mciSendString("Stop myvideo")

mciSendString("seek myvideo to start")

$mystatus = "STOPPED"

Guictrlsetdata($STATUS,"Status: "&$mystatus&@CRLF)

EndFunc

Func _Load()

mciSendString("Close myvideo")

$file = FileOpenDialog("OPEN","","Video (*.mp3;*.avi;*.mpg)")

$wintitle = stringsplit($file,"\")

$wintitle = $wintitle[$wintitle[0]]

$file = '"'&$file&'"'

mciSendString("open "&$file&" alias myvideo")

_Play()

EndFunc

Func _Pause()

If $pause = 0 Then

mciSendString("stop myvideo")

$mystatus = "PAUSED"

Guictrlsetdata($STATUS,"Status: "&$mystatus&@CRLF)

$pause = 1

Else

_Play()

EndIf

EndFunc

Func _Minimize()

WinSetState("VideoMovie","",@SW_MINIMIZE)

EndFunc

Func _Restore()

WinSetState("VideoMovie","",@SW_RESTORE)

EndFunc

[background code]

#include <GUIConstants.au3>

; Find a picture to use as Gui background.

Global $picture

If FileChangeDir(@WindowsDir & '\Web\Wallpaper') Then

$handle = FileFindFirstFile('*.jpg')

If $handle <> -1 Then

$picture = FileFindNextFile($handle)

FileClose($handle)

EndIf

EndIf

; Setup the Gui

$title = 'Test Background with AutoIt ' & FileGetVersion(@AutoItExe)

$handle = GUICreate($title, 320, 240)

If FileExists($picture) Then

GUICtrlCreatePic($picture, 0, 0, 320, 240)

GUICtrlSetState(Default, $GUI_DISABLE)

Else

MsgBox(0, '', 'A picture was not found to test with in ' & @WorkingDir)

Exit

EndIf

$button = GUICtrlCreateButton("test",10,10)

GuiSetState()

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then Exit

WEnd

Link to comment
Share on other sites

#include <GuiConstants.au3>
Opt("WinTitleMatchMode",2)
Opt("OnExitFunc","_exit")
Opt("GuiOnEventMode",1)
Global $mystatus = "Paused"
Global $pause = 0
Global $wintitle = "none"

$picture = @TempDir & "\pic-Back.jpg"
FileInstall("C:\Temp\Ez-back.jpg", $picture); use you pic file here

$GUI = GuiCreate("VideoPlayer",400,35,350,300,-1)
GUICtrlCreatePic($picture, 0, 0, 350, 300)
$PLAY = GUICtrlCreateButton("Play",41,2,40,30)
$PAUSEBUT = GUICtrlCreateButton("Pause",82,2,40,30)
$STOP = GUICtrlCreateButton("Stop",123,2,40,30)
$LOAD = GUICtrlCreateButton("Load",164,2,40,30)
$STATUS = GUICtrlCreateLabel("Status: "&$mystatus&@CRLF,206,0,-1,30)
GuiSetState()
GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit")
GUISetOnEvent($GUI_EVENT_MINIMIZE,"_Minimize")
GUISetOnEvent($GUI_EVENT_RESTORE,"_Restore")
GuiCtrlSetOnEvent($PLAY,"_Play")
GuiCtrlSetOnEvent($STOP,"_Stop")
GuiCtrlSetOnEvent($LOAD,"_Load")
GuiCtrlSetOnEvent($PAUSEBUT,"_Pause")

HotKeySet("^{DEL}","_Exit")
While 1
$stateplayer = WinGetState("VideoPlayer", "")
if BitAnd($stateplayer ,8) Then
$statemovie = WinGetState("VideoMovie", "")
If BitAnd($statemovie, 16) Then
WinSetState("VideoMovie","",@SW_RESTORE)
EndIf
EndIf
sleep(50)
Wend

Func mciSendString($string)
Local $ret
$ret = DllCall("winmm.dll","int","mciSendString","str",$string,"str","","int",65534,"hwnd",0)
If Not @error Then Return $ret[2]
EndFunc
Func _Exit()
mciSendString("Close myvideo")
Exit
EndFunc

Func _Play()
$pause = 0
mciSendString("play myvideo repeat")
$mystatus = "PLAYING"
Guictrlsetdata($STATUS,"Status: "&$mystatus&@CRLF)
WinSetTitle($wintitle,"","VideoMovie")
EndFunc
Func _Stop()
mciSendString("Stop myvideo")
mciSendString("seek myvideo to start")
$mystatus = "STOPPED"
Guictrlsetdata($STATUS,"Status: "&$mystatus&@CRLF)
EndFunc
Func _Load()
mciSendString("Close myvideo")
$file = FileOpenDialog("OPEN","","Video (*.mp3;*.avi;*.mpg)")
$wintitle = stringsplit($file,"\")
$wintitle = $wintitle[$wintitle[0]]
$file = '"'&$file&'"'
mciSendString("open "&$file&" alias myvideo")
_Play()
EndFunc
Func _Pause()
If $pause = 0 Then
mciSendString("stop myvideo")
$mystatus = "PAUSED"
Guictrlsetdata($STATUS,"Status: "&$mystatus&@CRLF)
$pause = 1
Else
_Play()
EndIf
EndFunc

Func _Minimize()
WinSetState("VideoMovie","",@SW_MINIMIZE)
EndFunc
Func _Restore()
WinSetState("VideoMovie","",@SW_RESTORE)
EndFunc

8)

NEWHeader1.png

Link to comment
Share on other sites

Am confused, i put the jpeg file in n chaged the file name

$picture = @TempDir & "BKG.jpeg"

FileInstall("BKG.jpeg", $picture); use you pic file here

and the picture still don't show

$picture = @TempDir & "\BKG.jpeg"

FileInstall("BKG.jpeg,@TempDir)

This ia assuming that BKG.jpeg is in the script directory or that you compiled the script with the file in the script directory. Otherwise you will have to add the FULL path to the file.

BTW double check your file extension and make sure it's not jpg. If that's the case then change the file extensions used above.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Keep getting an error "Error addinf file: BKG.jpeg,@tempdir"

Do you have have the file install it self? can't i just add the picture?

$picture = @TempDir & "\BKG.jpeg"

FileInstall("BKG.jpeg,@TempDir)

It was a GEOSoft typo.

It should be: FileInstall("BKG.jpeg", @TempDir)

notice the end quote after BKG.jpeg.

edit: misspelled GEOSoft's name

Edited by SerialKiller
Link to comment
Share on other sites

  • 9 years later...

Necropost.png

You do realize this thread is over 9 years old right?

Edited by BrewManNH

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 Gude
How 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

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...