#RequireAdmin ; Runs script as admin user #include #include #include #include #include #include #Include #include #include #include #include #include #include #include #include #include #Include #include #Include #include #include #include #include #include #include #include #include #include ; Define file names for different directories ; Main() Func Main() Opt("MouseCoordMode", 0) ; inserting code here to open explorer window Local $filePath1 = "E:\Users\Davida\Desktop\" Local $filePath2 = "E:\Users\Davida\Documents\" Global $runDate = @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC Local $iPid1= Run ("explorer.exe " & $filePath1) Sleep(500) If $iPid1 = 0 Then ; Run failed MsgBox(0, "Error -1", "CreateFilePath run explorer failed.") Exit(-1) EndIf Sleep(500) Local $WinHand1 = WinGetHandle ("[CLASS:CabinetWClass]", "Desktop") Sleep(500) If @error = 0 Then ; window found ; do nothing Else MsgBox(0, "Error -3", "WinGetHandle failed.") Exit(-3) EndIf Sleep(500) ; ; $RetValue1 = WinActivate ($WinHand1) ; If $RetValue1 = 0 Then ; winactivate failed ; MsgBox(0, "Error -7", "WinActivate 1 failed.") ; FileWrite($hFileOpen, "Error -7 WinGetHandle failed." & @CRLF) ; Exit(-7) ; EndIf ; Sleep(500) Local $Array1 = WinGetPos ("[ACTIVE]", "Desktop") ;Sleep(500) If @error = 0 Then ; window found ; MsgBox(0, "WinGetPos Example", "Screen Coord Array1 : " & @CRLF& _ ; "X: " & $Array1[0] & @CRLF & _ ; "Y: " & $Array1[1] & @CRLF & _ ; "W: " & $Array1[2] & @CRLF & _ ; "H: " & $Array1[3] & @CRLF) Else MsgBox(0, "Error -5", "WinGetPosition failed.") Exit(-5) EndIf Local $iPid2 = Run ("explorer.exe " & $filePath2) Sleep(500) If $iPid2 = 0 Then ; Run failed MsgBox(0, "Error -2", "CreateFilePath run explorer failed.") Exit(-2) EndIf Sleep(500) Local $WinHand2 = WinGetHandle ("[CLASS:CabinetWClass]", "Documents") Sleep(500) If @error = 0 Then ; window found ; do nothing Else MsgBox(0, "Error -4", "WinGetHandle failed.") Exit(-4) EndIf Sleep(500) $RetValue2 = WinActivate ($WinHand2) If $RetValue2 = 0 Then ; winactivate failed MsgBox(0, "Error -9", "WinActivate 1 failed.") Exit(-9) EndIf Sleep(500) Local $Array2 = WinGetPos ("[ACTIVE]", "Documents") ; Sleep(500) If @error = 0 Then ; window positions found ; MsgBox(0, "WinGetPos Example", "Screen Coord Array2 " & @CRLF& _ ; "X: " & $Array2[0] & @CRLF & _ ; "Y: " & $Array2[1] & @CRLF & _ ; "W: " & $Array2[2] & @CRLF & _ ; "H: " & $Array2[3] & @CRLF) Else MsgBox(0, "Error -6", "WinGetPosition failed.") Exit(-6) EndIf Sleep(500) $X = 250 $Y = 10 $NewX = 1150 $NewY = 10 $RetValue3 = MouseClickDrag ( $MOUSE_CLICK_LEFT, $X, $Y, $NewX, $NewY, 30 ) If $RetValue3 = 0 Then ; MouseClickDrag failed MsgBox(0, "Error -8", "MouseClickDrag 1 failed.") Exit(-8) EndIf Sleep(500) ;MsgBox(0, "After MouseClickDrag", "Screen Coord Array2 " & @CRLF& _ ; "X: " & $X & @CRLF & _ ; "Y: " & $Y & @CRLF & _ ; "W: " & $NewX & @CRLF & _ ; "H: " & $NewY & @CRLF) Sleep(500) $WinHandDesk = WinActivate($WinHand1, "") Sleep(500) If $WinHandDesk = 0 Then ; Winactivate call failed MsgBox(0, "Error -10", "WinActivate failed") Exit(-10) EndIf Sleep(500) ;GetFileFocus($filePath & $Rundate) $saveI = GetFileFocus("E:\Users\Davida\Desktop\testautoit.txt") Sleep(500) MsgBox(0, "$saveI: ", $saveI & @CRLF) Sleep(500) _GUICtrlToolbar_SetStyleAltDrag ($WinHand1, True) _GUICtrlToolbar_ClickIndex ($WinHand1, $saveI, "left",True,1) ; get position from first screen to drag to next screen Local $Array1A = WinGetPos ("[ACTIVE]", "Desktop") ; Sleep(500) If @error = 0 Then ; window positions found MsgBox(0, "WinGetPos Example", "Screen Coord Array1A " & @CRLF& _ "X: " & $Array1A[0] & @CRLF & _ "Y: " & $Array1A[1] & @CRLF & _ "W: " & $Array1A[2] & @CRLF & _ "H: " & $Array1A[3] & @CRLF) Else MsgBox(0, "Error -11", "WinGetPosition failed.") Exit(-11) EndIf Sleep(500) Local $New1X = $NewX + 300 Local $New1Y = $NewY + 15 Local $testValue = 320 + ($saveI * 20) $RetValue5 = MouseClickDrag ( $MOUSE_CLICK_LEFT, 220, $testValue, $New1X, $New1Y, 30 ) If $RetValue5 = 0 Then ; MouseClickDrag failed MsgBox(0, "Error -12", "MouseClickDrag 1 failed.") Exit(-12) EndIf EndFunc ;==> Main