8

Is there a way to automatically google cast a chrome tab or a specific website everytime I visit the website URL ?

Any command or function or script or bat file ?

user3320648
  • 91
  • 1
  • 1
  • 3
  • 2
    Did you find any solution for this? I would like to use chromecast to display a monitoring page on tv. For this, I have setup an VM with autologin and chrome in autostart. But starting the chrome-cast is still the bottleneck of my solution. – powerMicha Jan 13 '15 at 15:33
  • Technically it is certainly possible. On Android I use AutoCast tasker plugin in order to display a web page on the Chromecast. Again on Android, Web Video Caster allows me to automatically cast any video that is contained in a page. Unless you want specifically a solution for Google Chrome tabs so it should be possible to find equivalent tools for the desktop as well. – David L. Jan 07 '17 at 17:26

4 Answers4

1

No, you can't and even if you could, it is strongly recommended not to do that; user has to initiate the process and select a target explicitly. Here is two simple scenarios that can totally go wrong:

  • What if there are multiple devices on the same network? How does it know which one to choose?
  • Imagine your family is in front of the TV in living room, and you are in your bedroom and open that web page, all of sudden it starts casting to your living room.
Ali Naddaf
  • 16,951
  • 2
  • 21
  • 28
  • 3
    Hi, I am using this for a professional project and has nothing to do with kids websites. I would like to call mypage.com/index.html and automatically 1 specific chromecast device will start casting it, or even if there is a command to start up chrome with chromecast running for device1 there should be an autostart option someplace.... – user3320648 Feb 19 '14 at 21:27
  • 3
    Note that if you do that, you will be in violation of Google Cast SDK Terms of Service agreements, item 3.4.8 (https://developers.google.com/cast/docs/terms) so try to avoid that. – Ali Naddaf Feb 20 '14 at 01:14
  • 1
    I think Google should provide a separate business licence that allows the businesses to control their cast screens without manual intervention. There is no user input required in this scenario. Does Google want to restrict the usage of Chromecast to just private living rooms? – Price May 26 '15 at 10:43
  • @Price: "There is no user input required in this scenario" -- then do not use a device that requires some amount of user input. There are countless devices that can plug into a TV, ranging from TV-dedicated devices (e.g., Fire TV, Fire TV Stick, various HDMI sticks available on eBay, Alibaba, etc.) to ordinary phones/tablets with HDMI/MHL/SlimPort output. Any of those will run an OS (mostly Android), for which you can create full apps that can do lots of things "without manual intervention". – CommonsWare May 26 '15 at 15:11
  • @CommonsWare, thanks for suggesting these alternatives! Is it possible to automatically start an app on any of these devices and play content from an Android app running on another phone that is on the same WiFi network? – Price May 27 '15 at 01:14
  • FYI, this controller Android app is not going to be used by ordinary users, only by admins. – Price May 27 '15 at 01:19
  • 1
    @Price: In general, yes. That being said, your inquiries are getting off-topic for this question and answer. If you have further concerns in this area, I suggest that you ask a separate Stack Overflow question where you explain what your objectives are and ask about how to set up the pair of apps (one on the TV-connected device, one on the phone) to achieve those objectives. – CommonsWare May 27 '15 at 10:44
1

You need another device,

Android Mini PC MK802

Install app "autorun" and put chrome in this.

  • This is actually a really good option. Chromecasts, on the whole, are not meant to be used to automatically open a webpage... (Even though they'd be awesome at it) – davewasthere May 02 '17 at 08:26
1

Make sure you have Chrome version 76.0.3809.132 or later. Install AutoHotkey. Make 2 files and place them on your desktop:

CastOn.ahk:

; AutoHotKey Script to start ChromeCast in Desktop Mode
;
; Declare variables
delay := 1000
; Run Chrome
Run, C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --fullscreen --start-maximized
Sleep, delay
Send !f
Sleep, delay
Send c
Sleep, delay
Send {tab}{tab}
Sleep, delay
Send {Enter}
Sleep, delay
Send {Down}{Down}
Sleep, delay
Send {Enter}
Sleep, delay
Send +{tab}
Send {Enter}
Sleep, delay * 2
Send {tab}
Sleep, Delay
Send {tab}
Sleep, Delay
Send {tab}
Sleep, Delay
Send {Enter}
Sleep, delay
Send #{down} ; minimize window, casting starts

CastOff.ahk:

; AutoHotKey Script to stop ChromeCast in Desktop Mode
;
; Declare variables
delay := 1000
; Run Chrome
Run, C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --fullscreen --start-maximized
Sleep, delay
Send !f
Sleep, delay
Send c
Sleep, delay
Send {tab}
Send {Enter}
Sleep, delay
Send {ESC}
Sleep, delay
Send !{f4} ; close window

Now you have 2 ahk icons on your desktop. Double clicking CastOn.ahk starts casting and leaves Chrome minimized (just wait for the magic to happen). Double clicking CastOff.ahk stops casting and closes the opened Chrome window invoked in this script.

"Sleep" is needed to avoid the simulated keystrokes to launch to early, you can however experiment with the delay variable (now set to 1000 ms, one second).

Newer versions of Chrome may lead to new UI changes in the ChromeCast functionality, which would mean this script needs to be adjusted.

Chrome may be installed in a different path as mentioned in the ahk scripts. It would not be too difficult to sort out the correct location of Chrome.exe.

If needed, you can adjust this script to cast a Chrome tab instead of the desktop or open a specific website.

1

Ok.. so i figured out that the interface selection is dependent upon how many chromecast devices you have. SO i put together a AutoHotkey variation of Marcel Pennock's code...

This allows you to define how many times the script needs to hit the TAB button... to select the proper casting device from the populated list crhome gives you of detected devices.

So.. if you want to cast to device 2 on your list.. you set the deviceNumber parameter to be the number of the device in the list ( 1 = first device listed.. 2 = second.. etc ).

Also.. I made it so you can select what casting mode you want... be default I set it to DESKTOP ( option 2 ).

Again.. its all about how many times you need to hit TAB to select what you want...

CastOn-1.ahk:

;------------------------------------------------------------
; AutoHotKey Script to START ChromeCast in Desktop Mode
;
; Declare variables
;
; -- Set CastMode (1=TAB 2=DESKTOP 3=FILE)
castMode := 2
deviceNumber := 1
;
delay := 1000
;------------------------------------------------------------


;------------------------------------------------------------
; Run Chrome
Run, C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --fullscreen --start-maximized

;Sleep, delay
Sleep, 5000

#IfWinActive, ahk_class Chrome_WidgetWin_1

; -- SEND the ALT+F key combo to open settings
SendInput !f
Sleep, delay

; -- SEND the C key combo to select CAST
SendInput c
Sleep, delay
;------------------------------------------------------------

;------------------------------------------------------------
; -- Tab to the SOURCES drop down box and select it.
SendInput {TAB 3}
Sleep, delay

SendInput {Enter}
Sleep, delay
;------------------------------------------------------------

;------------------------------------------------------------
; -- Make your Selection ( One DOWN for TAB, Two DOWN for DESKTOP, THREE down for FILE.)
; Select DESKTOP -- TWO DOWN COMMANDS PASSED
SendInput {Down %castMode%}
Sleep, delay

SendInput {Enter}
Sleep, delay
;------------------------------------------------------------

;------------------------------------------------------------
; -- Tab  OUT of the Source Selection area ..   to be able to select correct device.
SendInput {TAB}
Sleep, delay

; -- Tab to the DEVICE we selected and 
SendInput {TAB %deviceNumber%}
Sleep, delay

; -- START CAST. 
SendInput {Enter}
Sleep, delay
;------------------------------------------------------------

;------------------------------------------------------------
; -- Minimize window, casting starts
Send {ESC}
Sleep, delay
Send #{d} ; minimize window, casting starts
;------------------------------------------------------------

CastOff-1.ahk:

;------------------------------------------------------------
; AutoHotKey Script to STOP ChromeCast in Desktop Mode
;
; Declare variables
delay := 1000
;------------------------------------------------------------


;------------------------------------------------------------
; Run Chrome
Run, C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --fullscreen --start-maximized

;Sleep, delay
Sleep, 5000

#IfWinActive, ahk_class Chrome_WidgetWin_1

; -- SEND the ALT+F key combo to open settings
SendInput !f
Sleep, delay

; -- SEND the C key combo to select CAST
SendInput c
Sleep, delay
;------------------------------------------------------------


;------------------------------------------------------------
; -- Tab  OUT of the Source Selection area ..   to be able to select correct device.
SendInput {TAB}
Sleep, delay

; -- Tab to the DEVICE we selected and 
SendInput {TAB %deviceNumber%}
Sleep, delay

; -- STOP CAST. 
SendInput {Enter}
Sleep, delay
;------------------------------------------------------------

;------------------------------------------------------------
; -- CLOSE window
Send {ESC}
Sleep, delay

Send !{f4} ; close window
;------------------------------------------------------------

I also launch this directly from within a batch file... so i can call the batch file from ANY program.. it comes in handy for applications that allow you to map key or an event into a function or activity.

Example: I have StreamDeck device i use when streaming video.. i can simply map one of the streamdeck buttons.. to launch this batch file.. and bam.. one button press on the device.. and i'm autocasting to my chromecast device as well.

CAST_ONOFF_SELECT.bat gives you a menu to select turning casting on or off.

it calls the corresponding local batch file to run AutoHotkey using the proper script for that function.

CAST_ONOFF_SELECT.bat

@ECHO OFF
CLS
ECHO.
Echo Please choose a FUNCTION:
echo.
ECHO 1. Turn ON casting to DESKTOP.
ECHO 2. Turn OFF casting.
ECHO.


CHOICE /C 12 /M "Enter your choice:"

IF ERRORLEVEL 2 GOTO CastStop
IF ERRORLEVEL 1 GOTO CastStart
GOTO End

:CastStart
ECHO "STARTING CAST"
echo.
echo.
CALL %0\..\START_DESKTOP_CASTING.bat
GOTO End

:CastStop
ECHO "STOPPING CAST"
echo.
echo.
CALL %0\..\STOP_DESKTOP_CASTING.bat
GOTO End


:End
echo Process complete.
echo.
pause

START_DESKTOP_CASTING.bat

@echo off
cd "C:\Program Files\AutoHotkey" && start "CHROMECAST START" "C:\Program Files\AutoHotkey\AutoHotkey.exe" "C:\Users\Darkstar\Videos\CastON.ahk"
exit

STOP_DESKTOP_CASTING.bat

@echo off
cd "C:\Program Files\AutoHotkey" && start "CHROMECAST START" "C:\Program Files\AutoHotkey\AutoHotkey.exe" "C:\Users\Darkstar\Videos\CastOFF.ahk"
exit