AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The Boss Key script

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Rajat



Joined: 28 Mar 2004
Posts: 1717

PostPosted: Sat Jun 19, 2004 12:56 am    Post subject: The Boss Key script Reply with quote

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

Code:

#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

_________________
Back to top
View user's profile Send private message
ParanoidX



Joined: 16 Dec 2005
Posts: 149
Location: Australia

PostPosted: Sun Feb 05, 2006 2:56 am    Post subject: Reply with quote

HAHAHAHAA!!!!

heres a word of advice... prevention is better than cure..LOL!!!
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Sun Feb 05, 2006 10:44 am    Post subject: Reply with quote

Woo, Rajat, bad boy! Very Happy
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.
Back to top
View user's profile Send private message Visit poster's website
Guest






PostPosted: Fri Jan 12, 2007 5:20 am    Post subject: it can hide all using windows,but cann't restore them Reply with quote

it can hide all using windows by #z but cann't restore them by ^#z which made me feel very anxious.
BUT WHY?
Back to top
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Fri Jan 12, 2007 5:24 pm    Post subject: Reply with quote

#^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.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
Jason as a guest
Guest





PostPosted: Tue Jan 16, 2007 3:01 am    Post subject: Reply with quote

Here is a ahk alternative i really like.
Ive used it just for that reason many times.
lol

http://www.autohotkey.com/forum/topic6182.html
Back to top
Guest






PostPosted: Fri Mar 23, 2007 8:37 pm    Post subject: Reply with quote

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.
Back to top
Rajat



Joined: 28 Mar 2004
Posts: 1717

PostPosted: Sat Mar 24, 2007 8:11 am    Post subject: Reply with quote

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! Rolling Eyes
_________________
Back to top
View user's profile Send private message
yellowsix



Joined: 17 Nov 2006
Posts: 6

PostPosted: Fri Apr 06, 2007 10:43 am    Post subject: Reply with quote

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. Very Happy
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.
Back to top
View user's profile Send private message
seclinix - offline
Guest





PostPosted: Sat Apr 07, 2007 12:53 am    Post subject: Reply with quote

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 Crying or Very sad 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 Crying or Very sad so i was in abit of trouble...

anyway my question is, is there anyway of getting me out of this trouble? Confused Sad
Back to top
Grumpy
Guest





PostPosted: Sat Apr 07, 2007 9:36 am    Post subject: Reply with quote

seclinix - offline wrote:
anyway my question is, is there anyway of getting me out of this trouble? Confused Sad
Sure... Just pay attention to your course! Razz
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group