#include #include Global $sleeptime = 3000 Global $ie_Windows_pid[5] Global $ie_Windows_HWNDs[5] Global $ie_current_ie_window = 0 Main() Func Main() KillAllIExplorers() For $i = 0 To 4 LoadIExplorer() Next EndFunc Func KillAllIExplorers() Local $IEProcessList = ProcessList() For $i__ = 1 To $IEProcessList[0][0] If $IEProcessList[$i__][0] == "iexplore.exe" Then ProcessClose($IEProcessList[$i__][1]) EndIf Next EndFunc Func LoadIExplorer() Local $InternetExplorer_PID = Run("iexplore.exe") MsgBox($MB_SYSTEMMODAL, "", "PID is: " & $InternetExplorer_PID) $bprocess_exist = 0 $ie_Windows_pid[$ie_current_ie_window] = $InternetExplorer_PID Do Do $bprocess_exist = ExistIEProcess($ie_Windows_pid[$ie_current_ie_window]) Until $bprocess_exist == 1 ;MsgBox($MB_SYSTEMMODAL, "Checking ExistIEProcess", "value found:" & $bprocess_exist) If $bprocess_exist == 0 Then ;MsgBox($MB_SYSTEMMODAL, "FAIL", "Process not running") Exit(1) EndIf $h_result = FindCurrentIE($ie_Windows_pid[$ie_current_ie_window]) Until $h_result == 1 Local $InternetExplorer_HWND = $ie_Windows_HWNDs[$ie_current_ie_window] Sleep($sleeptime) WinMinimizeAll ( ) Sleep($sleeptime) Local $result = 0 Do WinSetState($InternetExplorer_HWND, "", @SW_MAXIMIZE ) WinSetState($InternetExplorer_HWND, "", @SW_SHOW ) Local $iState = WinGetState($InternetExplorer_HWND) If BitAND($iState, 2) Then $result = 1 EndIf Until $result = 1 Sleep($sleeptime) Send("!d") Sleep($sleeptime) Send("{DEL}") Sleep($sleeptime) Send("https://www.youtube.com/watch?v=Nck6BZga7TQ") Sleep($sleeptime) Send("{ENTER}") Sleep($sleeptime) Send("{ENTER}") Sleep($sleeptime) $ie_current_ie_window = $ie_current_ie_window + 1 ;WinClose($InternetExplorer_HWND) EndFunc Func ExistIEProcess($pid_) ;MsgBox($MB_SYSTEMMODAL, "ExistIEProcess", "Calling ExistIEProcess") $found_proc = 0 Local $aProcessList = ProcessList() For $i_ = 1 To $aProcessList[0][0] If $aProcessList[$i_][1] == $pid_ Then $found_proc = 1 ;MsgBox($MB_SYSTEMMODAL, "FOUND", $aProcessList[$i_][0] & @CRLF & "PID: " & $aProcessList[$i_][1]) EndIf Next ;MsgBox($MB_SYSTEMMODAL, "ExistIEProcess", "Exiting ExistIEProcess found:" & $found_proc) return $found_proc EndFunc Func FindCurrentIE($currentPID) Local $aList = WinList("[CLASS:IEFrame]") Local $found = 0 For $i = 1 To $aList[0][0] If $aList[$i][0] <> "" Then Local $current_hwnd = $aList[$i][1] Local $current_PID = WinGetProcess($current_hwnd) ;MsgBox($MB_SYSTEMMODAL, "", "Title is: " & $aList[$i][0] & @CRLF & " PID is: " & $current_PID & @CRLF & "HWND is: " & $current_hwnd ) If $currentPID == $current_PID Then ;MsgBox($MB_SYSTEMMODAL, "MATCH", "Title is: " & $aList[$i][0] & @CRLF & " PID is: " & $current_PID & @CRLF & "HWND is: " & $current_hwnd ) $ie_Windows_HWNDs[$ie_current_ie_window] = $current_hwnd $found = 1 ;Sleep(5000) EndIf EndIf Next return $found EndFunc