PDA

View Full Version : Utility: SendMessage v2.2


Opus4
06-05-2004, 12:10 AM
The SendMessage utility has been upgraded to version 2.2, now allowing multiple messages to be sent to multiple windows with the ability to enclose parameters with spaces in quotes. Version 1 had to be run once for each message sent; v2 can have all messages included as command line parameters to a single run of the exe. This enables 'batching' message commands to have SageTV perform an operation or go to a specific menu when neither of those options are available through a single message command.

Example:
SendMessage.exe -C SageApp -N SageWin -m 1258 -W 0 42 56 4 4 4 20

This command sends 6 messages to SageTV, resulting in arriving at the "Archived shows recorded with SageTV" menu.

For SageTVClient, use SageClientApp instead of SageApp.

For more info on the messages available for SageTV, see the complete list of all SageTV Commands in the SageTV Commands section of the PDF manual in your SageTV directory. (p. 192 for v4.1)

If you are using the Hauppauge remote and its irremote.ini file to control SageTV, then you do not need this utility; see SendMsg() in updated Hauppauge IR software

SageTV v4.1 currently ships with SendMessage v2.2.

11-22-05, new for v2.1
The ability to enclose parameters with spaces in quotes, such as the WindowClassName and WindowName parameters, -C and -N.

12-03-05, new for v2.2
The usage dialog is only shown if no parameters are used, an incorrect parameter is used, or an incomplete set of parameters is used such that no attempt was made to send a messsage.
At exit, the program returns the number of messages sent, or -1 if there was an error.


- Andy

Note: This utility should already be in your SageTV install directory.

dooferlad
11-06-2005, 04:18 PM
I was hoping to put together a quick network encoder for my digital TV card (no BDA drivers for it yet) based on SendMessage.exe. Unfortunately the window name is "DigiTV - ", which makes SendMessage throw up the usage window. Is there any way of geting it to search for a window with a space in the window name, or just any window of the specified class?

Thanks

Opus4
11-07-2005, 12:07 AM
Unfortunately the window name is "DigiTV - ", which makes SendMessage throw up the usage window. Is there any way of geting it to search for a window with a space in the window name, or just any window of the specified class?You can try v2.1, attached below. I changed the way it parses the parameters, so you can place any of them in quotes now. (This attachment will be removed after this test. Once I'm fairly sure that the updated version is working satisfactorily, I will post it elsewhere.)

- Andy

dooferlad
11-07-2005, 03:46 AM
Thanks Andy - I will give it a go this evening.

fafurd
11-21-2005, 07:06 PM
I'm trying to use this utility on the command line to close winamp, but I always get the help dialog. This is what I'm trying to send:

sendmessage -C "BaseWindow_RootWnd" -N "Winamp 1.x" -M 16 -W 0

I think I have the class name and windowname correct, but not sure. If the class and window names are incorrect, what does it do? Could this be my problem?

Opus4
11-21-2005, 07:36 PM
Which version of SendMessage are you trying? I removed v2.1 above, since the other person decided not to use it & I haven't tested further with it. v2.0 will not work with quotes or spaces in the window/class names.

- Andy

fafurd
11-21-2005, 09:33 PM
Ah, that's probably my problem. I'm trying to use 2.0. Would it be a lot of work to change to allow spaces? If you don't have the time, could I get the source so I can add it?

Opus4
11-21-2005, 10:36 PM
Attached to this post is v2.1 again. If you try it out, please let me know how it works with quoted parameters containing spaces...

If I get no feedback, I'll be removing it again in a day or so.

If you tell me that it works, I'll remove the attachment & make v2.1 generally available elsewhere.

- Andy

fafurd
11-21-2005, 11:40 PM
Well, I'm still having problems. I'm sure it works, but I'm not sure what I'm doing wrong. I'm just trying to close winamp using the following.

sendmessage -C "BaseWindow_RootWnd" -N "Winamp 1.x" -M 16 -W 0

I also tried -> sendmessage -C "BaseWindow_RootWnd" -N "Winamp 5.112" -M 16 -W 0

and still no luck; it just keeps giving me the help dialog box. I'm also using spy++ to get the window name and class name.

In what cases will the help dialog appear?

Cheers and thanks for the help.

Opus4
11-22-2005, 12:28 AM
The usage dialog appears if there are no parameters, an unrecognized parameter, or no message was sent for whatever reason... of course, I never added code to explain which of those conditions occurred.

Anyway: please read the usage dialog a little more closely; you are missing the lParam parameter, since it wasn't specified directly with the -L parameter or indirectly as another number at the end of the list. So, you are getting a valid dialog that is trying to point out the usage. ;)

If it still doesn't work after that, then either there is a problem with the window and/or class names, or my changes to allow quoted params isn't working correctly.

- Andy

fafurd
11-22-2005, 11:24 AM
Well, still having problems with winamp, so I decided to try something simpler (notepad) and was successful issuing the WM_CLOSE with the spaces in the WindowName.

sendmessage -N "Untitled - Notepad" -C Notepad -M 16 0 0

This tells me that maybe I have the incorrect WindowName or ClassName...or something.

Thanks. I'll continue looking into my specific issue, but it appears to be working. :)

Edit:
I just figured it out. I thought the classname was the windowname and vis versa...ugh. Here they are for windows media and winamp.

Winamp: sendmessage "Winamp v1.x" "Winamp 5.11" 16 0 0
Windows Media Player: sendmessage "WMPlayerApp" "Windows Media Player" 16 0 0

Opus4
11-22-2005, 01:10 PM
Thanks for letting me know it works. :) I gave the SendMessage discussion its own thread now, with v2.1 available in the first post.

