Solved

Script to swap active programs in Windows 7

Posted on 2014-07-29
15
585 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
[X]
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
  • 9
  • 4
15 Comments
 
LVL 54

Accepted Solution

by:
Joe Winograd, EE MVE 2015&2016 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 54

Expert Comment

by:Joe Winograd, EE MVE 2015&2016
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
The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

 

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 54

Expert Comment

by:Joe Winograd, EE MVE 2015&2016
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 54

Expert Comment

by:Joe Winograd, EE MVE 2015&2016
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 54

Expert Comment

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

Expert Comment

by:Joe Winograd, EE MVE 2015&2016
ID: 40234247
Perfect! Thanks much.
0
 
LVL 54

Expert Comment

by:Joe Winograd, EE MVE 2015&2016
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 54

Expert Comment

by:Joe Winograd, EE MVE 2015&2016
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 54

Expert Comment

by:Joe Winograd, EE MVE 2015&2016
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

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.

Question has a verified solution.

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

There are many software programs on offer that will claim to magically speed up your computer. The best advice I can give you is to avoid them like the plague, because they will often cause far more problems than they solve. Try some of these "do it…
Invest in your employees with these five simple steps to improve employee engagement and retention.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Starting up a Project

729 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