Jump to content

sync the position and size of 2 windows


Recommended Posts

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
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 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2021-06-14 - Version 1.6.5.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - 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
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Link to post
Share on other sites

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
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...