Author |
Topic |
|
kyprios1
11 Posts |
Posted - 06/06/2012 : 07:33:36
|
Hi, first of all I want to say thank you for the time you've put in this project. I've been testing S+ over the last few days and I'm contemplaiting doing the switch from SI.
However I'm stuck with porting some actions. Specifically some SendMessage commands from Winamp.
A WM_COMMAND with a wParam of 40048 translates to Next Track command ( more here: tinyurl.com/d85kz68 ).
I tried
- acSendMessage("Winamp v1.x", WM_COMMAND, 4008, 0)
- local hWnd = acFindWindowByTitleRegex("Winamp.*")
acSendMessage(hWnd, WM_COMMAND, 40048, 0)
- local hWnd = acGetForegroundWindow()
acSendMessage(hWnd, WM_COMMAND, 40048, 0)
but failed miserably.
Can someone show me how do I do it? |
Edited by - kyprios1 on 06/06/2012 07:37:31 |
|
Rob
USA
2615 Posts |
Posted - 06/06/2012 : 08:46:29
|
(moved to General Action Scripts)
Hi!
First of all, WM_COMMAND isn't a defined variable anywhere within the Lua engine, so acSendMessage will fall back to sending a 0 in place of it. Next, I would change your find window qualifier a little so you don't catch something like a browser window that has "Winamp" in the title, although acFindWindowByTitleRegex("Winamp.*") would only match windows that began with "Winamp", but Winamp almost never has that title configuration, you'd need to use ".*Winamp.* to find a window with "Winamp" anywhere in the title. Again, I'd recommend using the regex pattern below as it would be much more reliable.
Downloaded Winamp and tested the following script myself, should work for you as well.
local WM_COMMAND = 0x111
local hWnd = acFindWindowByTitleRegex(".* - Winamp.*")
acSendMessage(hWnd, WM_COMMAND, 40048, 0) Of course, you don't really have to declare WM_COMMAND, it is simply 273, or 0x111 in hex..nor does hWnd technically need to be defined separately (I just do it for readability); so the whole script can just be one line (tested that one as well):
acSendMessage(acFindWindowByTitleRegex(".* - Winamp.*"), 273, 40048, 0)
|
|
|
Rob
USA
2615 Posts |
Posted - 06/06/2012 : 11:26:26
|
Actually, the best way to do this is via acFindWindow.. HOWEVER, prior to 1.9.3 (which I just released) back to the point where I added action parameter checking for stability purposes, S+ would not allow passing in a nil for class or title without reassigning the value to an empty string "". This results in the Windows API call (which S+ does internally) to FindWindow receiving an empty string for one of the parameters, so searching for window by class name alone, which is what you really should do here, wouldn't be possible.
The following script is what you should use (only will work properly with S+ 1.9.3 or higher):
acSendMessage(acFindWindow("Winamp v1.x",nil), 273, 40048, 0) |
|
|
kyprios1
11 Posts |
Posted - 06/06/2012 : 16:10:45
|
This is brilliant, thanks!
acFindWindow no longer requiring both classname AND title is great news, this requirement was quite restrictive.
When you get the chance, please update the Functions thread to reflect that change: http://www.strokesplus.com/forum/topic.asp?TOPIC_ID=5 |
Edited by - kyprios1 on 06/06/2012 16:20:01 |
|
|
Rob
USA
2615 Posts |
Posted - 06/06/2012 : 16:13:10
|
Right, but nil must be passed in place of the blank parameter. |
|
|
Rob
USA
2615 Posts |
Posted - 06/06/2012 : 16:23:02
|
Updated!
In the online help file as well. Will include the updated help and action help file along with the 1.9.4 release, whenever that may be. |
|
|
kyprios1
11 Posts |
Posted - 06/06/2012 : 16:46:22
|
Are you sure your name isn't Flash Gordon? Your responses are lightning fast |
|
|
Rob
USA
2615 Posts |
Posted - 06/06/2012 : 17:23:51
|
I may not get around to major features or enhancements that often nowadays, but there's no reason I can't just respond to a question right away or fix bugs when they pop up (like acFindWindow, that wasn't intended to be that way..even though I wrote the help file as such =) ).
The reason I wrote S+ was because StrokeIt was so poorly maintained and left up to the power users to help others; so I will never ignore S+ users, even if it's to say "tough shit, I don't feel like adding feature X", I'll at least let you know immediately and provide an explanation (or excuse)! |
|
|
imafishimafish
USA
19 Posts |
Posted - 06/07/2012 : 19:30:08
|
quote: Originally posted by Rob
Right, but nil must be passed in place of the blank parameter.
FYI, if you leave off a parameter, Lua passes nil for it by default. So acFindWindow("Winamp v1.x",nil) can just be acFindWindow("Winamp v1.x") |
|
|
Rob
USA
2615 Posts |
Posted - 06/07/2012 : 19:48:34
|
Yea, I was just trying not to confuse people with which parameter, the order, etc. :-P |
|
|
|
Topic |
|
|
|