Jump to content

BUG in the WinExists function? (Property H is not properly detected)


Recommended Posts

Hi,

can you run this script and tell me what messages you get:

#cs ----------------------------------------------------------------------------
 AutoIt Version: 3.2.12.1
 Author:         chmod777
 Script Function: testing purposes
#ce ----------------------------------------------------------------------------
Run ("notepad")
$size = WinGetPos ( "[CLASS:Notepad]")

If Not @error Then

; test property X
If WinExists ("[CLASS:Notepad; X:" & $size[0] & "]") Then 
    MsgBox (0,"X DETECTED", "Window with CLASS:Notepad and parametr >X< is open.")
Else
    MsgBox (0,"X NOT DETECTED", "No such a window was detected.")
EndIf

; test property Y
If WinExists ("[CLASS:Notepad; Y:" & $size[1] & "]") Then 
    MsgBox (0,"Y DETECTED", "Window with CLASS:Notepad and parametr >Y< is open.")
Else
    MsgBox (0,"Y NOT DETECTED", "No such a window was detected.")
EndIf

; test property W
If WinExists ("[CLASS:Notepad; W:" & $size[2] & "]") Then 
    MsgBox (0,"W DETECTED", "Window with CLASS:Notepad and parametr >W< is open.")
Else
    MsgBox (0,"W NOT DETECTED", "No such a window was detected.")
EndIf

; test property H
If WinExists ("[CLASS:Notepad; H:" & $size[3] & "]") Then 
    MsgBox (0,"H DETECTED", "Window with CLASS:Notepad and parametr >H< is open.")
Else
    MsgBox (0,"H NOT DETECTED", "No such a window was detected.")
EndIf

EndIf

The output should be

X Detected

Y Detected

W Detected

H Detected

but I'm constantly getting

X Detected

Y Detected

W Detected

H NOT Detected.

I don't know why the only H property doesn't function on my system. Is there a bug in the function or do I do something wrong?

Thanx.

Link to comment
Share on other sites

I tried

#include <GUIConstantsEx.au3>
Run ("notepad")
winwaitactive("Untitled")
$size = WinGetPos ( "[CLASS:Notepad]")




MsgBox(0, "Dimensions", $size[0] & @LF & $size[1] & @LF & $size[2] & @LF & $size[3] & @LF)
and got 166, 97, 768, and 530

so it's there but your code does bring up the H not found, but then again I'm not familar with calling the Height from the class, maybe it rounds up where the other rounds down. I also just tried adjusting the window size and no dice.

Giggity

Link to comment
Share on other sites

I don't think it's a rounding error, check out the code below ;)

I have the same bug aswell, strange stuff.

AutoItSetOption("WinTitleMatchMode", 4) 
Run ("notepad")
WinWaitActive("[CLASS:Notepad]")
$size = WinGetPos("[CLASS:Notepad]")
If Not @error Then
    If WinExists("[CLASS:Notepad; X:" & $size[0] & "]") Then 
        MsgBox (0,"X DETECTED", "Window with CLASS:Notepad and parametr >X< is open.")
    EndIf
    If WinExists("[CLASS:Notepad; Y:" & $size[1] & "]") Then 
        MsgBox (0,"Y DETECTED", "Window with CLASS:Notepad and parametr >Y< is open.")
    EndIf
    If WinExists("[CLASS:Notepad; W:" & $size[2] & "]") Then 
        MsgBox (0,"W DETECTED", "Window with CLASS:Notepad and parametr >W< is open.")
    EndIf
    If WinExists("[CLASS:Notepad; H:" & $size[3] & "]") Then 
        MsgBox(0,"H DETECTED", "Window with CLASS:Notepad and parametr >H< is open.")
    Else
        For $i = -10000 To 10000
            $offset = $size[3] + $i
            If WinExists("[CLASS:Notepad; H:" & $offset & "]") Then 
                MsgBox(0, "H DETECTED", "$size[3]=" & $size[3] & "+ $i=" & $i & "=" & $offset)
            EndIf
        next
    EndIf
EndIf
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...