#include #include Dim $itemsOld = 0, $lstSelText = "" ;Variable to note changes Global Const $WM_COMMAND = 0x0111, $WM_USER1 = 0x0400 ;Constant Winamp Commands Opt ("WinTitleMatchMode", 4) ;Sets the mode to 'classname=*' titlematch $WAhandle = ControlGetHandle ("classname=Winamp v1.x", "", 0) ;Gets the Winamp Handle $JFhandle = ControlGetHandle("classname=Winamp Gen", "", 0) ;Gets the JTFP Handle $LBhandle = ControlGetHandle($JFhandle, "", 1122) ;Gets the ListBox Handle $EBhandle = ControlGetHandle($JFhandle, "", 1206) ;Gets the InputBox Handle ;GUI: GUICreate ("Jump to File Plugin -- External Control", 400, 320, 500, 400) ;Creates the GUI GUISetState (@SW_SHOW) ;Shows the GUI $btnClear = GUICtrlCreateButton ("Clear", 15, 10, 60, 20) $txtInput = GUICtrlCreateInput ("", 90, 10, 220, 20) $btnEnter = GUICtrlCreateButton ("Enter", 325, 10, 60, 20, $BS_DEFPUSHBUTTON) $lstSongs = GUICtrlCreateList ("", 15, 40, 370, 280) GUICtrlSetFont ($lstSongs, 12) ;set listbox font to #12 ;Initialize ClearJF() ;Clear JTFP SmartDelay() ;Delays for a bit to get JTFP to catch up ;if the list is empty after clearing, notify of error: If _GUICtrlListCount($LBhandle)=0 Then MsgBox(0,"Error:","Playlist is Empty") WinActivate ("classname=AutoIt v3 GUI") ;Focuses on the GUI window GUICtrlSetState ($txtInput, $GUI_FOCUS) ;Focuses to the InputBox While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $btnEnter $strInput = GUICtrlRead ($txtInput) WinActivate ($EBhandle) ; focuses on the 'Jump to file' window ClearJF() ;Quickly clear the list (in case backspaces was used) Send($strInput) ;Sends text to the window SmartDelay() WinActivate ("classname=AutoIt v3 GUI") ;Focuses back on the GUI window GUICtrlSetState ($txtInput, $GUI_FOCUS) ;Focuses back to the InputBox Send("{END}") ;De-selects the text Case $msg = $btnClear ClearJF() ;clears the Jump-to-File input box ClearEC() ;clears the External Control inpub box EndSelect $items = _GUICtrlListCount($LBhandle) ;Gets the number of items in the list if $itemsOld<>$items Then ;Checks if the list has been updated since ;Clears the current list For $i = 0 to $itemsOld _GUICtrlListDeleteItem($lstSongs, 0) Next ;Loop to load all of the entries into an array: $items = _GUICtrlListCount($LBhandle) ;Gets the number of items in the list If $items<>0 Then Dim $ListText[$items] For $i = 0 to ($items - 1) ;'($items - 1)' eliminates the last '0' entry. $ListText[$i] = _GUICtrlListGetText($LBhandle, $i) ;Loads list in memory GUICtrlSetData($lstSongs, $ListText[$i]) ;Sets the list from memory Next EndIf $itemsOld = $items ;takes note of new changes EndIf ;ItemSelected? If for the first time, drop it in the text box; otherwise skip. If (_GUICtrlListSelectedIndex($lstSongs)>=0) AND _ $lstSelText<>(_GUICtrlListGetText($lstSongs, _GUICtrlListSelectedIndex($lstSongs))) _ Then $lstSelText = _GUICtrlListGetText($lstSongs, _GUICtrlListSelectedIndex($lstSongs)) GUICtrlSetData($txtInput, $lstSelText) EndIf Wend Func ClearJF() WinActivate ($EBhandle) ;Focuses on the 'Jump to file' window Send("+{HOME}") ;Sends Shift+Home (Ctrl+A doesn't work) Send("{DEL}") ;Sends Delte EndFunc Func ClearEC() WinActivate ("classname=AutoIt v3 GUI") ;Focuses back on the GUI window GUICtrlSetData ($txtInput, "") ;Clears out the TextBox GUICtrlSetState ($txtInput, $GUI_FOCUS) ;Focuses back to the InputBox EndFunc Func SmartDelay() Dim $pllength[1] ;Variable to get the length of the playlist $pllength = DllCall ("user32.dll", "int", "SendMessage", "hwnd", $WAhandle, "int", $WM_USER1, "int", 0, "int", 124) ;gets the number of tracks in the playlist If ($pllength[0]/10)>500 Then ;Delay shall be based on (playlist items / 10) or 500ms; whichever is greater Sleep($pllength[0]/10) Else Sleep(500) EndIf EndFunc