Advertisement
Guest User

dynamic icon for foobar2000 in AutoHotkey

a guest
Feb 2nd, 2019
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
  2. #Warn  ; Enable warnings to assist with detecting common errors.
  3. SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
  4. SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
  5. #persistent
  6.  
  7. Menu,Tray,DeleteAll
  8. Menu,Tray,NoStandard
  9. Menu,Tray,Add,Open Foobar2000,openFoobar
  10. Menu,Tray,Add
  11. Menu,Tray,Add,Reload
  12. Menu,Tray,Add,Exit,EXIT
  13. Menu, Tray, Add, PlayPause, lmao
  14. Menu, Tray, Default, PlayPause
  15.  
  16. icon_play = %A_ScriptDir%\play_icon.ico
  17. icon_pause = %A_ScriptDir%\pause_icon.ico
  18. icon_stop = %A_ScriptDir%\stop_icon.ico
  19.  
  20. OnMessage(0x404, "AHK_NOTIFYICON")
  21. AHK_NOTIFYICON(wParam, lParam, uMsg, hWnd)
  22. {
  23. if (lParam = 0x201) ;WM_LBUTTONDOWN := 0x201
  24. {
  25.     Send {Media_Play_Pause}
  26. }
  27. }
  28.  
  29.  
  30.  
  31. lastFileContent := ""
  32. setTimer, checkFile, 20
  33. return
  34.  
  35. checkFile:
  36. fileread newFileContent, foobar_status.txt
  37. if(newFileContent != lastFileContent) {
  38.     lastFileContent := newFileContent
  39.     statusFoo=newFileContent
  40.     if( newFileContent = "paused")
  41.         Menu, Tray, Icon, %icon_pause%
  42.     if( newFileContent = "playing")
  43.         Menu, Tray, Icon, %icon_play%
  44.     if( newFileContent = "stopped")
  45.         Menu, Tray, Icon, %icon_stop%
  46.     if( newFileContent = "not running")
  47.         Menu, Tray, Icon, %icon_stop%
  48.  
  49. }
  50. return
  51.  
  52.  
  53.  
  54. lmao:
  55.   Send {Media_Play_Pause}
  56. Return
  57.  
  58. openFoobar:
  59.     Run, Foobar2000
  60. return
  61.  
  62. RELOAD:
  63.     Reload
  64. Return
  65. SUSPEND:
  66.     Suspend
  67. Return
  68. EXIT:
  69.     ExitApp
  70. Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement