Solved

Script to swap active programs in Windows 7

Posted on 2014-07-29
15
532 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 52

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 52

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
 

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 52

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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 52

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 52

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 52

Expert Comment

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

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 52

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 52

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
The viewer will learn how to create multiple layers to apply various filters and how to delete areas from each layer’s filter.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

895 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

16 Experts available now in Live!

Get 1:1 Help Now