BobbyH Posted December 3, 2023 Posted December 3, 2023 Hello, I've been struggling the last 4 to 5 hours trying to create a script that will allow me to open two separate Google Chrome kiosk instances. The end goal is to be able to use swipe gestures to move between both instances of the kiosk Chrome windows. I haven't decided if I'm going to limit it to just 2 URLs at this point, but I do want the script to relaunch the two separate instances if one or both some how become terminated. Here's what I have (that's not working...), so far: #include <MsgBoxConstants.au3> ShellExecuteWait("Chrome.exe") ; Runs Chrome and specified parameters, and then waits for the commands listed below While 1 ; So... this is a logic statement/command. Basically, 1 will always be equal to or remain 1 (fact of life), so that means while 1 is 1, the statements/commands below will continue to be true, and run indefinately If NOT ProcessExists("Chrome.exe") Then ; If the Chrome process does not exist... Then the "then" statement below starts Sleep(1000) ShellExecute("Chrome.exe", "'URL1' 'URL2' --kiosk --new-window") ; This will reopen Chrome if it is terminated. EndIf WEnd Sleep(3000) #RequireAdmin If ProcessExists("Chrome.exe") Then ; Focuses one of the newly relaunched Chrome instances. Sleep(3000) winactivate("Chrome") EndIf You'll have to excuse my notes... It's the only way I can wrap my head around this stuff sometimes. 😅 Thanks for any help you can provide me!
Subz Posted December 3, 2023 Posted December 3, 2023 ShellExecute("Chrome.exe", 'https://www.google.com --user-data-dir="' & @TempDir & '\Kiosk1"') ShellExecute("Chrome.exe", 'https://www.amazon.com --user-data-dir="' & @TempDir & '\Kiosk2"')
BobbyH Posted December 4, 2023 Author Posted December 4, 2023 18 hours ago, Subz said: ShellExecute("Chrome.exe", 'https://www.google.com --user-data-dir="' & @TempDir & '\Kiosk1"') ShellExecute("Chrome.exe", 'https://www.amazon.com --user-data-dir="' & @TempDir & '\Kiosk2"') Thanks for your reply! I ended up coming up with this instead: ShellExecute("Chrome.exe", 'www.google.com --kiosk --new-window') Sleep(2000) ; Add a delay before sending the refresh shortcut Send("{F5}") ; Send the F5 key (refresh) Sleep(2000) ; Add a delay before opening the next window ShellExecute("Chrome.exe", 'www.yahoo.com --kiosk --new-window') Sleep(2000) ; Add a delay before sending the refresh shortcut Send("{F5}") ; Send the F5 key (refresh) While 1 If Not ProcessExists("Chrome.exe") Then ShellExecute("Chrome.exe", 'www.google.com --kiosk --new-window') Sleep(2000) ; Add a delay before sending the refresh shortcut Send("{F5}") ; Send the F5 key (refresh) Sleep(2000) ; Add a delay before opening the next window ShellExecute("Chrome.exe", 'www.yahoo.com --kiosk --new-window') Sleep(2000) ; Add a delay before sending the refresh shortcut Send("{F5}") ; Send the F5 key (refresh) EndIf Sleep(1000) WEnd #RequireAdmin If ProcessExists("Chrome.exe") Then Sleep(3000) WinActivate("Chrome") EndIf The only thing that I don't like about it, that I still haven't figured out, is how to restore one of the two new Chrome instances on the off chance it gets closed. Right now, both of them have to be terminated for it to restore them both. It would be nice for this script to restore one of the two windows. I'm all ears on suggestions.
ioa747 Posted December 4, 2023 Posted December 4, 2023 (edited) maybe you all ready know, the part with the code #RequireAdmin If ProcessExists("Chrome.exe") Then Sleep(3000) WinActivate("Chrome") EndIf it is never accessible, since there is no exit from the While - WEnd loop 4 hours ago, BobbyH said: haven't figured out, is how to restore one of the two new Chrome instances on the off chance it gets closed This is the way ; https://www.autoitscript.com/forum/topic/211192-shellexecute-and-separate-chrome-kiosk-instances #include <Array.au3> Global $aInstance = [[2, "URL", "REGEXPTITLE"], ["", "www.google.com", "Google - Google Chrome"], ["", "www.yahoo.com", "Sports & Videos - Google Chrome"]] ;~ _ArrayDisplay($aInstance) For $i = 1 To $aInstance[0][0] InstanceExec($i) Next ;********************************** While 1 InstanceCheck() Sleep(1000) WEnd ;********************************** ;---------------------------------------------------------------------------------------- Func InstanceExec($ID) ShellExecute("Chrome.exe", $aInstance[$ID][1] & ' --kiosk --new-window') $aInstance[$ID][0] = WinWaitActive("[REGEXPTITLE:(?i)(.*" & $aInstance[$ID][2] & ".*)]") Sleep(2000) ; Add a delay before sending the refresh shortcut Send("{F5}") ; Send the F5 key (refresh) EndFunc ;==>InstanceExec ;---------------------------------------------------------------------------------------- Func InstanceCheck() For $i = 1 To $aInstance[0][0] If WinExists($aInstance[$i][0]) Then ContinueLoop Else InstanceExec($i) EndIf Next EndFunc ;==>InstanceCheck ;---------------------------------------------------------------------------------------- Edited December 4, 2023 by ioa747 I know that I know nothing
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now