6

Does an application exist that will cause the computer to switch (bring in to focus) between two different applications, on a timer? This is for Windows 7.

I need this for a screen that will display publicly to customers. I want the screen to switch between two different applications every, say, 30 seconds. I figure there are enough businesses out there will customer-facing monitors these days that something simple like this must exist!

5 Answers 5

13

Yes, it is called AutoIt.

You would use something like this:

While 1 ;loop indefinitely
    WinActivate("notepad","") ;give focus to notepad
    Sleep(30000) ;sleep 30 seconds
    WinActivate("wordpad","") ;give focus to wordpad
    Sleep(30000) ;sleep 30 seconds
WEnd

WinActivate() gives focus to the window with exact or closest matching title, in cases where there are two that fit, it gives focus to the most recently activated one. Sleep() is in milliseconds, so 30000 is 30 seconds.

3
  • 1
    Yep, writing my own AutoIt script was going to be my backup plan and since you saved me some trouble by providing example code I'll just accept your answer. Thanks! Aug 24, 2011 at 22:05
  • Worked like a charm. I needed to compare two pdf documents and used a cycle of 500ms. To stop it conveniently I bound the ESC button to a terminate function (HotKeySet("{ESC}", "Terminate")) like here: autoitscript.com/autoit3/docs/functions/HotKeySet.htm May 28, 2014 at 5:40
  • (Also will throw in AutoHotKey as a similar option, from what I've seen each has pluses and minuses [and there are also two separate design versions of AHK to make things more complex]... but any are reasonable options from what I can see!) Jun 23, 2022 at 9:03
6

AutoTab is very simple.

http://www.analogx.com/contents/download/System/autotab/Freeware.htm

1
6

Why install a program (like AutoIt) when Windows can do this out of the box?

Save the following into a file called auto_switch.vbs:

Option Explicit
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
Do
    WScript.Sleep 30000
    WshShell.SendKeys("%{TAB}")
Loop

Change the 30000 to be the number of milliseconds (so 30000 = 30 seconds) between Alt+Tab presses. Double click on it to start it running.

If you want to stop it, then you need to kill the process called "wscript".

If you want to switch between explicitly named programs then this code will flip between "Inbox - Microsoft Outlook" and "Firefox" every 30 seconds:

Option Explicit
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
Do
    WScript.Sleep 30000
    WshShell.AppActivate("Inbox - Microsoft Outlook")
    ' WshShell.SendKeys "% r"
    WScript.Sleep 30000
    WshShell.AppActivate("Firefox")
    ' WshShell.SendKeys "% r"
Loop

It's worth noting that if the applications in the example above are minimized then they will remain minimized even after they are activated.

To restore the window as well, remove the ' in front of the WshShell.SendKeys. This will make the script active the window and then immediately send the restore key combination Alt+SpaceBar, r. If you're using a non-English version of Windows, you may need to change this shortcut.

5
  • Nice. Just curious (I'm not on Windows): why would you need to include "Inbox" for Outlook, but not the page title for Firefox?
    – Arjan
    Jan 11, 2014 at 15:58
  • To be honest, I just copied the name of the window titles when I wrote up the example (and Firefox was showing a blank page). According to msdn.microsoft.com/en-us/library/wzcddbek(v=vs.84).aspx, AppActivate will attempt to match an exact window title first and, if it can't, will then go for the first window that begins with that string.
    – Richard
    Jan 12, 2014 at 22:41
  • ESET antivirus automatically flagged this script as VBS/BadJoke and deleted this script on my machine when I tried to run it
    – phury
    Aug 7, 2019 at 15:50
  • @phury I'm guessing ESET doesn't like the AppActivate call inside a loop. Short of whitelisting the script or using another virus checker I'm not sure what to suggest, sorry.
    – Richard
    Aug 7, 2019 at 16:55
  • Excellent answer. To activate minimized windows: WshShell.SendKeys("~");
    – Zimba
    Feb 28, 2020 at 12:27
3

If there will not be any interaction between the customers and the screens/applications, you should simply take a screenshot of the programs and then create a simple slide show with a 30-second timer and endless repeat.

Generally, companies that use customer facing monitors that display programs for advertisement purposes do not use "live" programs. You want to control the interface, and allowing the chance of some error to show is not what you want. They'll record screen videos of the programs working, or simple take screenshots for static display.

Otherwise, there are specific dashboards that are used that display specific information, and these are not switched between, generally. Or, they're switched using A/V equipment so that each program is running on a different computer so as to minimize, once again, the chance of failure.

1
  • I thought of that, but unfortunately one of the applications being switched to dynamically loads content from the web (think RSS reader) so a static image won't work Aug 24, 2011 at 21:26
-1

The following allows you to switch between 6 programs without having to name them. Basically, enter 1 less {TAB} than the number of windows you want to switch between, and don't have any extraneous open windows.

Works for up to 6 windows as far as I know, probably more.

Option Explicit
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
Do
  WScript.Sleep 1000
  WshShell.SendKeys("%({TAB}{TAB}{TAB}{TAB}{TAB})")
Loop

Not the answer you're looking for? Browse other questions tagged .