Advertisement
euphonics

Untitled

Feb 24th, 2022
1,261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ' Command name:
  2.  
  3. <media_options> track
  4.  
  5. ' <media_options> list values:
  6.  
  7. last
  8. mute
  9. next
  10. pause
  11. play
  12. previous
  13. skip
  14. stop
  15.  
  16. ' The script:
  17.  
  18. Declare Function keybd_event Lib "user32.dll" (ByVal vKey As Long, bScan As Long, ByVal Flag As Long, ByVal exInfo As Long) As Long
  19.  
  20. Const VK_MEDIA_PLAY_PAUSE = &hB3 ' Play/Pause Media key
  21. Const VK_MEDIA_NEXT_TRACK = &hB0 ' Next Track key
  22. Const VK_MEDIA_PREV_TRACK = &hB1 ' Previous Track key
  23. Const VK_MEDIA_STOP = &hB2 ' Stop Media key
  24. Const VK_VOLUME_MUTE = &hAD ' Volume Mute key
  25.  
  26. Sub Main
  27.  
  28.     Select Case ListVar1
  29.         Case "play", "pause"
  30.             button = VK_MEDIA_PLAY_PAUSE
  31.         Case "next", "skip"
  32.             button = VK_MEDIA_NEXT_TRACK
  33.         Case "previous", "last"
  34.             button = VK_MEDIA_PREV_TRACK
  35.         Case "stop"
  36.             button = VK_MEDIA_STOP
  37.         Case "mute"
  38.             button = VK_VOLUME_MUTE
  39.     End Select
  40.    
  41.     'Hold down the key
  42.     keybd_event(button,0,0,0)
  43.     Wait 0.1
  44.     'Release the key
  45.     keybd_event(button,0,2,0)
  46.  
  47. End Sub
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement