#include #include Dim $SItemsOld = 0, $QItemsOld = 0 ;Variables to note changes Global Const $WM_COMMAND = 0x0111, $BM_CLICK = 0x00F5, $WM_KEYDOWN=0x100 ;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: $main = GUICreate ("Jump to File Plugin -- External Control v0.8b", 800, 480, 50, 200, -1,$WS_EX_TOPMOST) ;Creates the GUI (Always on TOP) GUISetState (@SW_SHOW, $main) ;Shows the GUI ;GUI Elements: $txtSearch = GUICtrlCreateInput ("", 11, 268, 313, 22, $ES_UPPERCASE) GUICtrlSetFont($txtSearch, 14) $btnEnter = GUICtrlCreateButton ("Enter", 285, 269, 40, 20, $BS_DEFPUSHBUTTON) GUICtrlSetState($btnEnter, $GUI_HIDE) ;hide the Enter button $lstSongs = GUICtrlCreateList ("", 10, 5, 315, 280, BitXOR($LBS_SORT, $WS_BORDER)) GUICtrlSetFont($lstSongs, 14) ;set listbox font to #12 $btnPlay = GUICtrlCreateButton ("&Play", 335, 6, 130, 67.5) $btnQueue = GUICtrlCreateButton ("&Queue -->", 335, 78.5, 130, 67.5) $btnRemove = GUICtrlCreateButton ("<-- &Remove", 335, 150, 130, 67.5) $btnCancel = GUICtrlCreateButton ("Cancel", 335, 222.5, 130, 67.5) $btnClear = GUICtrlCreateButton ("&Clear", 335, 222.5, 130, 67.5) GUICtrlSetState($btnClear, $GUI_HIDE) ;hide the Clear button $lstQueue = GUICtrlCreateList ("", 475, 5, 315, 300) GUICtrlSetFont($lstQueue, 14) ;OSK Elements: ;Row 1: $keyQ = GUICtrlCreateButton("Q", 8, 305, 50, 40) $keyW = GUICtrlCreateButton("W", 66, 305, 50, 40) $keyE = GUICtrlCreateButton("E", 124, 305, 50, 40) $keyR = GUICtrlCreateButton("R", 182, 305, 50, 40) $keyT = GUICtrlCreateButton("T", 240, 305, 50, 40) $keyY = GUICtrlCreateButton("Y", 298, 305, 50, 40) $keyU = GUICtrlCreateButton("U", 356, 305, 50, 40) $keyI = GUICtrlCreateButton("I", 414, 305, 50, 40) $keyO = GUICtrlCreateButton("O", 472, 305, 50, 40) $keyP = GUICtrlCreateButton("P", 530, 305, 50, 40) ;NumPad: $key7 = GUICtrlCreateButton("7", 624, 305, 50, 40) $key8 = GUICtrlCreateButton("8", 682, 305, 50, 40) $key9 = GUICtrlCreateButton("9", 740, 305, 50, 40) ;Row 2: $keyA = GUICtrlCreateButton("A", 8, 350, 50, 40) $keyS = GUICtrlCreateButton("S", 66, 350, 50, 40) $keyD = GUICtrlCreateButton("D", 124, 350, 50, 40) $keyF = GUICtrlCreateButton("F", 182, 350, 50, 40) $keyG = GUICtrlCreateButton("G", 240, 350, 50, 40) $keyH = GUICtrlCreateButton("H", 298, 350, 50, 40) $keyJ = GUICtrlCreateButton("J", 356, 350, 50, 40) $keyK = GUICtrlCreateButton("K", 414, 350, 50, 40) $keyL = GUICtrlCreateButton("L", 472, 350, 50, 40) $keyApostrophe = GUICtrlCreateButton("'", 530, 350, 50, 40) ;NumPad: $key4 = GUICtrlCreateButton("4", 624, 350, 50, 40) $key5 = GUICtrlCreateButton("5", 682, 350, 50, 40) $key6 = GUICtrlCreateButton("6", 740, 350, 50, 40) ;Row 3: $keyZ = GUICtrlCreateButton("Z", 8, 395, 50, 40) $keyX = GUICtrlCreateButton("X", 66, 395, 50, 40) $keyC = GUICtrlCreateButton("C", 124, 395, 50, 40) $keyV = GUICtrlCreateButton("V", 182, 395, 50, 40) $keyB = GUICtrlCreateButton("B", 240, 395, 50, 40) $keyN = GUICtrlCreateButton("N", 298, 395, 50, 40) $keyM = GUICtrlCreateButton("M", 356, 395, 50, 40) $keyComma = GUICtrlCreateButton(",", 414, 395, 50, 40) $keyHyphen = GUICtrlCreateButton("-", 472, 395, 50, 40) ;NumPad: $key1 = GUICtrlCreateButton("1", 624, 395, 50, 40) $key2 = GUICtrlCreateButton("2", 682, 395, 50, 40) $key3 = GUICtrlCreateButton("3", 740, 395, 50, 40) ;Row 4: $keySpace = GUICtrlCreateButton("SPACE", 8, 440, 282, 40) $keyBackspace = GUICtrlCreateButton("BACKSPACE", 298, 440, 166, 40) ;$keyLeft = GUICtrlCreateButton("<==", 472, 440, 50, 40) ;$keyRight = GUICtrlCreateButton("==>", 530, 440, 50, 40) ;NumPad: $key0 = GUICtrlCreateButton("0", 624, 440, 110, 40) $keyPeriod = GUICtrlCreateButton(".", 740, 440, 50, 40) ;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 ($main) ;Focuses on the GUI window GUICtrlSetState ($txtSearch, $GUI_FOCUS) ;Focuses on the Search Text Box QInit() ;Initializes the Queue ListBox While 1 $msg = GUIGetMsg() ;Get GUI messages ClearCancelState() ;Checks for input text, sets the clear/cancel button accordingly OSK($msg) $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 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() ;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() ;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) ControlSend($WSBLhandle, "", $WSBLhandle, $strInput) ;Send the whole string to JTFP's Edit Box SmartDelay() ;Necessary! Otherwise AutoIt v3 Crashes! If _GUICtrlListCount($WSLhandle)>0 Then ;If there's at least one entry, SInit() ;Redraw the Song List $SItemsOld = $SItems ;Note changes _GUICtrlListSelectIndex($lstSongs, 0) ;Select the top one EndIf 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() ;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() $SItemsOld = $SItems ;takes note of new changes EndIf If $QItemsOld<>$QItems Then ;Checks if the queue list has been updated since QInit() SInit() ;$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() ControlSend($WSBLhandle, "", $WSBLhandle, "+{HOME}") ;Send SHIFT + HOME to the Edit Box ControlSend($WSBLhandle, "", $WSBLhandle, "{DEL}") ;Send DELETE to the Edit Box EndFunc Func ClearEC() GUICtrlSetData($txtSearch, "") ;Send nothing to Search Box, AKA Clear 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) If ($i+1)<10 then ;if $i+1 is a single digit (1 thru 9) _GUICtrlListAddItem($lstQueue, "0" & $i+1 & ") " & _ ControlListView($JFhandle, "", "SysListView321", "GetText", $i, 0)) ;ADDS the last item Else ;if $i+1 is a double digit (10 thru 99) _GUICtrlListAddItem($lstQueue, $i+1 & ") " & _ ControlListView($JFhandle, "", "SysListView321", "GetText", $i, 0)) ;ADDS the last item EndIf 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: Local $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 _GUICtrlListSelectIndex($lstSongs, 0) ;Select the top entry in the list ;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($main) EndFunc Func OSK(ByRef $k) ;First type to Winamp's JTF search box ;Then type to the txtSearch Select Case $k = $keyQ $s="Q" SendKey($s) Case $k = $keyW $s="W" SendKey($s) Case $k = $keyE $s="E" SendKey($s) Case $k = $keyR $s="R" SendKey($s) Case $k = $keyT $s="T" SendKey($s) Case $k = $keyY $s="Y" SendKey($s) Case $k = $keyU $s="U" SendKey($s) Case $k = $keyI $s="I" SendKey($s) Case $k = $keyO $s="O" SendKey($s) Case $k = $keyP $s="P" SendKey($s) Case $k = $keyA $s="A" SendKey($s) Case $k = $keyS $s="S" SendKey($s) Case $k = $keyD $s="D" SendKey($s) Case $k = $keyF $s="F" SendKey($s) Case $k = $keyG $s="G" SendKey($s) Case $k = $keyH $s="H" SendKey($s) Case $k = $keyJ $s="J" SendKey($s) Case $k = $keyK $s="K" SendKey($s) Case $k = $keyL $s="L" SendKey($s) Case $k = $keyZ $s="Z" SendKey($s) Case $k = $keyX $s="X" SendKey($s) Case $k = $keyC $s="C" SendKey($s) Case $k = $keyV $s="V" SendKey($s) Case $k = $keyB $s="B" SendKey($s) Case $k = $keyN $s="N" SendKey($s) Case $k = $keyM $s="M" SendKey($s) Case $k = $keyComma $s="," SendKey($s) Case $k = $keyHyphen $s="-" SendKey($s) Case $k = $keySpace $s=" " SendKey($s) Case $k = $keyBackspace $s="{BACKSPACE}" SendKey($s) Case $k = $key0 $s="0" SendKey($s) Case $k = $keyPeriod $s="." SendKey($s) EndSelect EndFunc Func SendKey(ByRef $str) If ControlGetText($WSBLhandle,"",$WSBLhandle)<>GUICtrlRead($txtSearch) Then ;Copied over from Case $msg = $btnEnter $strInput = GUICtrlRead($txtSearch) ClearJF() ;Quickly clear the list (in case backspaces was used) ControlSend($WSBLhandle, "", $WSBLhandle, $strInput) ;Send the whole string to JTFP's Edit Box SmartDelay() ;Necessary! Otherwise AutoIt v3 Crashes! EndIf ControlSend($WSBLhandle, "", $WSBLhandle, $str) ;Send Key to JTFP's Edit Box If StringLen($str)>1 Then ;If $str is BackspaceKey, etc. GUICtrlSetState ($txtSearch, $GUI_FOCUS) ;Focuses on the Search Text Box Send("{END}") ;De-select the text Send($str) ;Less Accurate Else GUICtrlSetData($txtSearch, GUICtrlRead($txtSearch) & $str) ;Send key to Search Box -- More Accurate EndIf If _GUICtrlListCount($WSLhandle)>0 Then ;If there's at least one entry, SInit() ;Redraw the Song List $SItemsOld = $SItems ;Note changes ;MsgBox(0,"CHECK:",_GUICtrlListCount($WSLhandle)) ;_GUICtrlListSelectIndex($lstSongs, 0) ;Select the top entry in the list EndIf EndFunc #comments-start Func SendBackspace() $str = "{BACKSPACE}" If ControlGetText($WSBLhandle,"",$WSBLhandle)<>GUICtrlRead($txtSearch) Then ;Copied over from Case $msg = $btnEnter $strInput = GUICtrlRead($txtSearch) ClearJF() ;Quickly clear the list (in case backspaces was used) ControlSend($WSBLhandle, "", $WSBLhandle, $strInput) ;Send the whole string to JTFP's Edit Box SmartDelay() ;Necessary! Otherwise AutoIt v3 Crashes! If _GUICtrlListCount($WSLhandle)>0 Then ;If there's at least one entry, SInit($SItems) ;Redraw the Song List $SItemsOld = $SItems ;Note changes _GUICtrlListSelectIndex($lstSongs, 0) ;Select the top one EndIf EndIf ControlSend($WSBLhandle, "", $WSBLhandle, $str) EndFunc #comments-end ;Func KeyEnter() ; MsgBox(0,"$msg",$msg) ;EndFunc ;Func KeyEsc() ; MsgBox(0,"$msg",$msg) ; ;MsgBox(0,"",GUICtrlGetState($btnClear)) ;EndFunc