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
 Script to Simulate Keyboard 100%?
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

ivancarv.spk333

38 Posts

Posted - 09/23/2013 :  20:53:23  Show Profile
Until now, the only thing that bugs me in S + for me is that some mysteriously commands do not work in some windows and some programs too, however the virtual keyboard works 100% of the windows everywhere. Today I discovered that the S + does not work completely in windows ''save as'' or ''open'' offered by the programs.

I have a question, if the virtual keyboard of windows works across place, because the S + can not do the same?

Rob

USA
2615 Posts

Posted - 09/23/2013 :  20:57:21  Show Profile  Visit Rob's Homepage
Do you have a script, like in sp_before_actin that activates a window? If you're activating the owner, for example, the keyboard input would be directed there instead of the save dialog. I haven't personally experienced any issues that weren't explainable, though I feel as though I may not use the key commands as much as others.
Go to Top of Page

ivancarv.spk333

38 Posts

Posted - 09/23/2013 :  21:55:18  Show Profile
''function sp_before_action(gnm, gsx, gsy, gex, gey, gwd, gapp, gact)
--Activate the owning window where the gesture started
acActivateWindow(acGetOwnerWindowByPoint(gsx, gsy),0,0)
end
acSendKeys("{F_2}")

Already tried only acSendKeys {F_2} and does not work.



Go to Top of Page

Rob

USA
2615 Posts

Posted - 09/23/2013 :  22:18:22  Show Profile  Visit Rob's Homepage
The activate window call will activate the owner window, which will cause the save dialog window to lose focus thus it won't receive the keyboard input. If you comment out the line, keyboard input should work fine, but then you'll lose that functionality. Which has been covered a number of times on the forum as a no win scenario that requires additional scripting for those who wish to use the activate window call.
Go to Top of Page

ivancarv.spk333

38 Posts

Posted - 09/24/2013 :  00:30:37  Show Profile
I guess I do not understand ... what should I do? tried only acSendKeys'{F_2}' and does not work. Please
Go to Top of Page

Rob

USA
2615 Posts

Posted - 09/24/2013 :  09:16:42  Show Profile  Visit Rob's Homepage
When you complete a gesture, sp_before_action is called before the action is fired.

acActivateWindow(acGetOwnerWindowByPoint(gsx, gsy),0,0) activates the owner window before the acSendKeys is ever called.

Take Notepad, for example. Notepad the program itself is the main (owner) window of the entire notepad.exe process. When you complete a gesture over Notepad, acActivateWindow(acGetOwnerWindowByPoint(gsx, gsy),0,0) is going to find the main Notepad window and activate it first, then send your keystrokes.

When the Save dialog (window) is open and you complete a gesture (like Rename [F2]), acActivateWindow(acGetOwnerWindowByPoint(gsx, gsy),0,0) is going to find the owner window (the main Notepad window, not the Save dialog) and activate it. Since the main Notepad window is now the window with focus, the F2 keystroke is being received by the Notepad window, not the Save dialog.

The solution (for that particular part of the issue) would be to remove the call to activate the owner window (comment out the acActivateWindow line):
function sp_before_action(gnm, gsx, gsy, gex, gey, gwd, gapp, gact)
--Activate the owning window where the gesture started
--acActivateWindow(acGetOwnerWindowByPoint(gsx, gsy),0,0)
end

However, by doing that, S+ will no longer activate a window when you draw over it. For example, if you have Notepad and Explorer opened side-by-side and Explorer is the active window (has focus). Let's say you had an action which sends the CTRL+O key combination. If Explorer was the active window and you draw a gesture over Notepad, the keystrokes (CTRL+O) would be received by Explorer since it is the active window. Windows sends keyboard input to the currently active window.

Now, most actions do not require the window to be active. For example, acMinimizeWindow() simply send the minimize command to a window and it will be minimized; it doesn't have to have focus to be minimized. But to receive keyboard input, it needs to be the window with focus (well, without doing a LOT of advanced message sending which is unreliable).

Although, if you (or someone) really wanted to, a script in sp_before_action could be greatly expanded upon to better identify the window type and walk up the hierarchy accordingly. This would allow the window to be activated without (conditionally) activating the owner window. Perhaps a script which checks to see if the overall process is active and skip sending any kind of activate command.

The reason it is this way is intentional. I wanted to leave it up to the end user to decide what happens. Personally, I do not want a window to be activated. If I want something to happen in an inactive window which requires it being active, I will either put it into the script, or simply click the window to have it focused.

Some people don't like it this way, but it's the less imposing choice; rather than S+ deciding what it thinks is best. Ideally, it would be good to have a better activation script, one that is more robust and contains much more logic. acActivateWindow(acGetOwnerWindowByPoint(gsx, gsy),0,0) is a rather brute force call every time which can raise these types of slight inconsistencies.
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