computergroove Posted June 30, 2014 Posted June 30, 2014 (edited) I have been looking at the WMP.udf's and I dont understand how to make a form window and add elements to it. I want to have 3 main elements in my script 1. main GUICreate form. Fills the screen and colors the background black while idling 2. A media player object 3. A GUI User input box I want to have the video player playing a video file. I want the video to play at full screen but I need the script to be listening to the user input box. I figure if I have both the video player object and the user input box running at the same time I can continue to enter information in the user input box and send the data to the media player while it is playing another video. I have looked here -> but I am having trouble getting the window I create to show a user input text window. Why isn't this adding a user input window and allowing me to enter data into it? expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=WMP Example 3.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <IE.au3> Global $width = 800 Global $height = 450 Global $IEControl; = null; Global $MyGUI = GUICreate("WMPlayer Control", $width,$height,(@DesktopWidth-$width)/2,(@DesktopHeight-$height)/2, $WS_OVERLAPPEDWINDOW) Global $oIE = _GUICtrl_CreateWMPlayer("about:blank", 0, 0, $width, $height) GUISetState (@SW_SHOW, $MyGUI) GUIRegisterMsg($WM_SIZE, "WM_SIZE") Global $playerOBJ = _IEGetObjById($oIE, "objWMPlayer") if NOT IsObj($playerOBJ) Then MsgBox(0, "Error", "WMP failed to be created."); Exit; EndIf ;Start of my modifications to the working WMP udf example script $edit_field = GUICtrlCreateInput("", 0, 0, 200, 20); ( "text", left, top , width , height) While 1 $Form1 = GUICreate("Video Player", 0, 0, 0, 0, $WS_MAXIMIZE); $WS_EX_TOPMOST) ;WS_MAXIMIZE) $FileOpen = null $msg = GUIGetMsg() 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 Else GUICtrlSetData($edit_field, "");erases input in gui window _wmpvalue($playerOBJ, "nocontrols") _wmploadmedia($playerOBJ,$FileOpen) $mediaName = _wmpvalue($playerOBJ, "getname"); WinSetTitle($MyGUI, "", "Playing video: " & $mediaName) EndIf EndSwitch WEnd ;End of my modifications to the working WMP udf example script ;If Not @error Then ; _wmpvalue($playerOBJ, "nocontrols") ; _wmploadmedia($playerOBJ,$FileOpen) ; $mediaName = _wmpvalue($playerOBJ, "getname"); ; WinSetTitle($MyGUI, "", "Playing video: " & $mediaName) ;Else ; Exit; ;EndIf While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit; EndSwitch WEnd Func WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam, $ilParam Local $xClient, $yClient $xClient = BitAND($ilParam, 0x0000FFFF) $yClient = BitShift($ilParam, 16) GUICtrlSetPos($IEControl, 0, 0, $xClient, $yClient) if NOT @error Then if IsObj($playerOBJ) Then $playerOBJ.width = $xClient; if IsObj($playerOBJ) Then $playerOBJ.height = $yClient; EndIf Return $GUI_RUNDEFMSG EndFunc ;=============================================== ;=============================================== ;=============================================== #cs _wmploadmedia( $object, $URL ) $object: Object returned from the $playerOBJ = _IEGetObjById($oIE, "objWMPlayer") $URL: Path or URL of the media Return: None #ce Func _wmploadmedia( $object, $URL) $object.URL = $URL While Not $object.controls.isAvailable("play") Sleep(1) WEnd $object.controls.play() EndFunc ; Function: _GUICtrl_CreateWMPlayer ; Purpose: Embed Windows Media Player and play one file or one playlist only. ; Notes: PARAM NAME="url" is ReadOnly ; Authors: squirrely1 ; borderless IE embed example: GaryFrost ; Kudos - Kare Johansson, CFire ; References: ; http://msdn2.microsoft.com/en-us/library/ms930698.aspx ; http://www.w3schools.com/media/media_playerref.asp ; clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6 - wmplayer latest installed version ; clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95 - wmp 6.4 ;=============================================== Func _GUICtrl_CreateWMPlayer($movieURL, $playerLeft, $playerTop, $playerWidth, $playerHeight, _ $insetBorders = 0, $fullscreenMode = False, $showControls = True, $enableContextMenu = True, _ $LoopMode = false, $playCount = 1, $playVolume = 100, $playBalance = 0, $enableFullScreenControls = True) If $fullscreenMode Then $fullscreenMode = "true" Else $fullscreenMode = "false" EndIf If $showControls Then $showControls = "true" Else $showControls = "false" EndIf If $enableContextMenu Then $enableContextMenu = "true" Else $enableContextMenu = "false" EndIf If $LoopMode Then $playCount = 999 EndIf If $enableFullScreenControls Then $enableFullScreenControls = "true" Else $enableFullScreenControls = "false" EndIf Local $myIE_Obj = _IECreateEmbedded () $IEControl = GUICtrlCreateObj($myIE_Obj, $playerLeft, $playerTop, $playerWidth, $playerHeight) _IENavigate($myIE_Obj, "about:blank") Local $htmlWMP $htmlWMP = '' _ & @CR & '<body style="margin:0;padding:0" >' _ & @CR & '<OBJECT' _ & @CR & 'ID="objWMPlayer"' _ & @CR & 'STYLE="margin:0;padding:0"' _ & @CR & 'HSPACE="0"' _ & @CR & 'VSPACE="0"' _ & @CR & 'BORDER="0"' _ & @CR & 'WIDTH="' & $playerWidth & '"' _ & @CR & 'HEIGHT="' & $playerHeight & '"' _ & @CR & 'CLASSID="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6"' _ & @CR & 'STANDBY="Loading Windows Media Player components..."' _ & @CR & 'TYPE="application/x-ms-wmp">' _ & @CR & '<PARAM NAME="allowHideControls" VALUE="true">' _ & @CR & '<PARAM NAME="autoStart" VALUE="false">' _ & @CR & '<PARAM NAME="audioStream" VALUE="false">' _ & @CR & '<PARAM NAME="autoSize" VALUE="false">' _ & @CR & '<PARAM NAME="balance" VALUE="' & $playBalance & '"><!-- -100 to 100 -->' _ & @CR & '<!-- <PARAM NAME="bufferingTime" VALUE="5"><!-- seconds -->' _ & @CR & '<PARAM NAME="clickToPlay" VALUE="false"><!-- has no effect -->' _ & @CR & '<PARAM NAME="currentPosition" VALUE="0"><!-- start position within video, in seconds -->' _ & @CR & '<PARAM NAME="enableContextMenu" VALUE="' & $enableContextMenu & '">' _ & @CR & '<PARAM NAME="enableFullScreenControls" VALUE="' & $enableFullScreenControls & '">' _ & @CR & '<PARAM NAME="enabled" VALUE="true"><!-- whether controls are enabled -->' _ & @CR & '<PARAM NAME="fullScreen" VALUE="' & $fullscreenMode & '">' _ & @CR & '<PARAM NAME="mute" VALUE="false">' _ & @CR & '<PARAM NAME="playCount" VALUE="' & $playCount & '">' _ & @CR & '<!-- <PARAM NAME="previewMode" VALUE="true"> -->' _ & @CR & '<PARAM NAME="rate" VALUE="1"><!-- play speed of -.5 to 2 increments of .1 -->' _ & @CR & '<PARAM NAME="sendPlayStateChangeEvents" VALUE="false">' _ & @CR & '<PARAM NAME="showCaptioning" VALUE="false">' _ & @CR & '<PARAM NAME="showControls" VALUE="' & $showControls & '">' _ & @CR & '<PARAM NAME="showGotoBar" VALUE="false">' _ & @CR & '<PARAM NAME="showPositionControls" VALUE="true"><!-- uiMode must = "full" -->' _ & @CR & '<PARAM NAME="showStatusBar" VALUE="false"><!-- has no effect -->' _ & @CR & '<PARAM NAME="showDisplay" VALUE="true"><!-- has no effect - reportedly shows filename -->' _ & @CR & '<PARAM NAME="stretchToFit" VALUE="true">' _ & @CR & '<PARAM NAME="uiMode" VALUE="full"><!-- invisible, none, mini, full -->' _ & @CR & '<!-- <PARAM NAME="videoBorderWidth" VALUE="0"> -->' _ & @CR & '<PARAM NAME="volume" VALUE="' & $playVolume & '"><!-- volume percent setting of wmplayer.exe -->' _ & @CR & '<PARAM NAME="windowlessVideo" VALUE="false"><!-- must be the default (false) for function to work in wmp 9.0, otherwise might renders video directly in the client area -->' _ & @CR & '</OBJECT>' _ & @CR & '</body>' _IEDocWriteHTML ($myIE_Obj, $htmlWMP) _IEAction ($myIE_Obj, "refresh") $myIE_Obj.document.body.scroll = "no" $myIE_Obj.document.body.style.border = $insetBorders Return $myIE_Obj EndFunc ;==>_GUICtrl_CreateWMPlayer Func _wmpvalue( $object, $setting, $para=1 ) Switch $setting Case "play" If $object.controls.isAvailable("play") Then $object.controls.play() case "stop" If $object.controls.isAvailable("stop") Then $object.controls.stop() case "pause" If $object.controls.isAvailable("pause") Then $object.controls.pause() case "invisible" $object.uiMode = "invisible" case "controls" $object.uiMode = "full" case "nocontrols" $object.uiMode = "none" case "fullscreen" $object.fullscreen = "True" Case "step" If $object.controls.isAvailable("step") Then $object.controls.step($para) Case "fastForward" If $object.controls.isAvailable("fastForward") Then $object.controls.fastForward() Case "fastReverse" If $object.controls.isAvailable("fastReverse") Then $object.controls.fastReverse() Case "volume" $object.settings.volume = $para Case "rate" $object.settings.rate = $para Case "playcount" $object.settings.playCount = $para Case "setposition" $object.controls.currentPosition = $para Case "getposition" Return $object.controls.currentPosition Case "getpositionstring" Return $object.controls.currentPositionString Case "getduration" Return $object.currentMedia.duration Case "getname" Return $object.currentMedia.name EndSwitch EndFunc Edited June 30, 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
computergroove Posted July 1, 2014 Author Posted July 1, 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
computergroove Posted July 1, 2014 Author Posted July 1, 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
Palestinian Posted July 1, 2014 Posted July 1, 2014 Don't "bump" your thread unless it's been +24 hours without any replies to it.
Moderators Melba23 Posted July 1, 2014 Moderators Posted July 1, 2014 computergroove,What ^he^ said. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
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