AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Windows Media Player - Play random song

 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Falco



Joined: 01 Jan 2005
Posts: 10

PostPosted: Sun Jan 02, 2005 2:04 pm    Post subject: Windows Media Player - Play random song Reply with quote

I've looked at alot of the scripts here and I think there isn't enough about WMP.

Anyways. Just a lil script I made up. I know it isn't very technical or anything but it does what i want it to:
Plays a random song if you press Numpad plus key. If WMP isn't open it will open, play then minimise. If its open it will play the next song. To play a random one you may need to turn Shuffle on CTRL - H.
It probably isn't stable but atm it does what I want it to. Any suggestions would be nice.

Code:

NumpadAdd::
IfWinExist, Windows Media Player
{
        WinActivate
        send, {ALT}PP
        send, {ALT}PN
        sleep, 1000
        WinMinimize, Windows Media Player
}
else
{
        Run, C:\Program Files\Windows Media Player\wmplayer.exe
        WinActivate
        sleep, 1000
        Send, {ALT}PP
        send, {ALT}PN
        sleep, 2000
        WinMinimize, Windows Media Player
}
return


BTW - I seem to be having trouble sending control virtual keys to it like:
send {CTRL}H
It dosn't seem to work. Any ideas?


Last edited by Falco on Sun Jan 02, 2005 2:34 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
BoBo
Guest





PostPosted: Sun Jan 02, 2005 2:31 pm    Post subject: Reply with quote

Code:
sned, {ALT}PP


Guess that's a typo, isn't it Wink
Back to top
Falco



Joined: 01 Jan 2005
Posts: 10

PostPosted: Sun Jan 02, 2005 2:34 pm    Post subject: Reply with quote

Yeah, ill change it, i switched some things round before posting it...

Last edited by Falco on Sun Jan 02, 2005 2:35 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
BoBo
Guest





PostPosted: Sun Jan 02, 2005 2:35 pm    Post subject: Reply with quote

Quote:
{CONTROL} or {CTRL} CONTROL (sends the neutral virtual key but the left scan code)


Quote:
'^'
Sends a CONTROL keystroke, therefore Send, ^!a would send "CTRL+ALT+a".


Both taken from AHK's help. Have you had a try with:

Code:
Send, ^H
Question
Back to top
Falco



Joined: 01 Jan 2005
Posts: 10

PostPosted: Sun Jan 02, 2005 2:36 pm    Post subject: Reply with quote

Yeah i have, that dosn't work either...
Back to top
View user's profile Send private message Send e-mail
BoBo
Guest





PostPosted: Sun Jan 02, 2005 2:40 pm    Post subject: Reply with quote

Quote:
{LCONTROL} or {LCTRL} Left CONTROL key (same as CONTROL for Win9x, but on NT/2k/XP it sends the left virtual key rather than the neutral one)


As you havn't mentioned the OS you use ...
Back to top
Falco



Joined: 01 Jan 2005
Posts: 10

PostPosted: Sun Jan 02, 2005 2:42 pm    Post subject: Reply with quote

Sorry iam using Windows XP SP2
Back to top
View user's profile Send private message Send e-mail
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10716

PostPosted: Sun Jan 02, 2005 9:09 pm    Post subject: Reply with quote

Note that "Send ^H" will actually send Control+Shift+h since the "H" is capitalized. Some apps might not recognize that as being Ctrl+h.
Back to top
View user's profile Send private message Send e-mail
Falco



Joined: 01 Jan 2005
Posts: 10

PostPosted: Sun Jan 02, 2005 9:37 pm    Post subject: Reply with quote

no, still dosn't work.
Back to top
View user's profile Send private message Send e-mail
savage



Joined: 02 Jul 2004
Posts: 207

PostPosted: Tue Jan 04, 2005 8:38 pm    Post subject: Reply with quote

Try SetKeyDelay 1. If it's 0 or -1 sometimes certain programs won't catch the modifiers - shift, control, etc. I ran into this problem with console windows. Maybe that's the problem here.
Back to top
View user's profile Send private message AIM Address
MYYM
Guest





PostPosted: Mon Jan 24, 2005 11:20 pm    Post subject: Re: Windows Media Player - Play random song Reply with quote

Quote:

BTW - I seem to be having trouble sending control virtual keys to it like:
send {CTRL}H
It dosn't seem to work. Any ideas?


Hi, try this

Send, {CTRLDOWN}h{CTRLUP}
Back to top
Soldier3570



Joined: 30 Aug 2006
Posts: 10

PostPosted: Thu Sep 21, 2006 6:45 am    Post subject: Reply with quote

the code will then look like this if you want to copy and paste....

Code:

IfWinExist, Windows Media Player
{
     WinActivate, Windows Media Player
     Sleep, 2000
     Send, {ALTDOWN}PP{ALTUP}
     Sleep, 1000
     WinMinimize, Windows Media Player
}
else
{
     Run, C:\Program Files\Windows Media Player\wmplayer.exe
     Sleep, 2000
     WinActivate, Windows Media Player
     Send, {ALTDOWN}PP{ALTUP}
     Sleep, 1000
     WinMinimize, Windows Media Player     
}

Return
       


its based along the same lines as yours... except it just plays not shuffles
Wink
_________________
Soldier3570
Back to top
View user's profile Send private message
Seclinix*
Guest





PostPosted: Mon Sep 25, 2006 11:48 pm    Post subject: Reply with quote

use this it works but it plays a cd in the drive.... if you want it to play a song in a playlist then change the two letters "PD" to suite your needs
Code:
 {ALTDOWN}PD{ALTUP}

do not change the 4 in msgbox otherwise you might get some really random box with abort, retry and cancel lol
Code:
 
MsgBox, 4,, Would you like to play a CD?
IfMsgBox, no
Return
Msgbox, 4,,Is the CD in the drive?
IfMsgBox, no
Return

Run, C:\program files\Windows Media Player\WMPlayer.exe
sleep, 2000
WinActivate, Windows Media Player
Sleep, 2000
Send, {ALTDOWN}PD{ALTUP}
return

enjoy... Surprised
Back to top
Seclinix
Guest





PostPosted: Mon Sep 25, 2006 11:50 pm    Post subject: Reply with quote

you can also change the code to load from fiels and other places...
Back to top
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group