Sign in to follow this  
Followers 0
v1rtu0s1ty

issues with WinGetPos function

29 posts in this topic

#1 ·  Posted (edited)

I've been having a hard time figuring out why I'm getting different coordinate values of an active window. AutoIT Window Info tells me the correct values however, wingetpos doesn't.

Here is the scenario. WinGetPos returns me 300,200 for the X & Y coordinates while AutoIT Window Info gives me 199, 123. WinGetPos gives me 66,22 for the height and width which is weird but AutoIT Window Info gives 626,456.

Here is the code:

AutoItSetOption("WinTitleMatchMode", 4)
   if WinExists("classname=rek20006c0000002","") Then

      WinActivate("Rekon 2000"); this activates the parent along with the child sitting on it

      AutoItSetOption("WinTitleMatchMode", 4)
      $Dimension = WinGetPos("classname=rek20006c0000002")
      msgbox(0,"Dimensions", $Dimension[0] & ", " & $Dimension[1] & ", " &    $Dimension[2] & ", " & $Dimension[3])
   endif

Any ideas?

Thanks!

Edited by v1rtu0s1ty

Share this post


Link to post
Share on other sites



I've been having a hard time figuring out why I'm getting different coordinate values of an active window. AutoIT Window Info tells me the correct values however, wingetpos doesn't.

Here is the scenario. WinGetPos returns me 300,200 for the X & Y coordinates while AutoIT Window Info gives me 199, 123. WinGetPos gives me 66,22 for the height and width which is weird but AutoIT Window Info gives 626,456.

Here is the code:

AutoItSetOption("WinTitleMatchMode", 4)
   if WinExists("classname=rek20006c0000002","") Then

      WinActivate("Rekon 2000"); this activates the parent along with the child sitting on it

      AutoItSetOption("WinTitleMatchMode", 4)
      $Dimension = WinGetPos("classname=rek20006c0000002")
      msgbox(0,"Dimensions", $Dimension[0] & ", " & $Dimension[1] & ", " &    $Dimension[2] & ", " & $Dimension[3])
   endif

Any ideas?

Thanks!

<{POST_SNAPBACK}>

not sure what causes this, but FYI, your image isn't legible...

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

not sure what causes this, but FYI, your image isn't legible...

<{POST_SNAPBACK}>

It is legible. If you are using IE, then you have to hover the mouse on top of the image and wait for the icon at the bottom right. Once it appears, click it, it will enlarge or view the actual image size. :)

You have to do this after you have clicked the link in autoit.

This is one thing I hate in IE most especially when a new browser is loaded and not maximized.

Edited by v1rtu0s1ty

Share this post


Link to post
Share on other sites

It is legible. If you are using IE, then you have to hover the mouse on top of the image and wait for the icon at the bottom right. Once it appears, click it, it will enlarge or view the actual image size. :)

You have to do this after you have clicked the link in autoit.

This is one thing I hate in IE most especially when a new browser is loaded and not maximized.

<{POST_SNAPBACK}>

oops, sorry, normally when i click a thumbnail it comes up actual size(i think).

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

I've been having a hard time figuring out why I'm getting different coordinate values of an active window. AutoIT Window Info tells me the correct values however, wingetpos doesn't.

Here is the scenario. WinGetPos returns me 300,200 for the X & Y coordinates while AutoIT Window Info gives me 199, 123. WinGetPos gives me 66,22 for the height and width which is weird but AutoIT Window Info gives 626,456.

Here is the code:

AutoItSetOption("WinTitleMatchMode", 4)
   if WinExists("classname=rek20006c0000002","") Then

      WinActivate("Rekon 2000"); this activates the parent along with the child sitting on it

      AutoItSetOption("WinTitleMatchMode", 4)
      $Dimension = WinGetPos("classname=rek20006c0000002")
      msgbox(0,"Dimensions", $Dimension[0] & ", " & $Dimension[1] & ", " &    $Dimension[2] & ", " & $Dimension[3])
   endif

Any ideas?

Thanks!

<{POST_SNAPBACK}>

the specs you're listing from the autoit info are coming from the 'control under mouse' listing... try using ControlGetPos instead of WindowGetPos

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

the specs you're listing from the autoit info are coming from the 'control under mouse' listing... try using ControlGetPos instead of WindowGetPos

<{POST_SNAPBACK}>

It doesn't work. Reading the manual, ControlGetPos will only be applicable to a control inside the window.

I tried this and it gave me different numbers.

$Dimension = ControlGetPos("classname=rek20006c0000002","","")

Share this post


Link to post
Share on other sites

It doesn't work. Reading the manual, ControlGetPos will only be applicable to a control inside the window.

I tried this and it gave me different numbers.

