Jump to content

Getting a correct WinGetPos... trouble...


Recommended Posts

I'm having trouble getting the correct values from a WinGetPos return. I've used the function before and have no problem getting the correct values for say "notepad" and doing functions with that, but not getting the correct values for the application I want to close. Here is the code:

CODE
Opt("WinTitleMatchMode", 2)

If WinExists("Example") Then

While $exists

Opt("WinTitleMatchMode", 2)

$result = WinActivate("Example")

If Not $result Then

MsgBox(0,"Not","Not Found")

EndIf

Opt("WinTitleMatchMode", 2)

$arr = WinGetPos("Example")

MsgBox(0,"Position","The position is " & $arr[0] & " " & $arr[1] & " " & $arr[2] & " " & $arr[3])

MouseClick("primary",$arr[0]+$arr[2]-15,$arr[1]+15,1)

Sleep(3000)

$exists = WinExists("Example")

WEndEndIf

I know it is finding the window correctly because the return from the "WinActivate" and "WinExists" functions indicate no error. The result I am getting is "The position is 0 0 1680 1050" which is my desktop resolution. I also used the AutoIt window info app and was able to retrieve the correct position and size from that, but that doesn't help me because I can't hard code the position of the mouse click due to different window sizes and such. The only thing I can think of is the fact that the application I'm trying to close has an IEcontrol in it... Is there a known issue with finding the size/position of windows with IE controls? .... Frustrated ...

Link to comment
Share on other sites

Unfortunately no, I'm automating a process and through multiple iterations WinClose() or WinKill() will crash the application. I wanted to manually click the close button to get the best representation of an end-user scenario since closing the window via those commands will occasionally crash the application as it closes.

Link to comment
Share on other sites

Anyone else with a hint?

Something is wrong and I would check that the window you are finding is the window you want. With th eAutoIt Info tool you can get the handle of the window, so try printing the handle of the window in a script

ConsoleWrite("0x" & Hex(WinGetHandle("Example")) & @CRLF)

and make sure it's the same. If you can see the window and the WInGetPos("Example") is wrong then you must have the wrong window. That's my first guess.

You could also use WInList("Example") to see if there is more than one window which matches the "Example" title.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Perfect, there was a hidden Flash window running in the background with the exact same name as the window I was looking for. Finding the window by classname proved much more efficient and now supports older versions of the application much better! Shmanks!

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...