Jump to content
Sign in to follow this  
DragonBall

sync the position and size of 2 windows

Recommended Posts

DragonBall

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
water

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 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
DragonBall

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  

×