Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Script to swap active programs in Windows 7

Posted on 2014-07-29
15
559 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 53

Accepted Solution

by:
Joe Winograd, EE MVE earned 500 total points
ID: 40226904
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
ID: 40226906
Excellent Thank you. I will give it a try now, and report back.

Regards

Darren
0
 
LVL 53

Expert Comment

by:Joe Winograd, EE MVE
ID: 40226922
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
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)

 

Author Comment

by:DarrenEley
ID: 40226957
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 53

Expert Comment

by:Joe Winograd, EE MVE
ID: 40226992
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
ID: 40227077
Excellent Help!! Cant thank you enough. Regards Darren
0
 
LVL 53

Expert Comment

by:Joe Winograd, EE MVE
ID: 40227099
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 53

Expert Comment

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

Expert Comment

by:Joe Winograd, EE MVE
ID: 40234247
Perfect! Thanks much.
0
 
LVL 53

Expert Comment

by:Joe Winograd, EE MVE
ID: 40234283
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
ID: 40234304
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 53

Expert Comment

by:Joe Winograd, EE MVE
ID: 40234352
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 53

Expert Comment

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

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
iSeries email authority 6 75
sp_configure 'external scripts enabled', 1; 7 79
Run AutoHotkey script directly from Notepad++ 5 69
Programming Codes 2 22
Let’s list some of the technologies that enable smooth teleworking. 
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Video by: Tony
This video teaches viewers how to export a project from Adobe Premiere Pro and the various file types involved.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

837 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