Difference between revisions of "App Rotator"

From DanIT
Jump to navigation Jump to search
(Created page with "App Rotator allows for automatically rotating between apps, making them visible when needed.<br> It <pre> $app=@{} $timeline=@() $wshell = New-Object -ComObject WScript.Shell...")
 
Line 2: Line 2:
 
It
 
It
  
 +
=Script=
 +
===Script===
 
<pre>
 
<pre>
 
$app=@{}
 
$app=@{}
Line 32: Line 34:
 
</pre>
 
</pre>
  
 +
===Apps & Timelines===
 +
After the script, add the apps you need and create the timelines.<br>
 +
Close it at the end with calling the function "Rotate".
  
 
<pre>
 
<pre>
Line 43: Line 48:
 
Rotate
 
Rotate
 
</pre>
 
</pre>
 +
 +
=Tips=
 +
===Position & Size===
 +
Some applications have their own parameters to set the window position and size.<br>
 +
In case this is not an option, you can add [https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/sendkeys-statement keystrokes] to an application when launching. This is the 3rd argument of the "App" command.<br>
 +
{| class="wikitable"
 +
|-
 +
! 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.<br>
 +
Run Chrome with the parameter "--no-service-autorun" to avoid this, so it works with the script.<br>
 +
 +
To set the window position and size, you can use the parameters "--window-position=123,123" and "--window-size=123,123".<br>
 +
If this doesn't work (correctly), try also using the parameter "--user-data-dir=" to give the session it's own profile.

Revision as of 16:49, 20 November 2021

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.