Sign in to follow this  
Followers 0
RCLens

How get the Event Close position? [Solved]

10 posts in this topic

#1 ·  Posted (edited)

Hello,

I'd like to get the 'event close position' (like a GUI), when I run an application. Is it possible to get it? For instance, I'd like to know the position of the event for closing notepad.

Thanks, I'm a beginned in Autoit.

:)

Edited by RCLens

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

@RCLens not sure what you mean by event close position, exactly. Are you talking about simply a flag when the application is closed? If so, you can use WinExist or ProcessExist/ProcessClose in the help file, among other methods. If you could clarify what you're trying to do we can better assist.

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#3 ·  Posted

Hi,

 

For instance I'd like to know the position of the close button (I mean the red cross button closing a window for any application).

It could be nice to know how can I get the position of this red cross button, even when the window is moving.

 

Thank you for you help.

Share this post


Link to post
Share on other sites

#4 ·  Posted

Here is a way to do it. It works if you don't mind mouse moving all over the screen. You can also use controlsend ALT+F4 to window you want to close.

 

$WinPos = WinGetPos ( "Untitled" )
WinActivate ("Untitled")
MouseClick ("left", $WinPos[0] + $WinPos[2] - 15 , $WinPos[1] + 10, 1, 0)

 

Share this post


Link to post
Share on other sites

#5 ·  Posted

53 minutes ago, izis89 said:

Here is a way to do it. It works if you don't mind mouse moving all over the screen. You can also use controlsend ALT+F4 to window you want to close.

 

$WinPos = WinGetPos ( "Untitled" )
WinActivate ("Untitled")
MouseClick ("left", $WinPos[0] + $WinPos[2] - 15 , $WinPos[1] + 10, 1, 0)

 

No, in my case the mouse is moving all over the screen, such as this case:

When the user put its mouse over the 'red cross' to close the window, a message appears. So it means, I need to know the position of this 'red cross' when the window is reduced (but active) in the screen.

Share this post


Link to post
Share on other sites

#6 ·  Posted

Hm... I am still not quite sure what is the problem. You want window to be closed without pressing red cross? Or you just need corrdinates for red cross but not interact with it?

Well, this gives you a position of the red cross:

$WinPos = WinGetPos ( "Untitled" )

Onscreen coordinates for the red cross are 

$WinPos[0] + $WinPos[2] - 15 , $WinPos[1] + 10

You can make a While 1 loop to make script get coordinates indefinite times if the window is literally moving around constantly.

Also, have you tried Controlsend ALT+F4 to window you want to close if that is your goal?

1 person likes this

Share this post


Link to post
Share on other sites

#7 ·  Posted

11 hours ago, izis89 said:

Onscreen coordinates for the red cross are 

$WinPos[0] + $WinPos[2] - 15 , $WinPos[1] + 10

 

 

Wow, it was I wanted! How you know that, could I have documentation about that, or to explain me, how you get this value?

Share this post


Link to post
Share on other sites

#8 ·  Posted

It's from the help file of the function WinGetPos :) 

https://www.autoitscript.com/autoit3/docs/functions/WinGetPos.htm

Quote

Return Value

Success: a 4-element array containing the following information:
    $aArray[0] = X position
    $aArray[1] = Y position
    $aArray[2] = Width
    $aArray[3] = Height

So $WinPos[0] = notepad window X position for example.

He found the red cross position by simply opening notepad and calculated that the position was for X : (notepad window position X + notepad window width) - 15 

Share this post


Link to post
Share on other sites

#9 ·  Posted

Thanks a lot for your help :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0