Opt("GUIOnEventMode", 1) Opt("WinTitleMatchMode", 2) Opt("TrayIconDebug", 1) #include "wd_core.au3" #include #include #include #include #Include <_SendEx.au3> ;prevent keys from sticking dim $dll = DllOpen("user32.dll") _Singleton(@Scriptname) ;==================================================== Local $sDesiredCapabilities, $sSession $_WD_DEBUG = $_WD_Debug_Info $_WD_ERROR_MSGBOX = False $_WD_DEBUG = $_WD_DEBUG_None ;Hides console at startup SetupChrome() If Not ProcessExists("chromedriver.exe") Then _WD_Startup() EndIf If @error <> $_WD_ERROR_Success Then Exit EndIf ; sets up chrome with Google and Yahoo tabs open WinActivate("Chrome") WinWaitActive("Chrome", "", 10) _SendEx("+^m") ;opens my profile in a new Chrome Window Sleep(200) _SendEx("{enter}") _SendEx("^t") ;opens Yahoo tab ClipPut("https://yahoo.com") _SendEx("^v{enter}^1") WinMove("Chrome", "", @DesktopWidth/15, 0, @DesktopWidth - 125, @DesktopHeight -35); moves chrome a touch away from right side of screen Sleep(3000) WinClose("New Tab") ;Closes first chrome window ;==========================================START LOOP======================================== While 1 $_i1 = MouseGetPos() If _IsPressed('04', $dll) Then Call ("MClick"); Middle Click If Not WinExists("Chrome") Then exit Sleep(10) WEnd ;==========================================END LOOP========================================== ;==========================================FUNCTIONS====================================== Func MClick() $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "/html/body") $sText = _WD_ElementAction($sSession, $sElement, "text") MsgBox(1, "",$sText) ; *******ERROR*********** EndFunc Func SetupChrome() _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--user-data-dir=C:\\Users\\DOCMJ\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}' $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Option('DriverParams', '--marionette-port 2828') EndFunc