jfcby Posted September 12, 2008 Share Posted September 12, 2008 Hello, Introducing "Windows Media Player Resumer" (WMPR)... embeds Miscrosoft Windows Media Player (WMP) in AutoIT3. After you've setup WMP and WMPR for the first time then when you start WMP it will find and select the last song that you played. When you close WMPR then it will save the last song played to a specified file (file.config). I've added a playing list to WMP so that when started in "Now Playing" mode then it is automatically populated in the Now Playing List on the right side of the screen. It has been test in WMP version 9 and 10 and is not compatible with version 11. The script was put together with the help of AutoTI3 forum members and the Help File. So I'm offering the script as free and Open Source. It can be changed and modified as needed but all I ask is do not delete my information but add yours when distributing the script. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <Constants.au3> #include <GuiListView.au3> #cs Title: WMP Resumer Author: James F Cooper & AutoIT3 Forum Members Date: September 8, 2008 Copyright: Free & Open Source - Use and modify as needed but leave my information in tact and add yours. Website: http://www.coopersbarnyard.net - The Biz Portal Guide! ****** Description ****** Windows Media Player Resumer (WMPR)... embeds Miscrosoft Windows Media Player (WMP) in AutoIT3. After you've setup WMP and WMPR for the first time then when you start WMP it will find and select the last song that you played. When you close WMPR then it will save the last song played to a specified file (file.config). ****** Comments ****** For use with WMP v9 & v10. Not compatible with WMP v11. ******Updates ****** Features that will be added in future revisions. Date - Description ****** Bugs ****** Fixes to parts of the program that is not functioning/working properly. Date - Description #ce Dim $rData, $fName $hGUI2 = GUICreate('WMP Resumer', 800, 400, 0, 0, BitOr($GUI_SS_DEFAULT_GUI,$WS_CLIPCHILDREN)) $hDrive = @ProgramFilesDir $pID = Run($hDrive & "/Windows Media Player/wmplayer.exe /Task NowPlaying");FileGetShortName("C:\Documents and Settings\User\My Documents\My Downloads\KJBible\mp3\_KJVOldNewTeatament\_KJB.m3u")) WinWait("") Sleep(2000) $hChild = WinGetHandle("Windows Media Player") _WinAPI_SetParent($hChild, $hGUI2) _WinAPI_SetWindowLong($hChild, $GWL_STYLE, $WS_CLIPSIBLINGS) _WinAPI_SetWindowLong($hChild, $GWL_HWNDPARENT, $hGUI2) _WinAPI_SetWindowPos($hChild, 0, 0, 0, 0, 0, BitOr($SWP_SHOWWINDOW, $SWP_NOSIZE)) GUiSetState(@SW_SHOW, $hGUI2) GUISetState(@SW_MAXIMIZE, $hGUI2) WinSetState($hChild, "", @SW_MAXIMIZE) $h = WinGetHandle("[CLASS:WMPlayerApp]") $hwnd = ControlGetHandle($h,"","ATL:SysListView321") fFile() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE sFile() Sleep(2000) ProcessClose($pID) Exit Case Else EndSwitch WEnd Func wActivate() ;Activate Window WinActivate($h) EndFunc Func rFile() ;Read File - Perform each time program opens to resume last song play $fRead = FileOpen("config\file.config",0) $rData = FileReadLine($fRead) FileClose($fRead) EndFunc Func fFile() ;Find File - Perform each time program opens to resume last song play wActivate() Sleep(30000) rFile() $fFile = _GUICtrlListView_FindText($hwnd, $rData, -1, True) Sleep(2000) _GUICtrlListView_ClickItem($hwnd, $fFile, "left", False) EndFunc Func sName() ;Song Name - Gets the current song name when program closes $fName = _GUICtrlListView_GetItemText($hwnd, _GUICtrlListView_GetNextItem($hwnd)) Sleep(2000) EndFunc Func sFile() ;Save File - Perform each time program closes wActivate() Sleep(2000) sName() $fWrite = FileOpen("config\file.config",2) FileWrite($fWrite,$fName) FileClose($fWrite) EndFunc Learning to write scripts, jfcby Determined -- Devoted -- Delivered Make your mind up -- to seriously apply yourself -- accomplishing the desired results. **** A soft answer turneth away wrath: but grievous words stir up anger. Proverbs 15:1 KJB **** 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