autoit - Closing Chrome window or better solution -
i'm new autoit , have program working.
objective: open website in browser , close after given period of time (1.5 hours).
script:
;open command prompt start chrome from. run("c:\windows\system32\cmd.exe") winwaitactive("c:\windows\system32\cmd.exe") send('"c:\program files\google\chrome\application\chrome.exe" http://website.com' & "{enter}") ;close dos box winwaitactive("c:\windows\system32\cmd.exe") send('exit' & "{enter}") ; 5400000 = 1.5 hours sleep( 5400000 ); winwaitactive("listen live - google chrome","") ;send("{f4}{altup}") send("{ctrldown}{shiftdown}q{shiftup}{ctrlup}")
the opening works fine script never closes. appears work when timer short not when long.
the script executed via windows scheduled tasks. i've tried separating open/close 2 separate scripts didn't seem work either.
i'm open alternative solutions work on windows.
changing last winwaitactive winactivate might resolve issue, getting window handle , closing via better way.
also, window title looking exists. noticed google chrome window titles not have " - google chrome" in them. confirm opening web page , use auto window info application. application show exact window title , other information when click/activate window. , don't have have exact match. example, if window title may differ after "listen live - xxxx", "listen live -".
try code below , see how works:
; set variables $browser_exe = "c:\program files\google\chrome\application\chrome.exe" $url = "http://website.com" $window_title = "listen live - google chrome" $sleep_time = 5400000 ; 1.5 hours ; run browser , pass url run($browser_exe & " " & $url) ; window handle $window_handle = winwait($window_title) sleep($sleep_time) ; close window winclose($window_handle)
Comments
Post a Comment