Toggle ( Run or Show ) / ( Hide ) Window

Post your working scripts, libraries and tools
Posts: 1
Joined: 19 Mar 2018, 06:49

Toggle ( Run or Show ) / ( Hide ) Window

19 Mar 2018, 10:05

I needed a way to conveniently open my calculator, so I made this script.

Only shortcut is Alt + Ctrl + P.
If calculator Speedcrunch.exe is not open, this shortcut will open it.
Afterward, this shortcut is toggle for hide/show Speedcrunch.exe window. Even taskbar button will be hidden.

If program is minimized, this shortcut will restore window and will place it on the top.
If calculator window is behind some other program, this shortcut will bring Speedcrunch.exe window on top.

When calculator window is hidden, focus will go back to last active window. Last active window will be remembered in C:\SpeedCrunchONOFF.txt INI file.
For this reason you have to make one "C:\SpeedCrunchONOFF.txt" INI file, and you have to place this text inside of it.

Code: Select all

If you want to close Speedcrunch, that is done manually. Just click "X".

This is text of a script.

Code: Select all

SetWorkingDir %A_ScriptDir%
CoordMode, Mouse, Window
SendMode Input
#SingleInstance Force
SetControlDelay 1
SetWinDelay 0
SetKeyDelay -1
SetMouseDelay -1
SetBatchLines -1

SetTitleMatchMode, 3

ErrorLevel = % ProcessExist( "speedcrunch.exe" ) 

	return Errorlevel

If ErrorLevel = 0
	Run C:\Program Files (x86)\SpeedCrunch\speedcrunch.exe

IfWinActive, SpeedCrunch
	WinHide, SpeedCrunch
	IniRead, returnActiveWindowTitle, C:\SpeedCrunchONOFF.txt, Etc, LastActiveWindow
	WinActivate, % returnActiveWindowTitle
	WinGetActiveTitle, goActiveWindowTitle
	IniWrite, % goActiveWindowTitle, C:\SpeedCrunchONOFF.txt, Etc, LastActiveWindow
	WinRestore, SpeedCrunch
	WinShow, SpeedCrunch
	WinActivate, SpeedCrunch

Return to “Scripts and Functions”

Who is online

Users browsing this forum: Xtra and 38 guests