Jump to content

How to convince Chrome Browser to accept controlsend() in inactive state?


Recommended Posts

The Chrome browser accepts controlsend() only if it is the active window.
Internet Explorer also accepts controlsend() when another window is active.

For proof, run the following script.
Since the Chrome browser is active, both browser windows count upwards.
When the IE window is clicked, the Chrome browser stops counting because the controlsend ("{F5}") is not accepted. But no error is displayed.
Once the Chrome browser window is clicked again, both windows count again.

Exit the script with Shift+ESC

; chrome refresh tester

#Region Exit
OnAutoItExitRegister("_Exit")
Func _Exit()
    ; close all Test windows
    While WinActivate("[REGEXPTITLE:h--e.de]")
        Sleep(200)
        ControlSend("[Active]", "", "", "^w") ; close tab
        Sleep(500)
    WEnd
    MsgBox(64 + 262144, Default, "Script finished", 2)
EndFunc   ;==>_Exit
#EndRegion Exit

#Region Hotkey
_HotKey("+{ESC}")
Func _HotKey($hotkey = "")
    Switch @HotKeyPressed
        Case "+{ESC}"
            Exit
        Case Else
            If Not IsDeclared("hotkey") Then Return MsgBox(16 + 262144, Default, "No CASE statement defined for hotkey " & @HotKeyPressed)
            If HotKeySet($hotkey, "_Hotkey") = 0 Then Return MsgBox(16 + 262144, Default, "Hotkey " & $hotkey & " invalid or set by another application.")
    EndSwitch
EndFunc   ;==>_HotKey
#EndRegion Hotkey

_Refresh_Test()

Func _Refresh_Test()
    ; close all Test windows
    While WinActivate("[REGEXPTITLE:h--e.de]")
        Sleep(200)
        ControlSend("[Active]", "", "", "^w") ; close tab
        Sleep(500)
    WEnd

    ; open new test windows
    ; in Interner Explorer
    Local $hIEPid = ShellExecute("iexplore.exe", " http://h--e.de/autoit/", "", "", @SW_SHOW)
    Local $hIEWindow = WinWait("[regexptitle:h--e.de;Class:IEFrame]", "", 5)

    ; in Chrome Browser
    Local $hChromePid = ShellExecute("chrome.exe", " --new-window http://h--e.de/autoit/", "", "", @SW_SHOW)
    Local $hChromeWindow = WinWait("[regexptitle:h--e.de;Class:Chrome_WidgetWin_1]", "", 5)

    Local $slp = 500
    While 1
        Sleep($slp)
        $rc=ControlSend("[regexptitle:h--e.de;Class:Chrome_WidgetWin_1]", "", "", "{F5}") ; reload
        If $rc<> 1 Then Exit MsgBox(64+262144, Default, "Error during controlsend() on Chrome",0)
        Sleep($slp)
        ControlSend("[regexptitle:h--e.de;Class:IEFrame]", "", "", "{F5}") ; reload
        If $rc<> 1 Then Exit MsgBox(64+262144, Default, "Error during controlsend() on IE",0)
    WEnd
EndFunc   ;==>_Refresh_Test

What can I do to make the Chrome browser accept controlsend() even in inactive status?

App: Au3toCmd              UDF: _SingleScript()                             

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...