hutralospi Posted October 2, 2018 Share Posted October 2, 2018 I need to move some sub-windows, which all reside inside a main window, in this way: MouseClickDrag("left", 190, 55, 150, 55,0) MouseClickDrag("left", 290, 55, 220, 55,0) MouseClickDrag("left", 390, 55, 290, 55,0) MouseClickDrag("left", 490, 55, 360, 55,0) MouseClickDrag("left", 590, 55, 430, 55,0) MouseClickDrag("left", 690, 55, 500, 55,0) MouseClickDrag("left", 790, 55, 550, 55,0) The above code works perfectly except that the draggings of individual sub-windows are clearly visible one by one - and the whole dragging takes at least 7 seconds for the 7 sub-windows. Is there a way that this process can be made nearly Instant, so that the whole dragging takes just 2-3 seconds for all the 7 sub-windows? .... and so that, if I have 20 sub-windows to drag, the whole process takes less than about 5 seconds? Thanks in advance for any assistance. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted October 2, 2018 Share Posted October 2, 2018 @hutralospiWinMove() ? Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
hutralospi Posted October 2, 2018 Author Share Posted October 2, 2018 @FrancescoDiMuro Thanks for the instant reply. I indeed use WinMove() to move the Main window, which does have a constant title. However, the sub-windows do not have proper 'constant' title/hWnd/class, that is, the sub-windows change every time when the Main window changes. That's why I chose to use MouseClickDrag instead of WinMove() which is instant. The Main window is akin to a class/grade in a school while the sub-windows are the student names in that class. Thanks. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted October 2, 2018 Share Posted October 2, 2018 Do these sub-windows have a partial constant string in their titles? Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
hutralospi Posted October 2, 2018 Author Share Posted October 2, 2018 Yes, The Main window starts something like: Test 1 Class 3 (January) and the sub-windows start something like: John : Test 1 Class 3 (January) Jude : Test 1 Class 3 (January) Jack : Test 1 Class 3 (January) etc. Thanks. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted October 2, 2018 Share Posted October 2, 2018 WinList() could be helpful You retrieve all the Windows opened, and store in an array only the handles for the Windows which match your criteria. In your case, something like: Global $arrWinList, _ $arrWinToMove[1] $arrWinList = WinList() For $i = 1 To $arrWinList[0][0] Step 1 If StringInStr($arrWinList[$i][0], "Test 1 Class 3 (January)") Then _ArrayAdd($arrWinToMove, $arrWinList[$i][1]) ; Store the handle of the Window EndIf Next ; Process Windows with WinMove... Cheers Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
hutralospi Posted October 2, 2018 Author Share Posted October 2, 2018 @FrancescoDiMuro Thanks a lot for your help. Your solution is a little above my current knowledge, and probably a little overkill for my current purpose. However, I will try it in due course if some other member do not suggest a simpler solution. [Simpler solutions are welcome!] Thanks again. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted October 2, 2018 Share Posted October 2, 2018 (edited) @hutralospi I created a little sample script to let you know a very "basic", but at the same dynamic and simple solution for your question I commented it out to let you understand what the script does. Mouse* functions should be used only for very simple clicks and stuffs like that, but not for something that needs a bit of "dynamic" and, why not, something that does it "better" than Mouse* functions. expandcollapse popup#include <Array.au3> #include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) Global $arrStudents[] = ["John", "Mattew", "Ronald", "Gary"], _ $arrWinList, _ ; Array which stores all the Windows opened $arrWinToMove[1], _ ; Array which stores ONLY the Windows to move $intStartingX = 0, _ ; Starting offset for the X axis where to move your Window(s) $intStartingY = 0 ; Starting offset for the Y axis where to move your Window(s) (always 0 in this case) ; Create the GUIs, without storing the handle of them, and show them For $i = 0 To UBound($arrStudents) - 1 Step 1 GUICreate($arrStudents[$i] & " : Test 1 Class 3 (January)", 200, 200) GUISetState(@SW_SHOW) Next ; This GUI will appears behind the _ArrayDisplay, and it doesn't need to be moved, since it won't match the criteria "Test 1 Class 3 (January)" GUICreate("Some GUI that doesn't need to be moved", 200, 200) GUISetState(@SW_SHOW) ; Get the list of ALL windows opened, and store in $arrWinToMove only the ones which match the criteria "Test 1 Class 3 (January)" $arrWinList = WinList() For $i = 1 To $arrWinList[0][0] Step 1 If StringInStr($arrWinList[$i][0], "Test 1 Class 3 (January)") Then _ArrayAdd($arrWinToMove, $arrWinList[$i][1]) If @error Then ConsoleWrite("Error while adding the item " & $arrWinList[$i][1] & " in the array. Error: " & @error & @CRLF) EndIf EndIf Next ; Store the number of handles found with the criteria "Test 1 Class 3 (January)" $arrWinToMove[0] = UBound($arrWinToMove) ; Move the Windows in $arrWinToMove, increasing the X offset by 250, in order to let you see how they are moved For $i = 1 To $arrWinToMove[0] - 1 Step 1 WinMove($arrWinToMove[$i], "", $intStartingX, $intStartingY) $intStartingX += 250 Next ; Click on the "X" button of the _ArrayDisplay to exit the script _ArrayDisplay($arrWinToMove) Exit While 1 Sleep(100) WEnd Cheers Edited October 2, 2018 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
hutralospi Posted October 2, 2018 Author Share Posted October 2, 2018 @FrancescoDiMuro Wow, Fantastic ! Thanks a lot, again, for your help. 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