Start/Toogle/Activate App/Program/Window Quickly - Including Chrome WebApps - Single Hotkey

Post your working scripts, libraries and tools
DigiDon
Posts: 31
Joined: 19 May 2014, 04:55

Start/Toogle/Activate App/Program/Window Quickly - Including Chrome WebApps - Single Hotkey

13 Jun 2017, 10:23

Hi, I think this can interest some people :P
EDIT: This could maybe be moved in Tutorials

This is my simple way of starting/toogling Apps Quicly - Including quick Google Chrome WebApps.
What's really interesting is how you can start it in a smart way to toogle or start quickly your favorite pgrms or ... Google chrome web apps
(Yeah that's what I really like as I figured out the parameter "--app" to do it! :dance: )
With web apps it means you can toogle or start every website as an external app having its own window/icon.
The second interesting thing IMHO is the single hotkey example to start your subroutine or menu.
See at bottom for examples

By Toogling I mean : if the window exist then it is brought to foreground. If it is already in foreground it is Minimized (although this won't be of much use except with single hotkey).
If it is not found then the program is started with optional parameters.

It relies on a simple function to Toogle a window based on some Wintitle parts and the .exe process OR Start the .exe with some parameters :
ToogleOrStart Function

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



How to use the function
Somewhere in your code to Toogle or Start you have to call the function
e.g. For Notepad, simply use :

Code: [Select all] [Download] GeSHi © Codebox Plus

ToogleOrStart("Notepad")
;or
;ToogleOrStart("Notepad.exe")

Other software which did not register in Windows environnement Path will need the full path to the .exe

Code: [Select all] [Download] GeSHi © Codebox Plus

ToogleOrStart("C:\Program Files\CustomSoftware.exe")

Ifyou want to Detect a specific window put some Wintitle Parts in the second parameters:
e.g. For Toogling a new Notepad (untitled) or starting one that could be :

Code: [Select all] [Download] GeSHi © Codebox Plus

ToogleOrStart("Notepad","Untitled")


...With Google Chrome Web Apps
Now let's say you want to Toogle or start some music at 8tracks.com as a web app (I'm sure many of you could be interested by using it for Facebook and many other web apps)
You can use :

Code: [Select all] [Download] GeSHi © Codebox Plus

ToogleOrStart("chrome.exe","8tracks","--app=http://8tracks.com/login")


How to implement it?
Here are some ideas:

We will start by the simpliest way with a standard hotkey, which I quite DISlike.
EXAMPLE WITH HOTKEY: CTRL + SHIFT + T

Code: [Select all] [Download] GeSHi © Codebox Plus

^+t::Gosub Toogle8tracks

Toogle8tracks:
ToogleOrStart("chrome.exe","8tracks","--app=http://8tracks.com/login")
return


Here are some more interesting ways:

EXAMPLE WITH SINGLE KEY HOTKEY !!!
This will start 8tracks as a web app by simply holding down the "_" key (This is the 8 at top of my French Keyboard, that's why ;) )
!WARNING! THESE SINGLE KEY HOTKEYS TEND TO SLOW DOWN THE USED KEY A BIT AND LONG PRESS FOR FAST REAPEAT WON'T WORK ANYMORE
SO I SUGGEST YOU JUST USE SPECIAL KEYS SUCH AS THE ONE ON TOP OF KEYBOARDS OR SPECIAL CHARACTERS
EXAMPLE WITH LONG "_" KEY PRESS
IF YOU CHANGE THE HOTKEY YOU NEED TO MODIFY IT IN 4 PLACES : The Hotkey label the 2 KeyWait and the SendInput

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus




EXAMPLE WITH A CONTEXT MENU
STARTED BY CTRL+SHIFT+T (but could be single key hotkey as well!!)

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Do you like it ? :xmas:
Don't hesitate to comment for ideas and related things ;)
Knowledge is knowing a tomato is a fruit; wisdom is not putting it in a fruit salad. (Miles Kington)
When I die, I want to go peacefully like my grandfather did–in his sleep. Not yelling and screaming like the passengers in his car. (Bob Monkhouse)

Return to “Scripts and Functions”

Who is online

Users browsing this forum: neokix and 12 guests