App Rotator

From DanIT
Revision as of 16:49, 20 November 2021 by Dan (talk | contribs)
Jump to navigation Jump to search

App Rotator allows for automatically rotating between apps, making them visible when needed.
It

Script

Script

$app=@{}
$timeline=@()
$wshell = New-Object -ComObject WScript.Shell

function App($name, $run, $keys)
{
    $global:app += @{$name = @{ID = (Start-Process $run -PassThru).Id}}
    $wshell.SendKeys($keys)
}

function Timeline($apps, $seconds)
{
    $global:timeline += @{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) # prints true/false?
        }
        Start-Sleep -Seconds $global:timeline[$index].Seconds
    }
    Rotate
}

Apps & Timelines

After the script, add the apps you need and create the timelines.
Close it at the end with 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 3rd argument of the "App" command.

Value Description
{F11} Fullscreen
%{ENTER} Fullscreen (console application)

Google Chrome

By default, Chrome re-launches the process via the service, which results into the Process ID being incorrect.
Run Chrome with the parameter "--no-service-autorun" to avoid this, so it works with the script.

To set the window position and size, you can use the parameters "--window-position=123,123" and "--window-size=123,123".
If this doesn't work (correctly), try also using the parameter "--user-data-dir=" to give the session it's own profile.