Jump to content
Sign in to follow this  
JoeyJoeJOe

Send Windows Messages?

Recommended Posts

Hi,

I'm currently trying to write a script that will remotely tell winamp to do stuff (pause,start,stop etc.). I've got a client/server script going that works fine and will allow me to execute whatever i want on the remote computer and have global hotkeys set up linked to the functions i want to peform (ctrl+alt+c to pause for example).

Anyway the problem occurs when i try and do Send("^!c") on the remote machine. See i'm using synergy to use the same keyboard/mouse over two computers, so when i run my script on the local computer (the one that has the keyboard/mouse control) it tells the other computer two run Send("^!c") which it does. However synergy then of course hijacks the keypresses and sends them back to the computer on which it was triggered.

Anyway winamp doesn't have any controls that i can use the ControlSend() function with to do what I want, so what i need to do is directly send a windows message to winamp itself, thereby bypassing synergy.

Sorry if this explanation is hard to follow. Essentially what i need is a way to directly send a windows message, possible some kind of DLL call?

Thanks.

Share this post


Link to post
Share on other sites

Have you tried sending these keys?

{VOLUME_MUTE} 2000/XP Only: Mute the volume

{VOLUME_DOWN} 2000/XP Only: Reduce the volume

{VOLUME_UP} 2000/XP Only: Increase the volume

{MEDIA_NEXT} 2000/XP Only: Select next track in media player

{MEDIA_PREV} 2000/XP Only: Select previous track in media player

{MEDIA_STOP} 2000/XP Only: Stop media player

{MEDIA_PLAY_PAUSE} 2000/XP Only: Play/pause media player

{LAUNCH_MEDIA} 2000/XP Only: Launch media player

Are they suitable?

Share this post


Link to post
Share on other sites

They might be, but the problem is any keypresses simulated by the send() command will be intercepted by synergy and sent to the wrong computer.

Share this post


Link to post
Share on other sites

Try using ControlSend with an empty control name:

ControlSend('Winamp', '', '', '^!c')
I'm not sure if that works (also check the window name, I have no idea how the winamp window is called), but it's worth a try.

Share this post


Link to post
Share on other sites

Try using ControlSend with an empty control name:

ControlSend('Winamp', '', '', '^!c')
I'm not sure if that works (also check the window name, I have no idea how the winamp window is called), but it's worth a try.

<{POST_SNAPBACK}>

I successfully used this:

ControlSend('Winamp', '', '', 'x')

To "press" the Play button.

Share this post


Link to post
Share on other sites

Well i'm an idiot (wasn't capitalizing w in winamp) that works now. Thanks for the help.

I don't suppose there is a way to directly send windows messages asside from this just out of interest? For example the following should turn off all monitors.

Msg|Progman|274|61808|2

Edited by JoeyJoeJOe

Share this post


Link to post
Share on other sites

Heh, neat... I just tried that with the DllCall SendMessage function and shut off my monitor. I'll have to remember this.

$WM_SYSCOMMAND = 274
$SC_MONITORPOWER = 61808

Opt('WinTitleMatchMode', 4)
$hwnd = WinGetHandle('classname=Progman')
DllCall('user32.dll', 'int', 'SendMessage', 'hwnd', $hwnd, 'int', $WM_SYSCOMMAND, 'int', $SC_MONITORPOWER, 'int', 2)

There you go.

*Edit: I found some information. MSDN

Edited by Saunders

Share this post


Link to post
Share on other sites

$WM_SYSCOMMAND = 274
$SC_MONITORPOWER = 61808

Opt('WinTitleMatchMode', 4)
$hwnd = WinGetHandle('classname=Progman')
DllCall('user32.dll', 'int', 'SendMessage', 'hwnd', $hwnd, 'int', $WM_SYSCOMMAND, 'int', $SC_MONITORPOWER, 'int', 2)

Great tool, but it only shuts off the monitor for 1 sec or so, can you control when you want it to turn on again? :lmao:

Share this post


Link to post
Share on other sites

The monitor is only turned on again when you move the mouse or press a key. Or if a function to turn on the monitor is called.

Share this post


Link to post
Share on other sites

That's weird. Perhaps there's something else running on the computer that resets the idle time.

On a related note, if anyone finds a way (via DLL, or other means) to turn off the harddrives (like in the power settings) that would be great. On my old computer, the harddrive is loud while it's spinning, and it'd be great if I could manually stop it spinning when I want to.

Share this post


Link to post
Share on other sites

Im sitting at a Win2k Computer, and if i run the script, and not tuchting anything, it will still just turn off for about 2 sec:S

I think Saunders is right.Some program is resetting the idle time, or your mouse sends events even if it's not moved. Or, your monitor doesn't support power saving. At least these are the possibilities I can think of right now.

Share this post


Link to post
Share on other sites

I had the same problem as WB-Freekill when sending that message through hoekey, I solved it by placing a sleep|1000 command before the message is sent. I see no reason why it wouldn't work the same in autoit.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...