3

I'm looking to automate rotation between multiple applications, specifically Internet Explorer windows that have been opened in kiosk mode. This is for an overhead display.

I've tried the suggestions in the article (how to perform a hold ALT+TAB sendkey event in C#) but it does not work for me. I get the following errors.

Exception calling "SendWait" with "1" argument(s): "Specified repeat count is not valid."
At line:1 char:35
+ [Windows.Forms.Sendkeys]::SendWait <<<< ("%{Alt Up}")
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

With manual testing, an alt+tab and even alt+tab+tab will only toggle between the first two/three windows and I currently have 6 with the possibility for more in the future. It looks like I might be able to try pulling up the window by title maybe but that seems unreliable.

#ADD external assemblies here
add-type -AssemblyName microsoft.VisualBasic
add-type -AssemblyName System.Windows.Forms
#Sets interval before changing screens
Start-sleep -Seconds 2
[System.Windows.Forms.SendKeys]::SendWait("%{TAB}%{tab}")
[System.Windows.Forms.SendKeys]::SendWait("%{TAB}%{tab}")

I've also tried this:

[System.Windows.Forms.SendKeys]::SendWait("%{alt down}")
[System.Windows.Forms.SendKeys]::SendWait("%{tab}")
Community
  • 1
  • 1
Bryan Halterman
  • 315
  • 4
  • 10
  • Use single quotes in your SendWait calls. I.e.: SendWait('%{TAB}%{TAB}') – David Brabant Aug 20 '14 at 17:58
  • Single quotes didn't seem to make a difference. – Bryan Halterman Aug 20 '14 at 19:14
  • It should make a difference, what error are you getting, what is happening versus what you want to happen? The code you posted doesn't even match your error – Cole9350 Aug 20 '14 at 19:15
  • I do not get anything different between single or double quotes, and no error messages. Double quotes seems to work just fine on some of the other input code I use to log into web sites. The Alt up error is the same from what I got from the alt down, I just copied it once. Powershell doesn't like the up or down in those lines. Ideally, I'm looking to switch between application automatically like you can with Alt Tab. – Bryan Halterman Aug 20 '14 at 19:32

2 Answers2

3

I figured it out.

Use SendWait("%{TAB}")

In powershell the only way to use the alt key seems to be with the % symbol.

zdanman
  • 508
  • 1
  • 3
  • 13
2

So I think I figured it out. You don't want to do an ALT + TAB for the toggle since this is a Z-Based swap. This means it only toggles between the first and second applications running. However, if you do Alt+Shift+ESC, this will tell the system to pull the last item in the list and bring it forward

Bryan Halterman
  • 315
  • 4
  • 10