Skip to content

Instantly share code, notes, and snippets.

@WA9ACE
Created December 30, 2017 02:00
Show Gist options
  • Save WA9ACE/bdd086ac14dac4a0659e512aeb4bceb3 to your computer and use it in GitHub Desktop.
Save WA9ACE/bdd086ac14dac4a0659e512aeb4bceb3 to your computer and use it in GitHub Desktop.
#NoTrayIcon
#Persistent
global hWSL
/* Setup Tray icon and add item that will handle
* double click events
*/
Menu Tray, Icon
Menu Tray, Icon, C:\Program Files\WindowsApps\CanonicalGroupLimited.UbuntuonWindows_1604.2017.922.0_x64__79rhkp1fndgsc\images\icon.ico
Menu Tray, Add, Show / Hide WSL, TrayClick
Menu Tray, Default, Show / Hide WSL
;// Run notepad hidden
DetectHiddenWindows On
Run WSL,, Hide, PID
WinWait ahk_pid %PID%
hWSL := WinExist()
DetectHiddenWindows Off
return
TrayClick:
OnTrayClick()
return
;// Show / hide notepad on double click
OnTrayClick() {
if DllCall("IsWindowVisible", "Ptr", hWSL) {
WinHide ahk_id %hWSL%
} else {
WinShow ahk_id %hWSL%
WinActivate ahk_id %hWSL%
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment