Add shortcut to Desktop - to cast desktop via ChromeCast

0

I am in need of a solution to add some kind of Shortcut to a Desktop where by the shortcut will cast the desktop to Chromecast.

I'm basically looking to simply the process for our Users as they can't seem to do ALT + F, then C or click the 3 dots.. cast etc.

I've had a Google, but can't seem to find any successful results.

I was thinking of going along the lines of creating a Batch File for this or perhaps a Macro that could quickly do it? I'm out of ideas to be honest. I know I can launch Chrome via the batch script.

ST34M

Posted 2019-03-08T11:05:16.837

Reputation: 175

Yes, but please note that https://superuser.com is not a free script/code writing service. If you tell us what you have tried so far (include the scripts/code you are already using) and where you are stuck then we can try to help with specific problems. You should also read How do I ask a good question?.

– DavidPostill – 2019-03-08T11:08:21.180

@DavidPostill I have edited by question. – ST34M – 2019-03-10T09:54:42.153

Answers

0

So, I have a partial solution, and as of know, it's the only solution I know of. The only part I couldn't figure out was how to switch from casting tab to casting desktop. But, here's a nifty powershell script that you can use.

PowerShell.exe -windowstyle hidden { 
    if (Test-Path variable:global:wshell) {
        Clear-Variable wshell -Scope Global } 
    $wshell = New-Object -ComObject wscript.shell; 
    if (!$wshell.AppActivate("chrome")){
        ."\Program Files (x86)\Google\Chrome\Application\chrome.exe"
        Sleep 1
    }
    $wshell.AppActivate("chrome")
    Sleep .5
    $wshell.SendKeys('%(f)')
    Sleep .5
    $wshell.SendKeys('c')
    exit
}

And if you save this as a ps1 file (such as chromecast.ps1) in your documents, you can create a shortcut on the desktop that points to this file. (You can then go into the properties of the shortcut and change the icon if you'd like).

CodeNeedsCoffee

Posted 2019-03-08T11:05:16.837

Reputation: 1

0

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.

Marcel Pennock

Posted 2019-03-08T11:05:16.837

Reputation: 1