Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

The Boss Key script


  • Please log in to reply
15 replies to this topic
Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
This script might save your @$$ someday... It hides all open windows. It maintains a list of windows that should not be hidden (work apps).

Also a list of apps is kept that should be launched when Boss comes, in case you were not working at all, not even having a work window in the background!

All this at the press of a single hotkey. Press the hotkey again to show those hidden apps.

Customize the work apps in the script and the hotkeys. As the script doesn't show an icon in tray so to exit it press the hotkey for it.

Default hotkeys:
BossKey: Win+z
Exit Script: Ctrl+Win+z

#NoTrayIcon
SetTitleMatchMode, 2
SetBatchLines, 10ms
SetWinDelay, 10
B = 1


;______Windows not to hide__________________

;These window titles will be immune to the Boss key.
;don't remove 'hid1 = Shell_TrayWnd'

hid1 = Shell_TrayWnd
hid2 = Microsoft Word



;______Apps to launch_______________________

;These apps will be launched when Boss key is pressed.
;Takes care of situation when you were not working at all!

;Syntax: FilePath|WinTitle

;Giving WinTitle will make the script NOT launch an app
;if its window already exists, not giving wintitle will
;make the app be launched unconditionally

Run1 = %windir%\system32\calc.exe|Calculator
Run2 = E:\dos\batch\messages.txt|messages.txt - Notepad



;______Set Hotkeys here_____________________

Hotkey, #z, Boss	;This is the Boss key

^#z::ExitApp		;As the icon is hidden, use this hotkey to exit the script




Exit




Boss:
	
	;hides all windows with exceptions
	IfGreater, B, 0
	{
		;get all ids
		WinGet, id, list,,, Program Manager
		
		;loop for all windows
		Loop, %id%
		{
			StringTrimRight, this_id, id%a_index%, 0
			
			;get current win title
			WinGetTitle, title, ahk_id %this_id%
			
			;get current win class
			WinGetClass, class, ahk_id %this_id%
			ToHide = y
			
			;see if this is NOT to be hidden
			Loop
			{
				StringTrimRight, CWin, hid%A_Index%, 0
				IfEqual, CWin,, Break
				IfInString, title, %CWin%, SetEnv, ToHide, n
				IfInString, class, %CWin%, SetEnv, ToHide, n
				IfEqual, ToHide, n, Break
			}
			

			
			;hide windows and keep a record of windows hidden
			IfEqual, ToHide, y
			{
				WinHide, ahk_id %this_id%
				HWins = %HWins%||%this_id%
			}

		}
	}
	

	
	;shows hidden windows
	IfLess, B, 0
	{
		;show windows
		Loop, Parse, HWins, ||
			WinShow, ahk_id %A_LoopField%
	}
	
	
	
	;opens work windows
	IfGreater, B, 0
	{

		Loop
		{
			StringTrimLeft, CRun, Run%A_Index%, 0
			IfEqual, CRun,, Break
			StringGetPos, ppos, CRun, |

			StringLeft, fpath, CRun, %ppos%
			IfEqual, fpath,, SetEnv, fpath, %CRun%

			StringTrimLeft, wname, CRun, %ppos%
			StringTrimLeft, wname, wname, 1

			WinShow, %wname%
			IfWinNotExist, %wname%,, IfExist, %fpath%, Run, %fpath%
		}
	}
	

	B *= -1
Return

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


ParanoidX
  • Members
  • 148 posts
  • Last active: Jan 14 2007 02:00 AM
  • Joined: 16 Dec 2005
HAHAHAHAA!!!!

heres a word of advice... prevention is better than cure..LOL!!!

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
Woo, Rajat, bad boy! :-D
I see you took fast loading applications in the Run section... Better than an Office one, sure.
If I didn't read too fast, perhaps you should also restore the hid* windows in case they were minimized (or even hidden...).

