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

 All Forums
 General Discussion
 General Discussion
 How to get "Control Class Name" of a UI's element?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

poweruser84

Russia
24 Posts

Posted - 12/24/2015 :  13:42:59  Show Profile  Reply with Quote
Hello all
Hi Rob

Please give me suggestion how to get a "Control Class Name" in Lua Script. I want use that in Global Lua. The idea is to use this for gesture ("one click" gesture thought the sp_after_release() function) , that should work in specific UI's element.

Rob

USA
2604 Posts

Posted - 12/24/2015 :  18:20:42  Show Profile  Visit Rob's Homepage  Reply with Quote
The most basic example is this:

acMessageBox(acGetClassName(nil, gsx, gsy))

The challenge here is that sp_after_release() has no values passed into it. So within sp_after_release(), you wouldn't be able to specify which window (control) you're interested in (you won't have the mouse coordinates at the location of the click). Also, note that sp_after_release() is ONLY executed after a recognized gesture/action occurs; not any time you release the stroke button.

If you're looking to simply have this code execute any time you click a mouse button, let's say the middle-button, you could enable the Allow Middle Click Script* preference and use the function in Global Lua. If you don't already have it defined:
function sp_middle_mouse_up(x, y, fwKeys)
	-- x = the x coordinate of the mouse where the middle button was clicked
	-- y = the y coordinate of the mouse where the middle button was clicked
	-- fwKeys = the key state at the time the right button was pressed
	acMessageBox(acGetClassName(nil, x, y))
end
Note: You cannot use the click script preference for the same button as the stroke button. For example, if your stroke button is the right mouse button, Allow Right Click Script* will not work (nothing will happen). This is due to the complexities of stroke button capture and processing; trust me, it would negatively interfere with your Windows experience otherwise.

However, it is possible to still use sp_after_release(), but you'd have to save the gsx & gsy variables from a previous event to a global variable. But in all likelihood, you're looking for this to happen independently of any other defined action, which means sp_after_release() would never be called.

The purpose of sp_after_release() was really just to provide an area to update/clear variables (for example) that may have been used across scripts or chained events, like holding the stroke button and scrolling the mouse wheel; so after you let go, you could clean up any variables/etc. that may need it so it's ready the next time.

But, if you're looking for very specific control(s), using the click script for a different mouse button may be fine. Note that the mouse click event is NOT consumed in these click scripts. Meaning, if you click the middle button, your script in sp_middle_mouse_up will execute, but the middle button click will still be processed by whatever control/window where the middle click occurred. For example, if you used the script and middle-clicked on a Windows Explorer button on the Taskbar, your script (get class name) would process, but a new Windows Explorer window would also open (the default behavior for middle-clicking the Taskbar button).

Alternatively, you could make an action which had no gesture, and just Left Click modifier checked, then pressing right and left together and releasing could execute your class name check and script. If you already have a no gesture/Left Button action, you could have a conditional script. Meaning, if the mouse is over the desired class name/etc, do what you're looking to do; otherwise, execute the action the way it does now (if/else).

If you can give me a more specific example of exactly what you're looking to achieve, I might be able to come up with some ideas.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
StrokesPlus Forum © 2011-2018 Rob Yapchanyk Go To Top Of Page
Snitz Forums 2000