RCLens Posted August 10, 2017 Share Posted August 10, 2017 (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 August 11, 2017 by RCLens Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted August 10, 2017 Moderators Share Posted August 10, 2017 (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 August 10, 2017 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 More sharing options...
RCLens Posted August 10, 2017 Author Share Posted August 10, 2017 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 More sharing options...
izis89 Posted August 10, 2017 Share Posted August 10, 2017 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) Link to comment Share on other sites More sharing options...
RCLens Posted August 10, 2017 Author Share Posted August 10, 2017 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 More sharing options...
izis89 Posted August 10, 2017 Share Posted August 10, 2017 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? RCLens 1 Link to comment Share on other sites More sharing options...
RCLens Posted August 11, 2017 Author Share Posted August 11, 2017 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 More sharing options...
Neutro Posted August 11, 2017 Share Posted August 11, 2017 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 Identify active network connections and change DNS server - Easily export Windows network settings Clean temporary files from Windows users profiles directories - List Active Directory Groups members Export content of an Outlook mailbox to a PST file - File patch manager - IRC chat connect example Thanks again for your help Water! Link to comment Share on other sites More sharing options...
RCLens Posted August 11, 2017 Author Share Posted August 11, 2017 Thanks a lot for your help Link to comment Share on other sites More sharing options...
Nikolas92 Posted August 11, 2017 Share Posted August 11, 2017 To get exact positions of minimize, maximize and close button (and not guess it with WinGetPos) look at CaptionButtonSize() function at this link: http://www.answersbydavid.com/FOSS/Speed Browse/source/Speed Browse dll.au3 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now