That remind me...
One day, I received a large file (can't remember the format, somethink like video, PowerPoint or Flash, whatever) showing a Word window were somebody typed slowly a text. The purpose (for fun, not for real!) was to make believe you actually worked while you slept with open eyes and hands lightly lying on the keyboard...
I found that clumsy, because of the size of the file, and because the chosen document was in a language you may not use for work (English), and was probably unrelated to your work.
So, for fun, I wrote a MS Word macro to take a real work document, and slowly copy it in an empty one... Much smaller and more realistic.
I should dig it out someday.

  • Guests
  • Last active:
  • Joined: --
it can hide all using windows by #z but cann't restore them by ^#z which made me feel very anxious.
BUT WHY?

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
#^z exits the application without restoring the windows.
#z is a toggle key: hide then show.
Note: using a multiple desktop applet like VirtuaWin is probably a better (and more useful!) solution.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

Jason as a guest
  • Guests
  • Last active:
  • Joined: --
Here is a ahk alternative i really like.
Ive used it just for that reason many times.
lol

http://www.autohotke.../topic6182.html

  • Guests
  • Last active:
  • Joined: --
I just found this script and I love it!

One bug that I've found and I'm not real sure how to fix it:

If my mouse is hovering over something when I hit #z to toggle it on/off, a 'burn in' effect happens with the tooltip text. It is permanently shaded on the screen until I exit the script (and even then sometimes it wouldn't go away)

Don't have the first idea how to fix this, so I was wondering if anyone could recreate the error and possibly track down why this is happening.

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
Guest,
i know exactly what you're saying. i've seen that at places where AHK had nothing to do, so its most probably a windows bug. and as this script doesn't use tooltip at all, its a system displayed one and not ahk generated.

i know its annoying! :roll:

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


yellowsix
  • Members
  • 6 posts
  • Last active: Aug 13 2007 05:24 PM
  • Joined: 17 Nov 2006
LOL
I made something like this before to use on school.
Lots of my buddies made use of it, but it was kinda hard to do.
I also used an "ignore list".
I called the script WinSneak. :D
Thanks for the script.
I'm really going to make use of it.

Keep up the good work.

Yellowsix

(EDIT)

I just saw it doesn't have the start menu (BaseBar) and the program manager in the ignore list.
Of course everyone could add it by himself, but it might be handy to put it in the standard code.

seclinix - offline
  • Guests
  • Last active:
  • Joined: --
hahahaha oh sh*t it is nice script rajat!!!!!!! i attend a buisiness and admin course and my admin normally takes a stroll around the room so i use script to mask the internet explorer window but there was 1 problem one time i clicked a link and activated the hotkey and all these popups come up and it would not hide them :cry: so i was exposed for that... lol it was very funny because the admin had Radmin and was watching me type the hotkey in and there on he knew what the hotkey was so he told all the staff and the next day i was hiding windows and all of a sudden my tutor activated the hotkey on my keyboard and caught me playing Unreal Tournament 4 and downloading stuff :cry: so i was in abit of trouble...

anyway my question is, is there anyway of getting me out of this trouble? :? :(

Grumpy
  • Guests
  • Last active:
  • Joined: --

anyway my question is, is there anyway of getting me out of this trouble? :? :(

Sure... Just pay attention to your course! :-P

bengo
  • Guests
  • Last active:
  • Joined: --
can you add volume mute (with minimize) and volume back?

SoggyDog
  • Members
  • 803 posts
  • Last active: Mar 04 2013 06:27 AM
  • Joined: 02 May 2006
Without even looking at the code, it shouldn't be too hard to throw the volume toggle in where the routines are executed.
Send {Volume_Mute}


dvation
  • Guests
  • Last active:
  • Joined: --
Not sure if this is a limitation of Windows design, AutoHotKey or the script itself, but the script works beautifully for me in all but one instance.

I've noticed that if my mouse has focus inside a VNC or Remote Desktop session, WIN+Z does nothing. If there's any way to fix this, that would be awesome.

  • Guests
  • Last active:
  • Joined: --

I've noticed that if my mouse has focus inside a VNC or Remote Desktop session, WIN+Z does nothing.

...probably cuz the VNC is taking over Win+Z. You could change the script to use a different key...or attempt to get AutoHotkey to override the VNC hotkey.