#include #include Dim $SItemsOld = 0, $QItemsOld = 0 ;Variables to note changes Global Const $WM_COMMAND = 0x0111, $BM_CLICK = 0x00F5 ;Constant Commands $cp = 0 ;TEMP!!! Opt ("WinTitleMatchMode", 4) ;Sets the mode to 'classname=*' titlematch ;Check if Winamp is Running, otherwise exit: If WinExists("classname=Winamp v1.x")=0 Then MsgBox(0, "Error:", "Winamp MUST be on!") Exit EndIf ;Get the main handles: Winamp & Jump-to-File $WAhandle = ControlGetHandle("classname=Winamp v1.x", "", 0) ;Gets the Winamp Handle $JFhandle = ControlGetHandle("classname=Winamp Gen", "Jump to file", 0) ;Gets the JTFP Handle ;If Jump to File isn't on (it shouldn't be): If ControlGetHandle($JFhandle, "", 4951)=="" Then ;Call the 'Jump to file' window DllCall ("user32.dll", "int", "SendMessage", "hwnd", $WAhandle, "int", $WM_COMMAND, "int", 40194, "int", 0) ;Wait until it loads (manually because WinExists doesn't work here) While 1 $JFhandle = ControlGetHandle("classname=Winamp Gen", "Jump to file", 0) If ControlGetHandle($JFhandle, "", 4951)<>"" Then ExitLoop MsgBox(0,"Error","Please be sure you're using the Classic Skin") Wend EndIf ;Get the rest of the handles $WSLhandle = ControlGetHandle($JFhandle, "", 1122) ;Gets the Songs ListBox Handle $WSBLhandle = ControlGetHandle($JFhandle, "", 1206) ;Gets the InputBox Handle $WQLhandle = ControlGetHandle($JFhandle, "", 4951) ;Gets the Queue ListBox Handle $QUEBhandle = ControlGetHandle($JFhandle, "", 4919) ;Gets the Enqueue File Button Handle $REMBhandle = ControlGetHandle($JFhandle, "", 4960) ;Gets the Remove File Button Handle $JTFBhandle = ControlGetHandle($JFhandle, "", 4918) ;Gets the Jump to File Button Handle $CLSBhandle = ControlGetHandle($JFhandle, "", 0002) ;Gets the Close Button Handle ;GUI: GUICreate ("Jump to File Plugin -- External Control v0.71a", 800, 300, 50, 400, -1,$WS_EX_TOPMOST) ;Creates the GUI (Always on TOP) GUISetState (@SW_SHOW) ;Shows the GUI $txtSearch = GUICtrlCreateInput ("", 10, 269, 270, 20) $btnEnter = GUICtrlCreateButton ("Enter", 285, 269, 40, 20, $BS_DEFPUSHBUTTON) $lstSongs = GUICtrlCreateList ("", 10, 10, 315, 280) GUICtrlSetFont($lstSongs, 12) ;set listbox font to #12 $btnPlay = GUICtrlCreateButton ("&Play", 335, 10, 130, 62.5) $btnQueue = GUICtrlCreateButton ("&Queue -->", 335, 82.5, 130, 62.5) $btnRemove = GUICtrlCreateButton ("<-- &Remove", 335, 155, 130, 62.5) $btnCancel = GUICtrlCreateButton ("Cancel", 335, 227.5, 130, 62.5) $btnClear = GUICtrlCreateButton ("&Clear", 335, 227.5, 130, 62.5) GUICtrlSetState($btnClear, $GUI_HIDE) ;hide the Clear button $lstQueue = GUICtrlCreateList ("", 475, 10, 315, 300) GUICtrlSetFont($lstQueue, 12) ;Initialize ClearJF() ;Clear JTFP SmartDelay() ;Short delay for JTFP to catch up ;if the list is empty after clearing, notify of error: If _GUICtrlListCount($WSLhandle)=0 Then MsgBox(0,"Error:","Playlist is Empty") WinActivate ("classname=AutoIt v3 GUI") ;Focuses on the GUI window GUICtrlSetState ($txtSearch, $GUI_FOCUS) ;Focuses on the Search Text Box QInit() ;Initializes the Queue ListBox While 1 ClearCancelState() ;Checks for input text, sets the clear/cancel button accordingly $SItems = _GUICtrlListCount($WSLhandle) ;Gets the number of items in the song list $QItems = ControlListView ($JFhandle, "", "SysListView321", "GetItemCount") ;Gets the number of items in the queue list $msg = GUIGetMsg() ;Get GUI messages Select ;Check the GUI messages Case $msg = $GUI_EVENT_CLOSE ;if 'X' or 'Esc' is pressed, exit. DllCall ("user32.dll", "int", "SendMessage", "hwnd", $CLSBhandle, "int", $BM_CLICK, "int", 0, "int", 0) ;Clicks on the Clo&se File button ExitLoop Case $msg = $btnCancel ;if 'Cancel' is pressed, exit. DllCall ("user32.dll", "int", "SendMessage", "hwnd", $CLSBhandle, "int", $BM_CLICK, "int", 0, "int", 0) ;Clicks on the Clo&se File button ExitLoop Case $msg = $btnClear ClearJF() ;clears the Jump-to-File input box ClearEC() ;clears the External Control input box ClearCancelState() ;shows the Cancel button _GUICtrlListSelectIndex($lstSongs, -1) ;clears the Songs list box #comments-start Case $msg = $btnQueue ;Check the selection If (_GUICtrlListSelectedIndex($lstSongs)>=0) Then ;Write to JTF's input-box, press Alt+Q, and clear the box ;INSTEAD of Alt+Q, press the Queue button ;INSTEAD Write to JTF, match the indexes $QItems = _GUICtrlListCount($lstQueue) ;Gets the number of items in the queue list WinActivate($WSBLhandle) ClearJF() ;Quickly clear the inputbox Send(_GUICtrlListGetText($lstSongs, _GUICtrlListSelectedIndex($lstSongs))) SmartDelay() Send("!q") ;Send Alt+Q to queue ClearJF() ;Quickly clear the inputbox WinActivate("clasname=AutoIt v3 GUI") ;Focuses back on the GUI Window _GUICtrlListAddItem($lstQueue, "0" & $QItems+1 & ") " & _ ControlListView($JFhandle, "", "SysListView321", "GetText", $QItems, 0)) ;ADDS the last item $QItemsOld = $QItems ;takes note of new changes GUICtrlSetState($txtSearch, $GUI_FOCUS) ;Focuses back to the List Box Else Beep(440,150) ;Error: Plays A4 for 150ms EndIf #comments-end Case $msg = $btnQueue If (_GUICtrlListSelectedIndex($lstSongs)>=0) Then ;Check if there's a selection in lstSongs _GUICtrlListSelectIndex($WSLhandle, _GUICtrlListSelectedIndex($lstSongs)) ;Sets the Winamp List Index to the lstSongs' index DllCall ("user32.dll", "int", "SendMessage", "hwnd", $QUEBhandle, "int", $BM_CLICK, "int", 0, "int", 0) ;Clicks on the En&queue File button SInit($SItems) ;Updates the Song List for the '[X]' notations QInit() ;Updates the Queue List for the '#)' notations Else Beep(440,150) ;Error: Plays A4 for 150ms EndIf Case $msg = $btnRemove ;How it works: Selects the index according to lstQueue ;and presses '&Remove' button. ;It then MUST redraw the QueueList (for the '#)' to work properly) $QIndex = _GUICtrlListSelectedIndex($lstQueue) ;Gets the number of item to be removed If $QIndex = -1 Then Beep(440,150) ;Error: Plays A4 for 150ms Else PrimitiveRemove($QIndex) ;Update the Queue list _GUICtrlListDeleteItem($lstQueue, $QIndex) ;Deletes the item $QItemsOld = $QItems ;takes note of new changes SInit($SItems) ;Updates the Song List for the [X] notations If $QIndex<>$QItems-1 Then QInit() ;If the item to be removed isn't last, redraw the Queue list EndIf Case $msg = $btnEnter $strInput = GUICtrlRead($txtSearch) 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 If _GUICtrlListCount($WSLhandle)>0 Then ;If there's at least one entry, SInit($SItems) ;Redraw now $SItemsOld = $SItems ;Reset _GUICtrlListSelectIndex($lstSongs, 0) ;Select the top one EndIf GUICtrlSetState($txtSearch, $GUI_FOCUS) ;Focuses back to the InputBox Send("{END}") ;De-selects the text and goes to the end Case $msg = $btnPlay If (_GUICtrlListSelectedIndex($lstSongs)>=0) Then ;Check if there's a selection in lstSongs _GUICtrlListSelectIndex($WSLhandle, _GUICtrlListSelectedIndex($lstSongs)) ;Sets the Winamp List Index to the lstSongs' index DllCall ("user32.dll", "int", "SendMessage", "hwnd", $JTFBhandle, "int", $BM_CLICK, "int", 0, "int", 0) ;Clicks on the En&queue File button ClearJF() ClearEC() SInit($SItems) ;Updates the Song List for the '[X]' notations QInit() ;Updates the Queue List for the '#)' notations Else Beep(440,150) ;Error: Plays A4 for 150ms EndIf EndSelect If $SItemsOld<>$SItems Then ;Checks if the song list has been updated since SInit($SItems) $SItemsOld = $SItems ;takes note of new changes EndIf If $QItemsOld<>$QItems Then ;Checks if the queue list has been updated since QInit() SInit($SItems) ;$QItemsOld = $QItems ;takes note of new changes EndIf If ControlListView($JFhandle, "", "SysListView321", "GetText", 0, 0)=="There are no files in the queue" Then _GUICtrlListDeleteItem($lstQueue, 0) EndIf ;ItemSelected? If for the first time, drop it in the text box; otherwise skip. ;If (_GUICtrlListSelectedIndex($lstSongs)>=0) AND _ ;$SSelText<>(_GUICtrlListGetText($lstSongs, _GUICtrlListSelectedIndex($lstSongs))) _ ;Then ; $SSelText = _GUICtrlListGetText($lstSongs, _GUICtrlListSelectedIndex($lstSongs)) ; ;GUICtrlSetData($txtSearch, (_GUICtrlListGetText($lstSongs, _GUICtrlListSelectedIndex($lstSongs)))) ; GUICtrlSetData($txtSearch, $SSelText) ;EndIf Wend Func ClearJF() WinActivate ($WSBLhandle) ;Focuses on the 'Jump to file' window Send("+{HOME}") ;Sends Shift+Home (Ctrl+A doesn't work) Send("{DEL}") ;Sends Delete EndFunc Func ClearEC() WinActivate ("classname=AutoIt v3 GUI") ;Focuses back on the GUI window GUICtrlSetData ($txtSearch, "") ;Clears out the TextBox GUICtrlSetState ($txtSearch, $GUI_FOCUS) ;Focuses back to the InputBox EndFunc Func SmartDelay() ;INSTEAD: Make it relative to the number of items in the Song List, or any list to that matter... Local $SDSItems = _GUICtrlListCount($WSLhandle) If ($SDSItems/10)>500 Then Sleep($SDSItems/10) Else Sleep(500) EndIf EndFunc Func ClearCancelState() ;Swaps between the Cancel and Clear buttons according to the lstSongs and txtSearch selection If GUICtrlGetState($btnCancel)==80 Then If GUICtrlRead($txtSearch)<>"" OR (_GUICtrlListSelectedIndex($lstSongs)>=0) Then GUICtrlSetState($btnCancel, $GUI_HIDE) GUICtrlSetState($btnClear, $GUI_SHOW) ;MsgBox(0,"Inside:",GUICtrlGetState($btnCancel)) EndIf EndIf If GUICtrlGetState($btnClear)==80 Then If GUICtrlRead($txtSearch)=="" AND (_GUICtrlListSelectedIndex($lstSongs)<0) Then GUICtrlSetState($btnClear, $GUI_HIDE) GUICtrlSetState($btnCancel, $GUI_SHOW) ;MsgBox(0,"","Cancel Show") EndIf EndIf EndFunc Func QInit() ;Redraws the Queue ListBox _GUICtrlListClear($lstQueue) ;Clear the list $QItems = ControlListView ($JFhandle, "", "SysListView321", "GetItemCount") ;Gets the number of items in the queue list If $QItems<>0 AND ControlListView($JFhandle, "", "SysListView321", "GetText", 0, 0)<>"There are no files in the queue" Then For $i = 0 to ($QItems - 1) _GUICtrlListAddItem($lstQueue, "0" & $i+1 & ") " & _ ControlListView($JFhandle, "", "SysListView321", "GetText", $i, 0)) ;ADDS the last item Next EndIf $QItemsOld = $QItems ;takes note of new changes EndFunc Func SInit(ByRef $ISItems) ;Clears the current list _GUICtrlListClear($lstSongs) ;Loop to load all of the entries into an array: $ISItems = _GUICtrlListCount($WSLhandle) ;Gets the number of items in the list If $ISItems<>0 Then For $i = 0 to ($ISItems - 1) ;'($ISItems - 1)' eliminates the last '0' entry. _GUICtrlListAddItem($lstSongs, _GUICtrlListGetText($WSLhandle, $i)) ;Writes WA's Song List into lstSongs ;MsgBox(0,"Adding:","Text: " & _GUICtrlListGetText($WSLhandle, $i) & " | Index: " & $i) Next EndIf ;Consider adding: $SItemsOld = $SItems EndFunc Func PrimitiveRemove(ByRef $QRIndex) ControlFocus($WQLhandle, "", $WQLhandle) Send("{HOME}") For $i = 1 to $QRindex Send("{DOWN}") Next DllCall ("user32.dll", "int", "SendMessage", "hwnd", $REMBhandle, "int", $BM_CLICK, "int", 0, "int", 0) ;Clicks on the &Remove File button WinActivate("classname=AutoIt v3 GUI") EndFunc ;Func KeyEnter() ; MsgBox(0,"$msg",$msg) ;EndFunc ;Func KeyEsc() ; MsgBox(0,"$msg",$msg) ; ;MsgBox(0,"",GUICtrlGetState($btnClear)) ;EndFunc