This App is No Longer Maintained. Visit the Replacement at StrokesPlus.net

StrokesPlus Forum
                       
StrokesPlus Forum
Home | Profile | Active Topics
Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General Discussion
 General Discussion
 acActiveWindow issue
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

dizluk

Korea
11 Posts

Posted - 03/13/2013 :  02:30:32  Show Profile
Hello superman!!


I make a gesture(Global Action).
-----------------------------------------------------------------------------------
C / Close / acSendKeys("%{F_4}")
-----------------------------------------------------------------------------------

After that, I would send keys to an inactive window. so I modified Lua:
-----------------------------------------------------------------------------------
function sp_before_action(gnm, gsx, gsy, gex, gey, gwd, gapp, gact)
-- this code is fired before each action (excluding hotkey actions)
acActivateWindow(nil, gsx, gsy)
end
-----------------------------------------------------------------------------------

But It dosen't work at "Run(Win+R)", whole file and icon's properties menu and etc..
It is operated normally before I modified Lua.

How can I fix it?

Sorry for my terrible English... thankyou!

helloooooo!

Edited by - dizluk on 03/13/2013 02:31:31

Rob

USA
2615 Posts

Posted - 03/13/2013 :  09:17:03  Show Profile  Visit Rob's Homepage
You can try this:

acActivateWindow(acGetParentWindowByPoint(gsx, gsy), nil, nil)

Some windows are weird about where the handler is that processes certain messages. There is a good chance this will work fine for all windows, but if not, you might need to get more complex in the sp_before_action script, using functions like acGetWindowTitle and/or acGetClassName to determine how best to handle activating certain windows.
Go to Top of Page

dizluk

Korea
11 Posts

Posted - 03/13/2013 :  13:07:31  Show Profile
Amazing.. You are my hero!

helloooooo!
Go to Top of Page

Chris

28 Posts

Posted - 03/16/2013 :  23:49:09  Show Profile
Hello, there..

I just want to add something here, related to the topic.

I realized that Autoit scripting language has a command called ControlSend.
Basically, it allows user to send key to an inactive window.
http://www.autoitscript.com/autoit3/docs/functions/ControlSend.htm

Just thought it might be useful if StrokePlus has this command. This allows users to not activate the window when they want to send keys. Activating window might gives some users problem with how they works.

EDIT:
After checking AutoIt forum, I believe the AutoIt's ControlSend uses SendMessage or PostMessage to send keystrokes on inactive window. Unfortunately, I have not been able to do it using Lua Script.
acPostMessage(acGetOwnerWindowByPoint(gsx, gsy), 258, "{F11}", nil)

Edited by - Chris on 03/17/2013 12:53:40
Go to Top of Page

Rob

USA
2615 Posts

Posted - 03/17/2013 :  13:39:20  Show Profile  Visit Rob's Homepage
Correct, you'd need to setup the necessary messages. Using the acSendKeys verbiage will not work ("{F11}"). To be honest, it is kind of a pain to do that (certainly possible, of course), but I don't think I'm currently interested in writing all of that code as most people don't seem to need it. Additionally, it's VERY inconsistent, meaning you really need to know exactly which window handle (a standard app will have dozens or hundreds of window/control handles) is the one that needs to receive the message. Adding the functionality to S+ as a canned feature would likely result in far too many people complaining it's not working or me having to spend a lot of time, hand-holding each case. It's really only something that a very advanced person should be attempting.

It can certainly be accomplished in S+, all within Lua code, as all you have to do is send the correct messages to the correct window handle, in the correct sequence (including delays). However, it can get pretty complicated, and what will work with one application, will often need to be handled differently for another; this is, again, why I don't want it as a standard S+ feature. S+ is already complicated enough for a average person without scripting experience, opening up that door will really make things a mess from a support perspective.

You could absolutely create some global functions in the Global Lua tab which contain all of the necessary logic and call it from action scripts, e.g. make a acSendKeysIndirect(window, "keys") [or something]. If you do, by all means please post it to the forum so others can use it too!

I'm in the middle of several big life events at the moment, so I simply do not have the time to put something together, even just to get you started. In a few months, I may have some time and post it in the scripts forum (or maybe forum member breakcore has already done it, hint hint ).

In the end, yes you totally can accomplish it with the current release of S+, but it will be a real pain to implement and will need a lot of tweaking to function consistently across apps.

Here's a post that touches on sending key srokes using Windows messages:
http://www.strokesplus.com/forum/topic/339/closed-acsendmessage-error-sending-lparam

Another on posting messages for mouse wheel events with key modifiers (not what you're looking for, but still works with sending messages):
http://www.strokesplus.com/forum/topic/469/ctrlwheel-up-impossible-with-lua

Go to Top of Page

Rob

USA
2615 Posts

Posted - 03/17/2013 :  13:41:54  Show Profile  Visit Rob's Homepage
..and the Microsoft documentation on the various messages required (in their typically required sequence):

WM_KEYDOWN
WM_CHAR
WM_KEYUP

Go to Top of Page

Chris

28 Posts

Posted - 03/17/2013 :  17:20:39  Show Profile
Actually, I was thinking to combine StrokePlus with AutoIt as I know a bit more AutoIt commands than Lua.
Use acSendMessage WM_COMMAND so StrokePlus can communicate with AutoIt script.
When the script received SendMessage from StrokePlus, it will get the control or window below the cursor and send keystrokes that the user defined in acSendMessage.

Example:
acSendMessage(acFindWindowByTitleRegex("StrokePlus_Autoit"), 273, wParam, lParam)
wParam: information whether the keystroke(s) will be send to a control or to the parent window
lParam: the keystroke(s)
The problem (on my initial test) was that the parameter (lParam) could only be interger. It means that I have to define all the keystrokes combination.

However, after reading the links you gave me, apparently it's just about <keyDown> <char> <keyUp>. I think I might try to do this in Lua alone as I don't need to have additional exe running.

Thank you again and good luck with the big events, hope everything works the best for you.
Go to Top of Page
  Previous Topic Topic Next Topic  
 Forum Locked
 Printer Friendly
Jump To:
StrokesPlus Forum © 2011-2018 Rob Yapchanyk Go To Top Of Page
Snitz Forums 2000