Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[::winamp::] again ;-)


  • Please log in to reply
1 reply to this topic
wOxxOm
  • Members
  • 371 posts
  • Last active: Feb 20 2015 12:10 PM
  • Joined: 09 Feb 2006
If you don't like timers set at too much close space then maybe you will like the idea of getting song length/current-time then setting timer to length of remainder of song. Useful if you don't switch songs or switch them only through AHK keys, or in unattended mode.
Code that gets title through readProcessMemory is optional, you can read winamp title (only if it doesn't scroll ;-) through standard AHK commands.
Somewhat new feature - script show first 10 seconds running then traytip disappears. Same is for fast rewinding through keyboard control if you add call to "getWinampTitleFunc(1)" to your code.

setTimer,getWinampTitleTimer,1000 ; initial run

getWinampTitleTimer:
   getWinampTitleFunc()
   return

; set "forceShow" to 1 if you call it from winamp-controlling functions in AHK. This will show current pos/trackLength & song name.
getWinampTitleFunc(forceShow=0)                   ;;
{  static oldTitle,showCount,trackLastShowPos
   DetectHiddenWindows, on
   ifWinNotExist, ahk_class Winamp v1.x
   {  setTimer,getWinampTitleTimer,10000
      return
   }
   winGet,wa_pid,pid
   sendmessage,0x400,0,125    ; IPC_GETLISTPOS 125
      pl#:=errorlevel
   sendmessage,0x400,pl#,212  ; IPC_GETPLAYLISTTITLE 212 char *name=SendMessage(hwnd_winamp,WM_WA_IPC,index,IPC_GETPLAYLISTTITLE);
      title#:=errorlevel
   ProcessHandle:=DllCall("OpenProcess",int,24, char,0, uint,wa_pid)    ;PROCESS_VM_OPERATION | PROCESS_VM_READ
      varSetCapacity(title,256,0)
      dllCall("ReadProcessMemory",uint,processHandle, uint,title#, str,title, uint,256, uintP,len)
      DllCall("CloseHandle", uint, ProcessHandle)
   sendmessage,0x400,1,105 ; IPC_GETOUTPUTTIME 105 (1=track len in secs)
      trackLen:=errorlevel*1000
   sendmessage,0x400,0,105 ; IPC_GETOUTPUTTIME 105 (0=track pos in ms)
      trackPos:=iif(errorlevel>trackLen,0,errorlevel)
   showCount ++
   if (title<>oldTitle) or forceShow
   {  oldTitle:=title
      showCount:=0
      setTimer,getWinampTitleTimer,1000
   }
   else if (showCount>10)
   {  traytip
      setTimer,getWinampTitleTimer,% trackLen-trackPos+1000
      return
   }

   traytip,,% title " - " formatSeconds(trackPos/1000) " / " formatSeconds(trackLen/1000)
      . iif(trackLastShowPos=trackPos," [STOPPED]"," [PLAY]")
   trackLastShowPos:=trackPos
}
formatSeconds(sec)                     ;;
{  sec:=floor(sec)
   return iif(floor(sec/3600),floor(sec/3600) ":","")
            . mod(floor(sec/60),60) ":" strMid(100+mod(sec,60),2)
}
iif(expr, a, b)                            ;;
{
   if (expr)
      return a
   else
      return b
}
strMid(s, begin, n=0x7FFF, Left=0) ; if L<>0 then mid to the left  ;;
{
   if Left=0
      stringMid,s,s,%begin%,%n%
   else
      stringMid,s,s,%begin%,%n%,L
   return s
}


wOxxOm
  • Members
  • 371 posts
  • Last active: Feb 20 2015 12:10 PM
  • Joined: 09 Feb 2006
Maybe you know the situation: you olisten to good music in new collection and abruptly some awful song gets into your mind and is ready to spoil you again and again till you delete it from disk.
Now you don't need to browse folders and delete manually. The magic of autohotkey is at guard of you pleasure ;-) Just press a key, answer Yes and voila - annoying crap is gone, next song is playing.
Bind this func to whatever you like. I have this: #!NumpadDel
Tested with winamp 2.95. I think this will work with v5 also.

winampDelSong()                         ;;
{
   DetectHiddenWindows, on
; write playlist to disk and fetch current playlist song index
   SendMessage,0x400,0,120,,ahk_class Winamp v1.x
   songNum := Errorlevel+1
   if ErrorLevel = FAIL
      return
   plLine=0
   Loop, read, %ProgramFiles%\Winamp\winamp.m3u
   {  if (instr(A_LoopReadLine,"#EXT")<>1)
         plLine ++
      if (plLine=songNum) and (waSong="")
          waSong:=A_LoopReadLine
      if (plLine=songNum+1) and (waNext="")
      {  waNext:=A_LoopReadLine
         break
      }
   }
   MsgBox, 1, Confirm delete, Delete track (%songNum%) %waSong% ?, 10
   ifMsgbox, OK
   {
      if (waNext<>"")
         PostMessage,0x111,40048,,,ahk_class Winamp v1.x ; next
      else
           PostMessage,0x111,40047,,,ahk_class Winamp v1.x ; stop
      sleep,50
      fileDelete, %waSong%
      if (ErrorLevel = 1)
      {
         FileSetAttrib, -RHS, %waSong%
         if (ErrorLevel > 0)
              msgbox, delete failed`nattrib clearing failed...
         else
         {
            fileDelete, %waSong%
            if (ErrorLevel = 1)
                 msgbox, Delete failed...
         }
      }
   }
   ; insert here call to show new playing song
   ; sleep,200
   ; getWinampTitleFunc(1) ; from first post
   return
}