actiona icon indicating copy to clipboard operation
actiona copied to clipboard

Identify window under mouse?

Open bs27975 opened this issue 6 years ago • 11 comments

I'm looking to have the user move the mouse over the window they wish to operate upon.

I expect they will hit enter (== OK) once they've moved the mouse.

How do I get the Window title (handle) under the mouse?

I'd then do Window / Set foreground and proceed with things.

Further, as there may be multiple windows with the same title open, how to capture / specify the unique / particular window in the 'window title' parameter? [Seems I can't capture / specify the Pid returned by Window Condition.]

TIA.

bs27975 avatar Dec 10 '18 11:12 bs27975

try wmctrl -l

Areahints avatar Feb 18 '19 20:02 Areahints

try wmctrl -l

I'm not following. How does this tell me which window is under the mouse?

bs27975 avatar Feb 20 '19 00:02 bs27975

I don't see any easy way. Using Code, you could get the cursor's position, get a list of all the windows and see which one of them is under the cursor. But that would be very slow. I'm adding a Feature label, since having a way to get a handle to the window under the cursor would be a good thing to have.

Further, as there may be multiple windows with the same title open, how to capture / specify the unique / particular window in the 'window title' parameter? [Seems I can't capture / specify the Pid returned by Window Condition.]

You cannot. Again, would be a nice thing to have.

Jmgr avatar Mar 17 '20 23:03 Jmgr

Hi there. Here is my way to do next: identify window under mouse, find image and take him position into variable. STEPS:

  1. Using xdotool i do write window name into txt file
  2. Here is all process in Actiona: изображение And this output of command file -bi /home/rus/scripts/actiona/activewindow.txt text/plain; charset=utf-8
  3. More details: изображение This read txt file and make variable calling $active_window

изображение Then script show message box with variable in previous step.


Then i try found image using source - WINDOW and WINDOW NAME use variable calling $active_window and make new variable calling $xx as position of founded image. изображение

In this case i try found my icon pic as image - изображение


Finally move cursor in position of var $xx. изображение

So let's run script! изображение This step OK. Named window exist and in next step script will try to find image using this window as source. Here is list of windows: изображение

But nope...Script console show error like this: изображение


I try choose another window name via variable $active_window. The window name is really exist, but script also show error. By the way, if i select window name from drop menu not from variable $active_window - script work without error.

Whats wrong in my steps? Many thanks for your work! You do excellent app! Don't stop! p.s. sorry for my english, i'm not from USA or GB.

Logistix84 avatar Apr 08 '20 11:04 Logistix84

Hi, could you please post here your script's content? (File->Export->Script content, and then paste it here between two code backticks) That would be a lot easier for me to understand what your script is doing. :)

This could definitely be a bug.

Many thanks for your work! You do excellent app! Don't stop!

Thanks. :)

p.s. sorry for my english, i'm not from USA or GB.

No worries. I am currently living in the UK but I'm from France, so English is not my first language either.

Jmgr avatar Apr 10 '20 10:04 Jmgr

Many thanks for your answer. Here is code: <?xml version="1.0" encoding="UTF-8"?> <scriptfile> <settings program="actiona" version="3.9.2" scriptVersion="1.1.0" os="GNU/Linux"/> <actions> <action name="ActionMessageBox" version="1.0.0"/> <action name="ActionMoveCursor" version="1.0.0"/> <action name="ActionFindImage" version="1.1.0"/> <action name="ActionReadTextFile" version="1.0.0"/> </actions> <parameters/> <resources/> <script pauseBefore="0" pauseAfter="0"> <action name="ActionReadTextFile" comment=" output into var &quot;active_window&quot;"> <exception id="1" action="0" line=""/> <exception id="0" action="0" line=""/> <exception id="32" action="0" line=""/> <exception id="2" action="1" line=""/> <parameter name="firstline"> <subParameter name="value" code="0">1</subParameter> </parameter> <parameter name="file"> <subParameter name="value" code="0">/home/rus/scripts/actiona/activewindow.txt</subParameter> </parameter> <parameter name="variable"> <subParameter name="value" code="0">active_window</subParameter> </parameter> <parameter name="lastline"> <subParameter name="value" code="0">1</subParameter> </parameter> <parameter name="mode"> <subParameter name="value" code="0">full</subParameter> </parameter> </action> <action name="ActionMessageBox" comment="show what in txt"> <exception id="1" action="0" line=""/> <exception id="0" action="0" line=""/> <exception id="2" action="1" line=""/> <parameter name="icon"> <subParameter name="value" code="0">information</subParameter> </parameter> <parameter name="title"> <subParameter name="value" code="0">Title</subParameter> </parameter> <parameter name="message"> <subParameter name="value" code="0">$active_window</subParameter> </parameter> <parameter name="ifYes"> <subParameter name="action" code="0">do_nothing</subParameter> <subParameter name="line" code="0"></subParameter> </parameter> <parameter name="customIcon"> <subParameter name="value" code="0"></subParameter> </parameter> <parameter name="windowIcon"> <subParameter name="value" code="0"></subParameter> </parameter> <parameter name="textMode"> <subParameter name="value" code="0">automatic</subParameter> </parameter> <parameter name="type"> <subParameter name="value" code="0">ok</subParameter> </parameter> <parameter name="ifNo"> <subParameter name="action" code="0">do_nothing</subParameter> <subParameter name="line" code="0"></subParameter> </parameter> </action> <action name="ActionFindImage" comment="try find using title window from var"> <exception id="1" action="0" line=""/> <exception id="0" action="0" line=""/> <exception id="32" action="0" line=""/> <exception id="2" action="1" line=""/> <parameter name="method"> <subParameter name="value" code="0">correlationcoefficient</subParameter> </parameter> <parameter name="confidenceMinimum"> <subParameter name="value" code="0">70</subParameter> </parameter> <parameter name="ifNotFound"> <subParameter name="action" code="0">do_nothing</subParameter> <subParameter name="line" code="0"></subParameter> </parameter> <parameter name="imageToFind"> <subParameter name="value" code="0">/home/rus/scripts/actiona/trash.png</subParameter> </parameter> <parameter name="searchExpansion"> <subParameter name="value" code="0">15</subParameter> </parameter> <parameter name="windowName"> <subParameter name="value" code="0">$active_window</subParameter> </parameter> <parameter name="source"> <subParameter name="value" code="0">window</subParameter> </parameter> <parameter name="maximumMatches"> <subParameter name="value" code="0">1</subParameter> </parameter> <parameter name="imageToSearchIn"> <subParameter name="value" code="0">/home/rus/scripts/actiona/scrn.png</subParameter> </parameter> <parameter name="downPyramidCount"> <subParameter name="value" code="0">1</subParameter> </parameter> <parameter name="confidence"> <subParameter name="value" code="0"></subParameter> </parameter> <parameter name="windowRelativePosition"> <subParameter name="value" code="0">false</subParameter> </parameter> <parameter name="ifFound"> <subParameter name="action" code="0">goto</subParameter> <subParameter name="line" code="0">020</subParameter> </parameter> <parameter name="position"> <subParameter name="value" code="0">xx</subParameter> </parameter> <parameter name="searchDelay"> <subParameter name="value" code="0">100</subParameter> </parameter> </action> <action name="ActionMoveCursor" comment="move cursor into center of image"> <exception id="1" action="0" line=""/> <exception id="0" action="0" line=""/> <exception id="2" action="1" line=""/> <parameter name="positionOffset"> <subParameter name="unit" code="0">0</subParameter> <subParameter name="value" code="0"></subParameter> </parameter> <parameter name="position"> <subParameter name="unit" code="0">0</subParameter> <subParameter name="value" code="1">xx</subParameter> </parameter> </action> </script> </scriptfile>

Logistix84 avatar Apr 10 '20 20:04 Logistix84

My screen at current time look like this: изображение

Logistix84 avatar Apr 10 '20 20:04 Logistix84

Still show error as i wrote above. изображение

Logistix84 avatar Apr 10 '20 20:04 Logistix84

Thank you. I have tried under Ubuntu 18.04 with a Firefox Window and the same webpage, but I cannot reproduce this issue here.

It is the same algorithm that provides the list of window titles for listing and searching into, so I don't understand why it would list the window and then not be able to find it afterwards.

Could you try entering *Mozilla Firefox instead of the complete window name?

Jmgr avatar Apr 13 '20 19:04 Jmgr

Could you try entering *Mozilla Firefox instead of the complete window name?

This trick work!

Ok, the problem partially solved. But what if i need recognize next equal pic on page? What would i do?

Logistix84 avatar Apr 13 '20 22:04 Logistix84

Sorry I did not see your edit, I usually read the answers directly on the notification e-mail and it only displays the original text.

But what if i need recognize next equal pic on page? What would i do?

You mean find an image on the page? You could use the Find image action.

Jmgr avatar Apr 22 '20 19:04 Jmgr