$Dimension = ControlGetPos("classname=rek20006c0000002","","")

<{POST_SNAPBACK}>

try this... i'm not sure why there is no control id given, but i put in a 0 to make sure right number of arguments... if this doesn't work , try with "" instead of 0

ControlGetPos("Rekon 2000","Rekon2000",0)

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

try this... i'm not sure why there is no control id given, but i put in a 0 to make sure right number of arguments... if this doesn't work , try with "" instead of 0

ControlGetPos("Rekon 2000","Rekon2000",0)

<{POST_SNAPBACK}>

Both didn't help. :evil:

I'm stucked!

Could it be an autoIt bug though?

Thanks for the help though. :)

Share this post


Link to post
Share on other sites

Both didn't help. :evil:

I'm stucked!

Could it be an autoIt bug though?

Thanks for the help though. :)

<{POST_SNAPBACK}>

i'd be hesitant to call it a bug, more likely the program just has a style that doesn't expose control id's... could be wrong, it wouldn't be the first time (today)...

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

I confirm this behaviour. When running D2 in a window with the co-ordinates and w/h I get...

X: 2    Y: -18  W: 806  H: 618 from AutoIt Window Tool which is correct
and I get this from WinGetPos()...
X: -32000    Y: -32000   W: 160 H: 24

It is quite obvious that the X and Y positions of my window arn't -32000. I would report this as a bug if you haven't already done so.


[u]Old Projects:[/u]A3MORGB2Hex[u]Old Functions:[/u]_TimeAdd/_TimeSub_AddComma_BubbleSort _RippleSort "He who does not understand your silence will probably not understand your words." - Elbert Hubbard.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

I confirm this behaviour. When running D2 in a window with the co-ordinates and w/h I get...

X: 2    Y: -18    W: 806    H: 618 from AutoIt Window Tool which is correct
and I get this from WinGetPos()...
X: -32000     Y: -32000     W: 160    H: 24

It is quite obvious that the X and Y positions of my window arn't -32000. I would report this as a bug if you haven't already done so.

<{POST_SNAPBACK}>

Cool! I hope this can be fixed soon. I used Spy++ and it's able to get the x, y and size properly.

Btw, I don't know how to report it. Can you report it please?

Thanks for doing some test too! :)

Edited by v1rtu0s1ty

Share this post


Link to post
Share on other sites

X: -32000    Y: -32000   W: 160 H: 24
Those are coordinates for a minimized window. How positive are you guys that you don't have the window minimized when calling WinGetPos() or that its not finding another window?

By the way, I know from experience that Diablo II in windowed mode will automatically minimize whenever it loses focus and obviously to run a script in full-screen mode, you have to alt+tab out which also minimizes it. Unless you are inserting a sleep delay before the call to WinGetPos() or invoking it via a hotkey, you will not get the coordinates of the Diablo II window because it will be minimized. That is not a bug.

v1rtu0s1ty, I suspect in your case that there are more than one window in the system with that classname and its finding a different one than you think it is.

I highly doubt there is a bug in AutoIt.

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Those are coordinates for a minimized window.  How positive are you guys that you don't have the window minimized when calling WinGetPos() or that its not finding another window? 

By the way, I know from experience that Diablo II in windowed mode will automatically minimize whenever it loses focus and obviously to run a script in full-screen mode, you have to alt+tab out which also minimizes it.  Unless you are inserting a sleep delay before the call to WinGetPos() or invoking it via a hotkey, you will not get the coordinates of the Diablo II window because it will be minimized.  That is not a bug.

v1rtu0s1ty, I suspect in your case that there are more than one window in the system with that classname and its finding a different one than you think it is.

I highly doubt there is a bug in AutoIt.

<{POST_SNAPBACK}>

I downloaded a vb api that enumerates all windows including handles, caption and classnames. I looked for the classname rek20006c0000002 and saw one, however, I saw 3 other classes in classname=rek20006c000000. And I'm very sure that the classname is rek20006c0000002 by hovering the mouse on that window. I have actually attached a screenshot at the beginning of this thread and you will see it there. The class rek20006c000000 is the parent window. And the classname for the workspace underneath rek20006c0000002 window is rek20006c0000001.

To really verify this, I had to manually run the application and execute this code:

It gave me a result of (300,200) coordinates and (66,22) for the height and width.

WinActivate("Rekon 2000")
     AutoItSetOption("WinTitleMatchMode", 4)
     $Dimension = WinGetPos("classname=rek20006c0000002","")
     msgbox(0,"Dimensions", $Dimension[0] & ", " & $Dimension[1] & ", " & $Dimension[2] & ", " & $Dimension[3])

However, if I do the code below, it gets the dimension and coordinates of the parent window

