Sign in to follow this  
Followers 0
DragonBall

sync the position and size of 2 windows

3 posts in this topic

#1 ·  Posted (edited)

I used the following script to change the position and size of WinB immediately after WinA is moved or size changed. But there is a problem that it (very oftehn) happens that

"Subscript used with non-Array variable.:" when I click the right-top corner of WinA to exit WinA. If I used Sleep(90) after While _isPressed("1", $dll), then there is no problem, but WinB will change its position and size after 90ms. Although this is acceptable, I still would like to know if there is a way to change the position and size of WinB immediately after WinA is moved or size changed.

While (1)
Sleep(20)
If _isPressed(Hex(1), $dll)  Then
    While _isPressed("1", $dll)
        ;; Sleep(90)
        If WinActive("WinA") Then
            Sleep(10)
            If Not ProcessExists("A.exe") = 0 Then
                $WinAPosSize = WinGetPos("WinA")
                WinMove("WinB", "", $WinAPosSize[0] + $WinAPosSize[2], $WinAPosSize[1], $WinAPosSize[2], $WinAPosSize[3] )
           
            EndIf
        EndIf
    WEnd
EndIf
WEnd
Edited by hodgestructure

Share this post


Link to post
Share on other sites



Check if WingetPos returned an error. In this case $WinAPosSize is no array and hence you get the subscript error message.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks, water. I found the trick: It should put $WinAPosSize = WinGetPos("WinA") after WinMove("WinB", "", $WinAPosSize[0] + $WinAPosSize[2], $WinAPosSize[1], $WinAPosSize[2], $WinAPosSize[3] ) to avoid this problem, which is not the logical order....!!

While (1)
Sleep(20)
If _isPressed(Hex(1), $dll)  Then
    $WinAPosSize = WinGetPos("WinA")
    While _isPressed("1", $dll)
        ;; Sleep(90)
        If WinActive("WinA") Then
            Sleep(10)
            If Not ProcessExists("A.exe") = 0 Then
                ;; $WinAPosSize = WinGetPos("WinA")
                WinMove("WinB", "", $WinAPosSize[0] + $WinAPosSize[2], $WinAPosSize[1], $WinAPosSize[2], $WinAPosSize[3] )
                $WinAPosSize = WinGetPos("WinA")
            EndIf
        EndIf
    WEnd
EndIf
WEnd
Edited by hodgestructure

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