Solved

Script to swap active programs in Windows 7

Posted on 2014-07-29
15
520 Views
Last Modified: 2014-08-01
Hello, Wondering if someone can help me?

I would like a script which can swap two open applications on a display machine which we have running a wallboard screen PC.

We have one program shows the call stats for a team called DisplayX and the other is our internal website with company information which will be displayed on Internet explorer.

So the DisplayX gets maximised and is displayed as the main program full screen for approx. 30-40 seconds and then it minimizes the DisplayX software and maximizes an internet explorer page and then minimizes and switches back to the DisplayX.

Both applications will be loaded on the machine start-up.

Anyone out there have a solution for this?

Thank you in advance.

Darren
0
Comment
Question by:DarrenEley
  • 9
  • 4
15 Comments
 
LVL 51

Accepted Solution

by:
Joe Winograd, EE MVE earned 500 total points
Comment Utility
Hi Darren,

I'm a big fan of a (free!) programming language called AutoHotkey. Here's an EE article that shows where/how to download and install it:
http://www.experts-exchange.com/Web_Development/Document_Imaging/A_13315-How-to-Combine-Merge-PDF-Files-in-Many-Subfolders.html

The article is about a different topic — you may safely ignore most of it — use it just for the sections on downloading, installing, and compiling AutoHotkey (you don't need the other program, PDFtk).

Here's the program that does exactly what you want:
SetTitleMatchMode,2 ; title must contain specified text
Loop
{
  WinActivate,DisplayX ; title is case sensitive
  Sleep,30000 ; wait 30 seconds
  WinActivate,Internet Explorer ; title is case sensitive
  Sleep,30000; wait 30 seconds
}

Open in new window

After you've installed AutoHotkey, it will own the file type AHK. So simply double-click on the AHK file with the above code in it (I attached it for your convenience). This will loop forever. If you want to exit the program, simply right-click on the AutoHotkey icon in the system tray and select Exit. The icon looks like this:

AutoHotkey default icon
You could get a lot fancier with the program, such as making the swap time an input parameter (it is now hard-coded at 30,000 milliseconds=30 seconds), making the windows titles input params (hard-coded now as "DisplayX" and "Internet Explorer"), making it easier to terminate (although right-click/Exit is pretty easy), etc.

But those 8 lines of code do what you want. Btw, if you want to compile the program into an executable (an EXE file), the article mentioned above shows how to do it. Regards, Joe
SwapPrograms.ahk
0
 

Author Comment

by:DarrenEley
Comment Utility
Excellent Thank you. I will give it a try now, and report back.

Regards

Darren
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
Comment Utility
Darren,
In copying/pasting the code from the post to the AHK file, I made an error (the Loop statement wound up on the wrong line). Attached is the corrected AHK file. Also, here's the code with some better comments:
SetTitleMatchMode,2 ; the "2" option means title must CONTAIN specified text
Loop
{
  WinActivate,DisplayX ; title is case sensitive
  Sleep,30000 ; wait 30 seconds (time is specified in milliseconds)
  WinActivate,Internet Explorer ; title is case sensitive
  Sleep,30000 ; wait 30 seconds (time is specified in milliseconds)
}

Open in new window

Also, if you do want to get fancier, the article shows how to do it. Regards, Joe
SwapPrograms.ahk
0
 

Author Comment

by:DarrenEley
Comment Utility
Hiya, Thank you, Works kind of perfectly. If you could possibly offer some advice.

DisplayX is run in full screen mode (F11), so I need it to come out of Full screen (F11) before it does the switch to IE which then needs to be put in to full screen mode (F11) and then out of full screen and back to DisplayX in Full screen.... That's a lot of Full Screens.. :)

How would I achieve this if its not too much trouble.

I will have a read though the manual as I can see this is a very handy tool, but if you are able to help I would be very grateful, so I can get this completed.

Regards

Darren
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
Comment Utility
It swaps them fine if both windows are maximized, but I haven't tested full-screen mode (which I never use). If you want to send an F11, put this statement in the program:

Send {F11}

Regards, Joe
0
 

Author Comment

by:DarrenEley
Comment Utility
Excellent Help!! Cant thank you enough. Regards Darren
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
Comment Utility
Darren,
You're very welcome! You could do me a big favor by clicking the Request Attention link under the question and asking to re-open the question and then selecting my first or second post as the answer. The reason is that my article, which is referenced in both of those first two posts, will then get some credit (points) as being part of the Accepted Solution. That would thank me enough. :)  Regards, Joe

P.S. And if it's not asking too much, you could give the article a Helpful=Yes vote.
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
Comment Utility
Hi eenookami,
It's still showing http:#a40226992 as the Accepted Solution. Regards, Joe
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
Comment Utility
Perfect! Thanks much.
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
Comment Utility
Darren,
Thanks for making the extra effort to do that — I really appreciate it! Next step is to give the article a Helpful=Yes vote. :)  And thanks again to eenookami for reopening it. Regards, Joe
0
 

Author Comment

by:DarrenEley
Comment Utility
Hiya, Joe, Sorry to be a bit dim here but I cant find anything about Helpful=Yes vote button or anything... Where do I find it, and I will for sure press it :)

Regards

Darren
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
Comment Utility
Go to the article that was helpful and scroll to the bottom of it, but before the reader comments begin. On the right side, you'll see this:

article helpful
Just click the green check-mark. Thanks!
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
Comment Utility
Darren,
Thanks for the "upvote" (the short name for a Helpful=Yes vote) — on both articles! Much appreciated! Regards, Joe
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Today companies are subjected to more-and-more data, and it won't stop any time soon.  But there are obvious opportunities for reducing data, particularly data duplicated among companies.
This is about my first experience with programming Arduino.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now