rayzer Posted May 28, 2008 Author Posted May 28, 2008 You are re-moving the windows over and over again. I don't know if that's what you mean to do or not. Doesn't seem necessary. Also, fractional pixel coordinates just get rounded off, so 55.3 and 41.5 may not be that helpful. I see. I want 5 windows to open in the following co-ords:window 1: 0, 0window 2: 372, 0window 3: 372, 166window 4, 372, 166window 5: 372, 166Initially all that was happening was the first window would open at the correct co-ords. The rest would be random, I didn't understand how to lay it out correctly in the array even though you showed me twice. I felt really embarrassed to ask again and tried working out for myself, at the least I'm learning something even if its wrong.
PsaltyDS Posted May 28, 2008 Posted May 28, 2008 I see. I want 5 windows to open in the following co-ords: window 1: 0, 0 window 2: 372, 0 window 3: 372, 166 window 4, 372, 166 window 5: 372, 166 Initially all that was happening was the first window would open at the correct co-ords. The rest would be random, I didn't understand how to lay it out correctly in the array even though you showed me twice. I felt really embarrassed to ask again and tried working out for myself, at the least I'm learning something even if its wrong. You have window 3, 4 and 5 all at the same coordinates, but I assume you know what you want... You could avoid the array, but it's worth learning, so stick with it. We want a 2D array with the first element set to the number of windows, and the second thru n rows set to [n][0] = x coord, and [n][1] = y coord. That would look like this: $avWinPos[6][2] = [[5,""], [0,0], [372,0], [372,166], [372,166], [372, 166]] ; Assumes $avWinList already has the handles for the five windows: For $n = 1 To $avWinPos[0][0] WinMove($avWinList[$n][1], "", $avWinPos[$n][0], $avWinPos[$n][1], 652, 483) Next Note how the array is preloaded with data: Each set of square brackets contains one row of date (colum 0 and column 1), then the whole stack is surrounded by one more set of brackets for the whole array. Hope that helps! Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
rayzer Posted May 30, 2008 Author Posted May 30, 2008 Please test this Mr PsaltyDS. expandcollapse popupGlobal $sRunCmd = "notepad.exe" Global $sWinTitle = "Untitled - Notepad" Global $avWinList = WinList($sWinTitle) Global $iWinCount = $avWinList[0][0] Global $avWinPos[6][2] = [[5,""], [0,0], [372,0], [372,166], [372,166], [372, 166]] While $iWinCount < 5 Run($sRunCmd) Do Sleep(100) $avWinList = WinList($sWinTitle) Until $avWinList[0][0] = $iWinCount + 1 $iWinCount = $avWinList[0][0] WEnd Sleep(1000) For $n = 1 To $avWinPos[0][0] WinMove($avWinList[$n][1], "", $avWinPos[$n][0], $avWinPos[$n][1], 652, 483) Next ; Login and automate each window For $n = 1 To 5 _WinLogin($avWinList[$n][1]) Sleep(1000) Switch $n Case 1; Window 1 ControlSend($avWinList[$n][1], "", "", "{up}"); keypress to 'Ran Enquiry' ControlSend($avWinList[$n][1], "", "", "{right}");keypress to 'Ran Enquiry' ControlSend($avWinList[$n][1], "", "", "{down}");keypress to 'Ran Enquiry' ControlSend($avWinList[$n][1], "", "", "{right}");keypress to 'Ran Enquiry' Case 2; Window 2 ControlSend($avWinList[$n][1], "", "", "{down}");keypress to 'Receipts' ControlSend($avWinList[$n][1], "", "", "{right}");keypress to 'Receipts' ControlSend($avWinList[$n][1], "", "", "{down 2}");keypress to 'Receipts' ControlSend($avWinList[$n][1], "", "", "{right 2}");keypress to 'Receipts' ControlSend($avWinList[$n][1], "", "", "{up}");keypress to 'Receipts' ControlSend($avWinList[$n][1], "", "", "{right}");keypress to 'Receipts' Case 3; Window 3 ControlSend($avWinList[$n][1], "", "", "{down}" );keypress to 'Transfers' ControlSend($avWinList[$n][1], "", "", "{right}" );keypress to 'Transfers' ControlSend($avWinList[$n][1], "", "", "{down}" );keypress to 'Transfers' ControlSend($avWinList[$n][1], "", "", "{right 3}" );keypress to 'Transfers Case 4 ;Window 4 ControlSend($avWinList[$n][1], "", "", "{down}" );keypress to 'Stock Enquiry' ControlSend($avWinList[$n][1], "", "", "{right}" );keypress to 'Stock Enquiry' ControlSend($avWinList[$n][1], "", "", "{down}" );keypress to 'Stock Enquiry' ControlSend($avWinList[$n][1], "", "", "{right}" );keypress to 'Stock Enquiry' ControlSend($avWinList[$n][1], "", "", "{down}" );keypress to 'Stock Enquiry' ControlSend($avWinList[$n][1], "", "", "{right}" );keypress to 'Stock Enquiry' ControlSend($avWinList[$n][1], "", "", "{down}" );keypress to 'Stock Enquiry' ControlSend($avWinList[$n][1], "", "", "{right}" );keypress to 'Stock Enquiry' ControlSend($avWinList[$n][1], "", "", "{f9}" );keypress to 'Stock Enquiry' Case 5; Window 5 ControlSend($avWinList[$n][1], "", "", "{down}" );keypress to 'Copy Stock To Warehouse' ControlSend($avWinList[$n][1], "", "", "{right}" );keypress to 'Copy Stock To Warehouse' ControlSend($avWinList[$n][1], "", "", "{down}" );keypress to 'Copy Stock To Warehouse' ControlSend($avWinList[$n][1], "", "", "{right}" );keypress to 'Copy Stock To Warehouse' ControlSend($avWinList[$n][1], "", "", "{down 2 }" );keypress to 'Copy Stock To Warehouse' ControlSend($avWinList[$n][1], "", "", "{right 2}" );keypress to 'Copy Stock To Warehouse' EndSwitch Sleep(1000) Next Func _WinLogin($hWin) WinActivate($hWin) WinWaitActive($hWin) ControlSend($hWin, "", "", "It worked"); username Sleep(1000) ControlSend($hWin, "", "", "{Enter}") Sleep(1000) ControlSend($hWin, "", "", "Thankyou PsaltyDS you're a legend");password Sleep(1000) ControlSend($hWin, "", "", "{Enter}") EndFunc;==>_WinLogin Do you have any suggestions that can improve the efficiency of the script and do I need to add anything when I've created the script as a service with srvany.exe I want it to run without any other processes/scans interfering whilst its being run.
PsaltyDS Posted May 31, 2008 Posted May 31, 2008 Please test this Mr PsaltyDS.I wouldn't do that unless I could charge so much for it that you wouldn't want me to... I don't quite understand what the 6 and 2 represent. Global $avWinPos[6][2] = [[5,""], [0,0], [372,0], [372,166], [372,166], [372, 166]]The 6 is the number of elements in the first dimension (usually referred to as 'rows'), and the 2 is the number of elements in the second dimension ('columns'). So it declares a 2D array that is 6-by-2 in size. Because array indexes are 0-based, that means the indexes range from [0][0] thru [5][1]. In refilling the array, [0][0] is set to 5 to represent the count of valid entries (1 thru 5) and [0][1] is set to "" (NUL) because it is not used. These fill row 0. Rows 1 thru 5 contain the X and Y coordinates you gave for the five windows. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
rayzer Posted June 4, 2008 Author Posted June 4, 2008 (edited) Thankyou, thankyou, thankyou. Edited June 4, 2008 by rayzer
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