FUNCTION GetForegroundWindow%&
'find currently focused process handle
title$ = "Cheapo Hotkey (Shift+A)" 'title of program window
_TITLE title$
'set program title
_DELAY .1 ' I found this delay is needed to get the _TITLE function to catch up and be read by the API function.
hwnd%&
= FindWindowA
(0, title$
+ CHR$(0)) 'find this program's process handle
PRINT "Minimize window, click another then Press Shift+A to bring it back up."
'=== below minimizes it for you
x& = ShowWindow&(hwnd%&, 2)
'===========================
IF GetKeyState
(16) < 0 AND GetKeyState
(ASC("A")) < 0 THEN '<==== Shift+A FGwin%& = GetForegroundWindow%& 'get current process in focus
PRINT "Program Handle:"; hwnd%&;
"Focus handle:"; FGwin%&
y& = ShowWindow&(hwnd%&, 1) 'maximize minimized program
IF FGwin%&
<> hwnd%&
THEN z&
= SetForegroundWindow&
(hwnd%&
) 'set focus when necessary
PRINT "That is all. Return values:"; x&; y&; z&
_DELAY 5:
END 'delay allows user to not minimize the window
_LIMIT 30 'save CPU usage while waiting for key press