Difference between revisions of "App Rotator"

From DanIT
Jump to navigation Jump to search
 
Line 101: Line 101:
 
To set the window position and size, you can use the parameters "--window-position=123,123" and "--window-size=123,123".<br>
 
To set the window position and size, you can use the parameters "--window-position=123,123" and "--window-size=123,123".<br>
 
This only works when also using "--user-data-dir="C:\ExampleFolder"" for each Chrome App to give it it's own profile.<br>
 
This only works when also using "--user-data-dir="C:\ExampleFolder"" for each Chrome App to give it it's own profile.<br>
 +
 +
====Microsoft Edge====
 +
To set the window position and size, you can use the parameters "--window-position=123,123" and "--window-size=123,123".<br>

Latest revision as of 01:33, 23 January 2022

App Rotator allows for automatically rotating between multiple applications, making them visible on a preset interval.

Script

Script

Register-EngineEvent PowerShell.Exiting -SupportEvent -Action {
    Start-Process -FilePath "taskkill.exe" -ArgumentList $global:kill
}
Write-Host "Press CTRL+C to close all open windows." -ForegroundColor Yellow

$app=@{}
$timeline=@{}
$wshell = New-Object -ComObject WScript.Shell
$kill = ""

function App($name, $run, $refresh, $keys)
{
    $global:app += @{$name = @{
        ID = (Start-Process $run -PassThru).Id
        Refresh = $refresh
        NextRefresh = (Get-Date).AddSeconds($refresh)
    }}
    $global:kill += " /pid "+ $global:app[$name].ID

    $wshell.SendKeys($keys)
}

function Timeline($apps, $seconds)
{
    $global:timeline += @{$global:timeline.Count = @{Apps = $apps; Seconds = $seconds}}
}

function Rotate
{
    for($index = 0; $index -lt $global:timeline.Count; $index++)
    {
        foreach($app in $global:timeline[$index].Apps)
        {
            $wshell.AppActivate($global:app[$app].ID) > $null

            if($global:app[$app].Refresh -and $global:app[$app].NextRefresh -le (Get-Date))
            {
                $wshell.SendKeys("{F5}")
                $global:app[$app].NextRefresh = (Get-Date).AddSeconds($global:app[$app].Refresh)
            }
        }
        Start-Sleep -Seconds $global:timeline[$index].Seconds
    }
    Rotate
}

Apps & Timelines

After the script, you need to add Apps and Timelines.

First of all, create all the Apps that you're going to use; give them a unique name, and enter the location of the file.
After that, create Timelines by setting what App(s) need to be shown at a given time, and how long they will stay until the next timeline.

Close it at the end by calling the function "Rotate".

App "app1" "notepad.exe"
App "app2" "mspaint.exe"
App "app3" "cmd.exe"

Timeline "app1","app2" 10
Timeline "app3" 5

Rotate

Tips

Position & Size

Some applications have their own parameters to set the window position and size.
In case this is not an option, you can add keystrokes to an application when launching. This is the 4rd argument of the "App" command.

Value Description
{F11} Fullscreen
%{ENTER} Fullscreen (console application)
{PGDN} Scroll down (add consecutively for more)

Websites

Because you want to use parameters with websites, it might be better to create a shortcut (.lnk file) and run it from there.

App "CNN" "C:\Temp\News.lnk" 60

Some websites don't automatically refresh (F5), use the 3rd argument to set the amount of seconds between each refresh.
Please note, a refresh can only take place after a timeline has passed.

Google Chrome

For Google Chrome, make sure to add the parameter "--no-service-autorun" to make it compatible with this script.

Use the parameter "--app="https://google.com/"" to set the website that needs to be shown.
This also removes unnecessary bars. Make sure the URL includes "http://" or "https://".

To set the window position and size, you can use the parameters "--window-position=123,123" and "--window-size=123,123".
This only works when also using "--user-data-dir="C:\ExampleFolder"" for each Chrome App to give it it's own profile.

Microsoft Edge

To set the window position and size, you can use the parameters "--window-position=123,123" and "--window-size=123,123".