Avatar of Rebel_no_1
Rebel_no_1Flag for China

asked on 

How to bring Hotkeyz.exe into focus and send it an Alt+F4 with a VBScript

Hi.
I have a straightforward issue:
I launch Hotkeyz.exe with a dos .bat script (Start /MIN Hotkeyz.exe) and have configured the program to go "Hidden" when I click on the close button or Press Alt+F4 on it. Therefore it doesn't close, but goes hidden, which is what I want. The problem is that it launches but it is still just minimized and not closed. The issue is that a user can then ALT+TAB to it and perform unwanted actions. Therefore I need only the following:
I need a simple vbscript which would bring into focus the Hotkeyz.exe application (Which will be minimized) and send it an Alt+F4. After this the vbscript must just close. This would then effectively tell the program to go "Hidden" and avoid the users from Alt+Tab'ing to it and potentially editing and breaking the Hotkeyz.exe app settings. (Intentionally or unintentionally) I would prefer if this script can be compatible with Windows XP and above. Please let me know if any further information is required.
VB ScriptMicrosoft DOS

Avatar of undefined
Last Comment
Rebel_no_1
ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of BillDL
BillDL
Flag of United Kingdom of Great Britain and Northern Ireland image

Hi Rebel

Rob Sampson's VBScript should work fine for what you need, but just for your additional information it is possible to create a step-by-step script and wrap it up into one program Exe using great little free applications like:
http://www.autohotkey.com/
http://www.autoitscript.com/site/autoit/

If you use little scripts quite a lot to perform repetitive tasks it might be worthwhile having a look.  basically you run through the actions in a similar way to manually recording a Macro in MS Word, except that you use the program to discover things like the Window Title and the names of the buttons, check boxes, text fields, etc, and compile your script which can then be saved as a single executable.  In other words, you could have a program launcher that opens Hotkeyz.exe and then hides it all in one go.

There are also a couple of simpler programs by the same author that wrap up BAT/CMD or VBS files into a single executable:
VBS to EXE:  http://www.f2ko.de/programs.php?lang=en&pid=v2e
(Online version to test: http://www.f2ko.de/programs.php?lang=en&pid=ov2e)
BAT to EXE:  http://www.f2ko.de/programs.php?lang=en&pid=b2e
(Online version to test: http://www.f2ko.de/programs.php?lang=en&pid=ob2e)
Various useful command line tools: http://www.f2ko.de/programs.php?lang=en&pid=cmd

Remember, this is just for your additional info in future.  Rob has answered your question with a script that should work fine for you.

Bill
Avatar of Rebel_no_1
Rebel_no_1
Flag of China image

ASKER

This script will successfully send an (ALT+F4) command to a specified application. This script will however not send the command to a program which have been minimized. This was tested on win7. Thank you Rob, this works a bit different from what I expected but It will be just fine for me. Thanks again! Much appreciated!
VB Script
VB Script

VBScript (Visual Basic Scripting Edition) is an interpreted scripting language developed by Microsoft that is modeled on Visual Basic, but with some important differences. VBScript is commonly used for automating administrative and other tasks in Windows operating systems (by means of the Windows Script Host) and for server-side scripting in ASP web applications. It is also used for client-side scripting in Internet Explorer, specifically in intranet web applications.

39K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo