Jump to content

How get the Event Close position? [Solved]


 Share

Recommended Posts

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
Link to comment
Share on other sites

  • Moderators

@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

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...