WinActivate("Rekon 2000")
     AutoItSetOption("WinTitleMatchMode", 4)
     $Dimension = WinGetPos("","")
     msgbox(0,"Dimensions", $Dimension[0] & ", " & $Dimension[1] & ", " & $Dimension[2] & ", " & $Dimension[3])

Please look at the new attachments.

The left attached is the parent window. The right pic attached is the child window that I really want to get working. :)

New addtion:

I added this and it showed a SIZE of 1 but the Title was blank. I did this to make sure there is no other classname=rek20006c0000002 which proved it.

$winvar = WinList("classname=rek20006c0000002")
     
      Msgbox(0,"","SIZE:" & $winvar[0][0])
      For $i = 1 to $winvar[0][0]
             MsgBox(0, "Details", "Title=" & $winvar[$i][0] & @LF & "Handle=" & $winvar[$i][1])
      Next

Thanks for looking into this.

N

Edited by v1rtu0s1ty

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

You must be really fast with your screen shots, even the seconds are the same between the Parent and the Child.

BTW, couldn't be as easy as cheking AutoInfo in the Options / Coord Mode and making sure that your getting Windows Coords since your using WinGetPos() could it?

Just a thought.

Edit: Maybe try adding the text to it?

$Dimension = WinGetPos("classname=rek20006c0000002","Rekon2000")

Hope you get it working, gary had to help me w/ WinGetPos() a couple of days ago.

Edited by ronsrules

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

The class name is "classname=rek20006c000000", no trailing 2. The 2 is the instance number for a control. The instance number is something invented by AutoIt that allows it to identify which control the mouse is over, it is not part of the real class name. If you are trying to get the coordinates for the main parent window itself, then you need to use the class name as posted above, without any trailing instance number.

Share this post


Link to post
Share on other sites

You must be really fast with your screen shots, even the seconds are the same between the Parent and the Child.

BTW, couldn't be as easy as cheking AutoInfo in the Options / Coord Mode and making sure that your getting Windows Coords since your using WinGetPos() could it?

Just a thought.

Edit:  Maybe try adding the text to it?

$Dimension = WinGetPos("classname=rek20006c0000002","Rekon2000")

Hope you get it working, gary had to help me w/ WinGetPos() a couple of days ago.

<{POST_SNAPBACK}>

I've done that. Didn't help. :)

WinGetTitle("classname=rek20006c0000002") and WinGetText("classname=rek20006c0000002") returns 1

WinList("classname=rek20006c0000002") gives out a size of 1

I know, there is a possibility that is is a bug! How else can I test?

However, WinClose or WinKill, WinSetState doesn't do anything to the window.

I've wasted many days just for this coordinate and size.

Lastly, VB handle enumerator shows only 1 instance of rek20006c0000002.

Share this post


Link to post
Share on other sites

The class name is "classname=rek20006c000000", no trailing 2.  The 2 is the instance number for a control.  The instance number is something invented by AutoIt that allows it to identify which control the mouse is over, it is not part of the real class name.  If you are trying to get the coordinates for the main parent window itself, then you need to use the class name as posted above, without any trailing instance number.

<{POST_SNAPBACK}>

I want to get the coordinates of the child window. It's the window that contains the error.

Share this post


Link to post
Share on other sites

ControlGetPos("classname=rek20006c000000", "", "rek20006c0000002")

Share this post


Link to post
Share on other sites

ControlGetPos("classname=rek20006c000000", "", "rek20006c0000002")

<{POST_SNAPBACK}>

Here is my latest code and it fails:

AutoItSetOption("WinTitleMatchMode", 4)

if WinExists("classname=rek20006c0000002","") Then
      WinActivate("Rekon 2000")
      WinActivate("classname=rek20006c0000002")
      $Dimension = ControlGetPos("classname=rek20006c000000", "", "rek20006c0000002")
      msgbox(0,"Dimensions", $Dimension[0] & ", " & $Dimension[1] & ", " & $Dimension[2] & ", " & $Dimension[3])
endif

Please see attachment.

Thanks for helping out! :)

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

AutoItSetOption("WinTitleMatchMode", 4)

If WinExists("classname=rek20006c0000002","") Then
   WinActivate("Rekon 2000")
   WinActivate("classname=rek20006c0000002")
   $Dimension = ControlGetPos("classname=rek20006c000000", "", "rek20006c0000002")
   If IsArray($Dimension) Then
      msgbox(0,"Dimensions", $Dimension[0] & ", " & $Dimension[1] & ", " & $Dimension[2] & ", " & $Dimension[3])
   Else
      MsgBox(0, "Error", "")
   EndIf
Endif

Edit: Forgot Code Tags

Edited by ronsrules

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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