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 comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.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
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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 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...