- Andy

fafurd
11-22-2005, 10:57 PM
Actually, If I can make another request.

Instead of displaying the parameter dialog box when the sendmessage fails (not because of bad params), have it just not do anything and maybe just return a dos type return code. The help dialog should probably be only reserved for poorly fomatted commands. The reason I ask is that I occasionally send a blind message, but the window may or may not be available and that's okay. The problem now is that it pops up the help dialog when the window is not available.

Opus4
11-22-2005, 11:12 PM
I can do something like that and/or add a 'quiet' option to never display the usage dialog -- but it will have to wait several days. Not much will get done around here over Thanksgiving. :)

- Andy

fafurd
11-22-2005, 11:21 PM
That would be great. I'm not in a hurry as I'll be just as busy. :)

Opus4
12-02-2005, 11:44 PM
Now that Thanksgiving has been over for at least a couple days, I promptly got back to updating this program; see the first post for the download. Changes:

12-03-05, new for v2.2
The usage dialog is only shown if no parameters are used, an incorrect parameter is used, or an incomplete set of parameters is used such that no attempt was made to send a messsage.
At exit, the program returns the number of messages sent, or -1 if there was an error.

- Andy

fafurd
12-05-2005, 11:01 AM
Great, I'll give it a try tonight.

DCipher
02-14-2006, 10:54 AM
OK, I'm a bit frustrated now... i can't seem to get Sage to respond to any messages. I've tried from Girder using the SendMessage plugin (Message number 1258, wparam 0, lparam 5 for example) and from SendMessage (2.2) with no luck.

Do i need to configure anything in sage to listen for windows messages?

I'm trying something very simple, just trying to use "down" a bunch of times... no luck:

SendMessage -C SageApp -N SageWin -m 1258 -W 0 5 5 5

Nothing.

I'm running sage 4.1.4 w/ the latest SageMCE 16x9 STV.

TIA,
Jeff

Opus4
02-14-2006, 11:41 AM
Is this for a client? If so you have to use SageClientApp instead of SageApp.

There isn't anything to configure inside SageTV. If it gets a command that it knows how to respond to, it will do so.

- Andy

DCipher
02-14-2006, 01:09 PM
It's for server... actually, i rebooted my machine and now SendMessage is working fine. I think something got messed up by Girder.

Girder is not working properly. Not sure why. Time to head over to the girder forums!

Thanks

Henki
02-27-2006, 10:35 AM
hi
I've got a small problem with sendmessage.

I use Nielm's "Dynamic Customizable Main Menu” and have made a button within sage that sends a message to Meedio to grab focus. I've tried to do this with SendMessage 2.2, but because I don't have Meedio's window name the arguments are:

sendmessage.exe -C H2-WM-COMMAND -N "" -M 273 -W 45 -L 0

This works great with a batch file. But this doesn't work in an xml file because of the quotes.

Is the any way I can use something else than the quotes. Preferably nothing...

DCipher
02-27-2006, 10:53 AM
Have you tried using " in your xml file?

hi
I've got a small problem with sendmessage.

I use Nielm's "Dynamic Customizable Main Menu” and have made a button within sage that sends a message to Meedio to grab focus. I've tried to do this with SendMessage 2.2, but because I don't have Meedio's window name the arguments are:

sendmessage.exe -C H2-WM-COMMAND -N "" -M 273 -W 45 -L 0

This works great with a batch file. But this doesn't work in an xml file because of the quotes.

Is the any way I can use something else than the quotes. Preferably nothing...

Henki
02-27-2006, 01:45 PM
Have you tried using " in your xml file?

Thanks!! it worked :thumb:

Henrik

dabrosca
12-26-2007, 09:45 PM
Hello,

I've successfully created a script utilizing send message to toggle full screen mode, even if Sage does not have focus. Unfortunately, if Sage is minimized my script does not successfully run. Does anyone have any recommendations on how to utilize sendmessage to restore a minimized window, such that I can then toggle full screen off and on (or take any other required action)?

Thanks,
Dave

Paul H
03-23-2008, 09:13 AM
Maybe I'm missing the obvious but, how do you determine which client to send to? :confused:
I have two clients setup but only want to send to the one in the bedroom.

TNX in advance,

Paul H

Opus4
03-23-2008, 12:34 PM
Maybe I'm missing the obvious but, how do you determine which client to send to? :confused:
I have two clients setup but only want to send to the one in the bedroom.I'm not sure I understand... are you trying to control a client on another computer? This program only sends Windows messages to another program on the same Windows computer where the utility is running.

- Andy

Paul H
03-23-2008, 02:52 PM
OooooKay, Now I get it. :bang:
I'm looking for a way to use the FM radio plugin on my Bedroom client as an alarm clock. I can set HomeSeer to send command at any time or day. I was hoping that this might work. Oh well, thanks for the fast reply.:)

Paul H

UFGrayMatter
08-10-2008, 08:22 PM
Has something changed w/ the latest Beta and SendMessage?? I'm getting an error now.

Opus4
08-10-2008, 09:42 PM
What's the error? It worked fine for me when I tested it a couple minutes ago.

- Andy

UFGrayMatter
08-10-2008, 09:43 PM
What's the error? It worked fine for me when I tested it a couple minutes ago.

- Andywell - i did some more testing and it seems ok. For a little while I was getting the SendMessage dialog box saying the arguments were wrong