DragonBall Posted November 30, 2011 Share Posted November 30, 2011 (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 November 30, 2011 by hodgestructure Link to comment Share on other sites More sharing options...
water Posted November 30, 2011 Share Posted November 30, 2011 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 - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
DragonBall Posted November 30, 2011 Author Share Posted November 30, 2011 (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 November 30, 2011 by hodgestructure Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now