#PB_Shortcut_PlayPause and other media/special keys!

Share your advanced PureBasic knowledge/code with the community.
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

#PB_Shortcut_PlayPause and other media/special keys!

Post by Rescator »

Code updated For 5.20+

I just noticed that AddKeyboardShortcut() on windows actually accept most (if not all) VK_ key codes.

So if you ever wanted to handle those nifty Play, Pause, Next Track, Previous Track, Mute, Volume up, Volume Down keys and so on.
This is how to do that:

Code: Select all

#PB_Shortcut_NextTrack=$B0
#PB_Shortcut_PrevTrack=$B1
#PB_Shortcut_Stop=$B2
#PB_Shortcut_PlayPause=$B3
It's that simple, just define the missing constants and you can do things like this:

Code: Select all

AddKeyboardShortcut(#Window,#PB_Shortcut_NextTrack,#NextTrack)
AddKeyboardShortcut(#Window,#PB_Shortcut_PrevTrack,#PrevTrack)
AddKeyboardShortcut(#Window,#PB_Shortcut_Stop,#Stop)
AddKeyboardShortcut(#Window,#PB_Shortcut_PlayPause,#PlayPause)
The full list can be found at:
http://msdn.microsoft.com/library/defau ... ycodes.asp
and also in the latest PSDK if you have that!

It's that easy, so now you have no excuse any more to not support "special" keys! :)
Gansta93
Enthusiast
Enthusiast
Posts: 238
Joined: Wed Oct 20, 2004 7:16 pm
Location: The Village
Contact:

Post by Gansta93 »

Fred, don't you want to add it? It would be good... I'va asked me this question and found this post. :-D
Be seeing you! :-)

Gansta93
If you speak french, you can visite Le Monde de Gansta93 (Gansta93's World)
Post Reply