Go Back   The macosxhints Forums > OS X Help Requests > System



Reply
 
Thread Tools Rate Thread Display Modes
Old 08-17-2004, 03:59 AM   #1
switcher
Prospect
 
Join Date: Aug 2004
Posts: 1
cmd-tab to switch between all windows?

Hi,

I am new to mac osx, so far it has been a nice experience, but one thing is driving me crazy: command-tab cycles through all apps, but not the all the windows that the app has open, is there some way to make that happen, or a third party add-on? I know about expose, but it's not a good substitute. Basically I'd like it to work like windows alt-tab.

thanks,
Joe
switcher is offline   Reply With Quote
Old 08-17-2004, 04:40 AM   #2
roncross@cox.net
MVP
 
Join Date: Jan 2004
Posts: 1,496
Sorry, I don't know how to do this in command-tab

I don't know how to do this on a Mac, except Expose for windows, and personally I avoid it like the plague. I use alt-tab on a windows machine at work and it sucks, big time!!! Half the time you don't see all the windows because only so many windows are visible in the crappy dialog that is displayed. 2nd the windows are not organized in the crappy dialog that is displayed. For example, you may see an excel document on the 1st and 3rd row; or you may not see it at all until you cycle through a few rows. Windows alt-tab would be much better if all the windows in alt tab were organized by applications. There doesn't appear to be any organization in using the alt-tab command. Windows task bar is not that must better. I do have to agree with you on one point. Expose for windows is not that much better especially when you have a lot of windows opens. Both Macs and Windows are terrible handling window switching when a lot of windows are opened. The best strategy to switching in a Mac is to switch using Expose for all applications and then use the tab key to switch through the applications. This way you get to see all of your windows organized by applications. It would be nice if windows had something like this, but they don't.

The other thing that sucks about alt-tab is that when you press the keys, the windows switch way to fast. You have to do each window click by click by click or else the windows will scroll to fast for you to get a lock on them. You are not able to use the mouse to select a window in alt-tab. These are the reasons why I stay away from it. At least on the MAC, you can you the mouse as well as the keyboard to do window switching.

If you are looking for a third party app that does this, then I would recommend trying virtual PC. Its the closest thing to running windows on a Mac.

thx
RLC

Last edited by roncross@cox.net; 08-17-2004 at 04:52 AM.
roncross@cox.net is offline   Reply With Quote
Old 08-17-2004, 09:17 AM   #3
griffman
Site Admin
 
Join Date: Dec 2001
Location: Portland, OR
Posts: 1,447
Well, VirtualPC won't really help, as it will only switch the windows inside VirtualPC.

There are some apps that will help, but probably not precisely replace the behavior you're used to. The first is actually the dock; just control-click (or right click or click and hold) on an app's dock icon, and you can pick any open document and jump directly to it.

Second, a launcher program called DragThing enables you to create a floating window listing all open windows; every window on your machine is now but a click away -- I use this one all the time.

I'm sure there are others, but those are two solutions that come to mind.

regards;
-rob.
griffman is offline   Reply With Quote
Old 08-17-2004, 09:49 AM   #4
Craig R. Arko
Site Admin
 
Join Date: Dec 2001
Location: Minneapolis, MN
Posts: 3,787
Although this can be app specific, generally Cmd-` will rotate through the open windows of an App. (The ` key is usually in between the tab and escape keys). So the process does involve moving one finger. Easier than playing the violin, though.
Craig R. Arko is online now   Reply With Quote
Old 08-17-2004, 11:19 AM   #5
roncross@cox.net
MVP
 
Join Date: Jan 2004
Posts: 1,496
Quote:
Originally Posted by griffman

Second, a launcher program called DragThing enables you to create a floating window listing all open windows; every window on your machine is now but a click away -- I use this one all the time.

griffman, how do you get dragthing window dock to show you hidden windows? If I hide a window, then I am not able to see it in dragthing. I can probably write a script to do this, but I was wondering if there is an easier way to do this. In other words, I would like to see all windows in the window dock whether they are minimized, hidden, frontmost, or in the background.

The process dock is perfect as it shows all running applications whether they are background, hidden or not. I guess I am asking how do you do the same thing in the window dock?

thx
RLC
roncross@cox.net is offline   Reply With Quote
Old 08-17-2004, 11:46 AM   #6
jbc
All Star
 
Join Date: Feb 2003
Location: Chico, CA
Posts: 676
Rob forgot to mention that Dragthing also allows you to assign a hot key to cycling through the windows listed in the Window Dock. If you sort the Window Dock by Application in the preferences, I think the behavior is very close to what the original poster was asking about. The default hot keys for moving forward and backward through the window list are control-tab and control-shift-tab.
jbc is offline   Reply With Quote
Old 08-17-2004, 11:58 AM   #7
roncross@cox.net
MVP
 
Join Date: Jan 2004
Posts: 1,496
Works fine unless the window is hidden

Quote:
Originally Posted by jbc
Rob forgot to mention that Dragthing also allows you to assign a hot key to cycling through the windows listed in the Window Dock. If you sort the Window Dock by Application in the preferences, I think the behavior is very close to what the original poster was asking about. The default hot keys for moving forward and backward through the window list are control-tab and control-shift-tab.

How do you show ALL windows? I would like to see my hidden windows in the window dock.

thx
RLC
roncross@cox.net is offline   Reply With Quote
Old 08-17-2004, 12:09 PM   #8
jbc
All Star
 
Join Date: Feb 2003
Location: Chico, CA
Posts: 676
Played with this a little...Dragthing seems to take removing hidden applications from the lists pretty seriously. The windows disappear not only from the Window Dock, but also from the contextual window menus you get in the Process Dock and normal docks for each application (must be turned on in preferences).

Seem to me like you'll first need to unhide or activate the application you want before the windows become accessible. You could probably script something like unhiding all processes for 5 seconds, then rehiding the previously hidden ones unless it's the frontmost process, thus giving you a chance to select the window you want. Dragthing is very scriptable.

Just a rough first thought...
jbc is offline   Reply With Quote
Old 08-17-2004, 01:25 PM   #9
roncross@cox.net
MVP
 
Join Date: Jan 2004
Posts: 1,496
Another solution to seeing all windows in the window dock

You could just simply not hide applications and minimize them, but I have gotten use to hiding applications. It is very convenient. Beside, if you minimize every window that you have, then the dock becomes pretty useless.

Your idea sounds like a good rough draft, however, unhiding all applications will bring up a lot of stuff on your screen. I would recommend the following changes to your original proposal. Maybe we could write a script to create a list of hidden applications. Do a show all command and minimize windows in the list of hidden applications simultaneously. Time it for like 5 to 10 seconds and then rehide the applications that were previously hidden. This way you can select the window from the windows dock.

Another possible solution is to ask the author to fix this for us. If he has a reason for doing this, then I would like to know why.


I guess I should say one good thing about alt-tabs in windows. It will cycle through all the windows since windows does not have a hide application. This is the only possitive thing that I have to say about alt-tabs in windows.

thx
RLC
roncross@cox.net is offline   Reply With Quote
Old 08-17-2004, 02:00 PM   #10
griffman
Site Admin
 
Join Date: Dec 2001
Location: Portland, OR
Posts: 1,447
I've just written to James Thompson (DragThing's author) asking him if he can add a feature to optionally show hidden windows in a "semi-transparent" manner, ala the dock with the "showhidden" feature enabled for apps.

I'll post back anything interesting...

Also, don't forget you can also assign the window dock a hotkey, so you can activate it from any app, and then cycle thru it.

-rob.
griffman is offline   Reply With Quote
Old 08-17-2004, 05:34 PM   #11
griffman
Site Admin
 
Join Date: Dec 2001
Location: Portland, OR
Posts: 1,447
Bad news . Here's James' reply:


Quote:
Unfortunately you're right - the mechanism I use to get the list of windows
for other apps doesn't really let me get them for hidden applications. When
the application hides, I get told all the windows have gone away. There was
some talk by Apple that they might change this behaviour, so it might be
something I can do in the future...

So no fix in the near term ... it's a system limitation.

-rob.
griffman is offline   Reply With Quote
Old 08-17-2004, 05:38 PM   #12
roncross@cox.net
MVP
 
Join Date: Jan 2004
Posts: 1,496
Time to write the script

I guess that we'll have to start working on that script. Being able to script Dragthing is actually a plus and I appreciate the effort the author took in making Dragthing scriptable.

thx
RLC

Last edited by roncross@cox.net; 08-17-2004 at 05:52 PM.
roncross@cox.net is offline   Reply With Quote
Old 08-18-2004, 02:03 PM   #13
Hal Itosis
MVP
 
Join Date: Apr 2002
Posts: 2,396
Used to use 'Program Switcher' back in the pre-OSX days. It has now morphed into Keyboard Maestro and -- I think -- it provides the window switching control sought here. Though... finding specific details in the online manual proved difficult. Here's the best I could do:

>
Quote:
Basic Concepts

Program Switcher Keystroke

This is a pair of keys that you press to activate the application or window switching feature of Program Switcher. This sequence defaults to option and tab for application switching. This key sequences may be altered on the Program Switcher Tab of Keyboard Maestro. When pressing this keystroke, be sure that you hold down the activator key (usually the option, control, or command key) prior to pressing the switching key (usually, the tab key). To cancel an application switch that is in progress, press the escape key.

-HI-
Hal Itosis is online now   Reply With Quote
Old 08-22-2004, 09:20 PM   #14
roncross@cox.net
MVP
 
Join Date: Jan 2004
Posts: 1,496
Ok, here is my 1st draft to getting Dragthing to show all windows.

Here is the first rough draft of the DragThing script that will allow you to show all windows including hidden ones. You also have the option to minimize all windows so that they all show up in the windows dock. While working on this script, I learned somethings that I didn't know before such as applescript appears to be non standardized with respect to applications.

For example, some applications are scriptable while others or not. Some applications have different options for commands. For example, if you have several Finder frontmost with several windows opens and want to minimize all window, you can can type alt+M and all windows will close. Try doing this with the terminal and it will not work. Of course you can double click on the title bar of these applications with the alt button down and all the windows of the application will minimize. But not having standardized key commands makes it difficult to script.

Another example of applications not be standardizes is that some of the windows don't show up in the windows Dock such as activity monitor and stickies. They show up in the process Dock, but they don't show up in the window dock. Why aren't stickies visible in the windows dock?


Some other notes and suggestions based on limited testing:


The name of my window dock is "running document". Make sure to replace "running document with the name of your window docks are else it will not run properly.


The window dock doesn't reset itself after all the windows were rehidden so there was no need to put a time limit on selecting the window from the window dock. You simply run the script and after you decide to rehide or minimize all windows, you should be able to make your selection. Is this is a bug? It appears to me that after the applications are hidden then the windows in the window dock should disappear, but they don't! Is there a cache file or something that can be thrown away after the applications are hidden so that the window Dock will reset itself? I would like to implement a time limit so that the selection can be made and then the applications will rehide, along with the windows disappearing in the window dock. If you try this code, then please post back as to your findings on this. If this is common, then we may want to follow up with the author on this one.

If you have hide other applications when switching checked, then you will be able to minimize the window, however, once you select another application then your other applications will be hidden again. This is not a bug, this is the choice you made. You can change the setting to anything you like in the code to reflect your taste. I wrote this code so it mainly reflect my style.

I only did limited testing. My advice is that if you have questions or problems, then post them here and hopefully myself or someone else will be able to answer the question. There are so many options in Dragthing, differences in applications and how they response to commands that you will have to test this with your applications and you will most likely have to make some modification to the script to get this working so that it is robust for you. I invite everyone to improve upon this script so that everyone will be able to benefit from it.


Here is the code:

Code:

global myapp, N, d, b
set d to 1
set t to 15
set b to {}
set myapp to ""







tell application "DragThing"
	activate
	
	set mybackground to include background only processes
	set include background only processes to false
	
	
	set myshowwindow to show windows in a dock
	set show windows in a dock to true
	
	set myhideotherapplication to hide other applications when switching
	set hide other applications when switching to false
	
	set myminimisedwin to only show minimised windows in window dock
	set only show minimised windows in window dock to false
	
	set showfrontapp to only show frontmost application windows in window dock
	set only show frontmost application windows in window dock to false
	
	set hidden of dock "Running document" to false
	
	set N to {}
	set theappinthelist to name of every slot of every layer of dock "Process Dock"
	display dialog "keep minimized or rehide?" buttons {"keep mininmized", "rehide applications"} default button 1
	
	if button returned of result is "keep mininmized" then
		set b to "minimize"
	else
		set b to "hideum"
	end if
	
	
	-- A subroutine to get all the window of the process dock
	
	repeat with myapp in theappinthelist
		
		if (myapp as text) is not equal to "Trash" then
			if myapp as text is equal to "Excel" then
				set myapp to "Microsoft Excel"
			end if
			my theapp(myapp, N, d)
		end if
		
	end repeat
	
	if b is equal to "hideum" then
		my rehide(N, d)
		
	end if
	set N to {}
	set b to {}
	
	-- resetting everything back to the way it was
	
	set include background only processes to mybackground
	set show windows in a dock to myshowwindow
	set hide other applications when switching to myhideotherapplication
	set only show minimised windows in window dock to myminimisedwin
	set only show frontmost application windows in window dock to showfrontapp
	
	
	
end tell

-- This is a pseudo reset on the Dock so that DragThing will eventually work properly

tell application "Dock" to launch


--  Beginning of subroutine to compare windows in the application to window Dock

on theapp(myapp, N, d)
	tell application myapp
		tell application "System Events"
			tell application process (myapp as text)
				
				
				if visible is false then
					
					-- This is the part where we activate the window and then minimum it and throw the hidden applications into a list
					
					set end of N to myapp
					my doitron(myapp)
					tell application "System Events"
						tell process (myapp as text)
							set frontmost to true
							
							set P to name of every window
							set anitem to count items of P
							try
								repeat anitem times
									click menu item "minimize" of menu "Window" of menu bar item "window" of menu bar 1
								end repeat
							end try
							try
								repeat anitem times
									click menu item "minimize window" of menu "Window" of menu bar item "window" of menu bar 1
								end repeat
							end try
							
						end tell
					end tell
				end if
				
			end tell
		end tell
	end tell
end theapp

--  This is where we will rehide the applications in the list

on rehide(N, d)
	set text item delimiters to ", "
	N as string
	set u to 0
	set z to count items of N
	repeat z times
		set u to u + 1
		--	get item u of N
		set hideapp to item u of N
		tell application hideapp to activate
		tell application "System Events"
			key down {command}
			-- delay d
			keystroke "h"
			-- delay d
			key up {command}
		end tell
	end repeat
end rehide


--  This activates the application so that they can be minimized

on doitron(myapp)
	tell application myapp to activate
end doitron

thx RLC
roncross@cox.net is offline   Reply With Quote
Old 08-23-2004, 09:58 AM   #15
roncross@cox.net
MVP
 
Join Date: Jan 2004
Posts: 1,496
When has the script finished running?

The time the script takes to run depends on the amount of applications you have running and the amount of applications hidden. You can replace the code:
Code:
tell application "Dock" to launch
with this code to prompt you when the script is finished:
Code:
tell application "Dock"
	launch
	display dialog "finished... Look at your windows" giving up after 2
end tell
roncross@cox.net is offline   Reply With Quote
Old 08-23-2004, 10:38 AM   #16
localhost
Prospect
 
Join Date: Mar 2003
Location: 127.0.0.1
Posts: 48
Maybe I just don't understand the question, but doesn't the option I have highlighted in this screen shot ("Focus on Window (active) or next window") do exactly what you want?

localhost
Attached Thumbnails
Click image for larger version

Name:	access.png
Views:	338
Size:	80.2 KB
ID:	154  
localhost is offline   Reply With Quote
Old 08-23-2004, 10:53 AM   #17
roncross@cox.net
MVP
 
Join Date: Jan 2004
Posts: 1,496
Quote:
Originally Posted by localhost
Maybe I just don't understand the question, but doesn't the option I have highlighted in this screen shot ("Focus on Window (active) or next window") do exactly what you want?
localhost

No it doesn't. It will not find hidden windows. The script I wrote will show you all windows, including hidden ones, in the windows dock by name or applications. But maybe you found the equivalent of a poor man version of alt-tab used on windows pc.

thx
RLC
roncross@cox.net is offline   Reply With Quote
Old 08-24-2004, 07:27 AM   #18
roncross@cox.net
MVP
 
Join Date: Jan 2004
Posts: 1,496
I understand the behavior of DragThing

Quote:
Originally Posted by roncross@cox.net

Some other notes and suggestions based on limited testing:

The window dock doesn't reset itself after all the windows were rehidden so there was no need to put a time limit on selecting the window from the window dock. You simply run the script and after you decide to rehide or minimize all windows, you should be able to make your selection. Is this is a bug? It appears to me that after the applications are hidden then the windows in the window dock should disappear, but they don't! Is there a cache file or something that can be thrown away after the applications are hidden so that the window Dock will reset itself? I would like to implement a time limit so that the selection can be made and then the applications will rehide, along with the windows disappearing in the window dock. If you try this code, then please post back as to your findings on this. If this is common, then we may want to follow up with the author on this one.


I figure this out. Dragthing takes into account windows that are minimized! In fact it puts strong emphasis on windows that are minimized. Do this as a test. Open up the process Dock and the window dock. Open up two application windows such as the Terminal. Bring them front and center. An application icon will show up in the process dock while two windows will show up in the windows dock. Next, minimize one of the window so that it is in the dock and hide the Terminal application - notice that the minimized window in the Apple dock disappears. If you have highlight hidden process turned on for the process dock, then you will see the Terminal Application go dim. The window dock will show one Terminal window; this is the window that was minimized and hidden in the dock. The window that wasn't hidden in the dock is completely gone from the window dock. In other words, all windows that are minimized in the dock are ALWAYS shown in the window dock for a given application. So the script that I wrote is valid for showing all windows in the window dock even for hidden application since I first minimize all the windows to the dock and then I hide them. I must admit that I discovered this completely by serendipity!!! Have I try to do a show all and then rehide hidden applications I may have never stumbled upon this GEM.

Based on what I have learned, I don't see a reason for making a script with a timer since I am showing all windows, including hidden one, by minimizing them in the Apple Dock and then hiding them. If you want to clear out the window dock when an application is hidden, you can click on the windows in the dock and rehide the applications and they will no longer be visible in the window dock.



I have already written another script that is cleaner than the 1st script that I wrote based on what I have learned. It does basically the same thing, but I believe that the code is easier to follow:

The new and clearer code is:

Code:
global myapp, N, d, e
local u, z, hideapp, P, anitem
set d to 0
set t to 15
set b to {}
set myapp to ""

tell application "DragThing"
	activate
	
	set mytrashcan to process dock includes trash
	set process dock includes trash to false
	
	set mybackground to include background only processes
	set include background only processes to false
	
	
	set myshowwindow to show windows in a dock
	set show windows in a dock to true
	
	set myhideotherapplication to hide other applications when switching
	set hide other applications when switching to false
	
	set myminimisedwin to only show minimised windows in window dock
	set only show minimised windows in window dock to false
	
	set showfrontapp to only show frontmost application windows in window dock
	set only show frontmost application windows in window dock to false
	
	set hidden of dock "Running document" to false
	
	-- set L to name of every slot of every layer of dock "Running document"
	set N to {}
	set theappinthelist to name of every slot of every layer of dock "Process Dock"
	display dialog "hidden applications choices?
	minimize windows in Apple Dock or
	rehide win apps and show in win dock" buttons {"minimize windows", "rehide windows"} default button 1
	
	if button returned of result is "minimize windows" then
		set e to "minimize"
	else if button returned of result is "rehide windows" then
		set e to "hideumall"
	end if
	
	
	-- A subroutine to test whether an application is hidden
	
	repeat with myapp in theappinthelist
		if myapp as text is equal to "Excel" then
			set myapp to "Microsoft Excel"
		end if
		my theapp(myapp, N)
	end repeat
	
	-- A subroutine to minimize all hidden window in the dock and show all windows in the window dock
	
	if e is equal to "minimize" then
		my minallwin(N)
	else if e is equal to "hideumall" then
		my minallwin(N)
		my rehide(N)
	end if
	
	set N to {}
	set e to {}
	
	set include background only processes to mybackground
	set show windows in a dock to myshowwindow
	set hide other applications when switching to myhideotherapplication
	set only show minimised windows in window dock to myminimisedwin
	set only show frontmost application windows in window dock to showfrontapp
	set process dock includes trash to mytrashcan
end tell

tell application "Dock"
	launch
	display dialog "finished... Look at your windows" giving up after 2
end tell

--  This is the subroutine that test whether the application is hidden

on theapp(myapp, N)
	tell application myapp
		tell application "System Events"
			tell application process (myapp as text)
				if visible is false then
					set end of N to myapp
				end if
			end tell
		end tell
	end tell
end theapp

-- This is the subroutine that minimizes all hidden windows

on minallwin(N)
	set text item delimiters to ", "
	N as string
	set u to 0
	set z to count items of N
	repeat z times
		set u to u + 1
		set hideapp to item u of N
		tell application hideapp to activate
		tell application "System Events"
			tell application process (hideapp as text)
				set P to name of every window
				set anitem to count of P
				try
					repeat anitem times
						delay d
						click menu item "minimize" of menu "Window" of menu bar item "window" of menu bar 1
					end repeat
				end try
				try
					repeat anitem times
						delay d
						click menu item "minimize window" of menu "Window" of menu bar item "window" of menu bar 1
					end repeat
				end try
			end tell
		end tell
	end repeat
end minallwin

--  This is where we will rehide the hidden applications in the list

on rehide(N)
	set text item delimiters to ", "
	N as string
	set u to 0
	set z to count items of N
	repeat z times
		set u to u + 1
		--	get item u of N
		set hideapp to item u of N
		tell application hideapp to activate
		tell application "System Events"
			key down {command}
			-- delay d
			keystroke "h"
			-- delay d
			key up {command}
		end tell
	end repeat
end rehide

Last edited by roncross@cox.net; 08-24-2004 at 08:16 AM.
roncross@cox.net is offline   Reply With Quote
Old 09-06-2004, 12:51 AM   #19
roncross@cox.net
MVP
 
Join Date: Jan 2004
Posts: 1,496
update to include microsoft word, microsoft powerpoint. Firefox and mozilla

Update to include Microsoft word, Microsoft Powerpoint, Firefox, and Mozilla.

Code:
global myapp, N, d, e
local u, z, hideapp, P, anitem
set d to 0
set t to 15
set b to {}
set myapp to ""

tell application "DragThing"
	activate
	
	set mytrashcan to process dock includes trash
	set process dock includes trash to false
	
	set mybackground to include background only processes
	set include background only processes to false
	
	
	set myshowwindow to show windows in a dock
	set show windows in a dock to true
	
	set myhideotherapplication to hide other applications when switching
	set hide other applications when switching to false
	
	set myminimisedwin to only show minimised windows in window dock
	set only show minimised windows in window dock to false
	
	set showfrontapp to only show frontmost application windows in window dock
	set only show frontmost application windows in window dock to false
	
	set hidden of dock "Running document" to false
	
	-- set L to name of every slot of every layer of dock "Running document"
	set N to {}
	set theappinthelist to name of every slot of every layer of dock "Process Dock"
	display dialog "hidden applications choices?
	minimize windows in Apple Dock or
	rehide win apps and show in win dock" buttons {"minimize windows", "rehide windows"} default button 1
	
	if button returned of result is "minimize windows" then
		set e to "minimize"
	else if button returned of result is "rehide windows" then
		set e to "hideumall"
	end if
	
	
	-- A subroutine to test whether an application is hidden
	
	repeat with myapp in theappinthelist
		if myapp as text is equal to "Excel" then
			set myapp to "Microsoft Excel"
		end if
		if myapp as text is equal to "PowerPoint" then
			set myapp to "Microsoft PowerPoint"
		end if
		if myapp as text is equal to "Word" then
			set myapp to "Microsoft Word"
		end if
		if myapp as text is equal to "Firefox" then
			set myapp to "Firefox-bin"
		end if
		if myapp as text is equal to "Mozilla" then
			set myapp to "Mozilla-bin"
		end if
		my theapp(myapp, N)
	end repeat
	
	-- A subroutine to minimize all hidden window in the dock and show all windows in the window dock
	
	if e is equal to "minimize" then
		my minallwin(N)
	else if e is equal to "hideumall" then
		my minallwin(N) -- You have to minimize first are else you will not be able to see it on the window dock
		my rehide(N)
	end if
	
	set N to {}
	set e to {}
	
	set include background only processes to mybackground
	set show windows in a dock to myshowwindow
	set hide other applications when switching to myhideotherapplication
	set only show minimised windows in window dock to myminimisedwin
	set only show frontmost application windows in window dock to showfrontapp
	set process dock includes trash to mytrashcan
end tell

tell application "Dock"
	launch
	display dialog "finished... Look at your windows" giving up after 2
end tell

--  This is the subroutine that test whether the application is hidden

on theapp(myapp, N)
	tell application myapp
		tell application "System Events"
			tell application process (myapp as text)
				if visible is false then
					set end of N to myapp
				end if
			end tell
		end tell
	end tell
end theapp

-- This is the subroutine that minimizes all hidden windows

on minallwin(N)
	set text item delimiters to ", "
	N as string
	set u to 0
	set z to count items of N
	repeat z times
		set u to u + 1
		set hideapp to item u of N
		tell application hideapp to activate
		tell application "System Events"
			tell application process (hideapp as text)
				set P to name of every window
				set anitem to count of P
				try
					repeat anitem times
						delay d
						click menu item "minimize" of menu "Window" of menu bar item "window" of menu bar 1
					end repeat
				end try
				try
					repeat anitem times
						delay d
						click menu item "minimize window" of menu "Window" of menu bar item "window" of menu bar 1
					end repeat
				end try
			end tell
		end tell
	end repeat
end minallwin

--  This is where we will rehide the hidden applications in the list

on rehide(N)
	set text item delimiters to ", "
	N as string
	set u to 0
	set z to count items of N
	repeat z times
		set u to u + 1
		--	get item u of N
		set hideapp to item u of N
		tell application hideapp to activate
		tell application "System Events"
			key down {command}
			-- delay d
			keystroke "h"
			-- delay d
			key up {command}
		end tell
	end repeat
end rehide
roncross@cox.net is offline   Reply With Quote
Old 09-16-2004, 01:42 AM   #20
roncross@cox.net
MVP
 
Join Date: Jan 2004
Posts: 1,496
update to fix display dialog. I also modified the rehide routine to improve speed.

I have updated the script to fix the display dialog box. It used to only show in rehide mode, and failed to display in minimize mode. I simply changed tell application "Dock" to launch to tell application "Dock" to activate. Also based on some feedback, I modified the rehide subroutine so that I eliminate the system event to click command+H to hide an application. This has resulted in a slightly faster script since delays are no longer needed between clicks.

Here is the updated code:

Code:
global myapp, N, d, e
local u, z, hideapp, P, anitem
set d to 0
set t to 15
set b to {}
set myapp to ""

tell application "DragThing"
	activate
	
	set mytrashcan to process dock includes trash
	set process dock includes trash to false
	
	set mybackground to include background only processes
	set include background only processes to false
	
	
	set myshowwindow to show windows in a dock
	set show windows in a dock to true
	
	set myhideotherapplication to hide other applications when switching
	set hide other applications when switching to false
	
	set myminimisedwin to only show minimised windows in window dock
	set only show minimised windows in window dock to false
	
	set showfrontapp to only show frontmost application windows in window dock
	set only show frontmost application windows in window dock to false
	
	set hidden of dock "Running document" to false
	
	-- set L to name of every slot of every layer of dock "Running document"
	set N to {}
	set theappinthelist to name of every slot of every layer of dock "Process Dock"
	display dialog "hidden applications choices?
	minimize windows in Apple Dock or
	rehide win apps and show in win dock" buttons {"minimize windows", "rehide windows"} default button 1
	
	if button returned of result is "minimize windows" then
		set e to "minimize"
	else if button returned of result is "rehide windows" then
		set e to "hideumall"
	end if
	
	
	-- A subroutine to test whether an application is hidden
	
	repeat with myapp in theappinthelist
		if myapp as text is equal to "Excel" then
			set myapp to "Microsoft Excel"
		end if
		if myapp as text is equal to "PowerPoint" then
			set myapp to "Microsoft PowerPoint"
		end if
		if myapp as text is equal to "Word" then
			set myapp to "Microsoft Word"
		end if
		if myapp as text is equal to "Firefox" then
			set myapp to "Firefox-bin"
		end if
		if myapp as text is equal to "Mozilla" then
			set myapp to "Mozilla-bin"
		end if
		my theapp(myapp, N)
	end repeat
	
	-- A subroutine to minimize all hidden window in the dock and show all windows in the window dock
	
	if e is equal to "minimize" then
		my minallwin(N)
	else if e is equal to "hideumall" then
		my minallwin(N) -- You have to minimize first are else you will not be able to see it on the window dock
		my rehide(N)
	end if
	
	set N to {}
	set e to {}
	set myapp to ""
	
	set include background only processes to mybackground
	set show windows in a dock to myshowwindow
	set hide other applications when switching to myhideotherapplication
	set only show minimised windows in window dock to myminimisedwin
	set only show frontmost application windows in window dock to showfrontapp
	set process dock includes trash to mytrashcan
end tell

tell application "Dock"
	activate
	display dialog "finished... Look at your windows" giving up after 2
end tell

--  This is the subroutine that test whether the application is hidden

on theapp(myapp, N)
	tell application myapp
		tell application "System Events"
			tell application process (myapp as text)
				if visible is false then
					set end of N to myapp
				end if
			end tell
		end tell
	end tell
end theapp

-- This is the subroutine that minimizes all hidden windows

on minallwin(N)
	set text item delimiters to ", "
	N as string
	set u to 0
	set z to count items of N
	repeat z times
		set u to u + 1
		set hideapp to item u of N
		tell application hideapp to activate
		tell application "System Events"
			tell application process (hideapp as text)
				set P to name of every window
				set anitem to count of P
				try
					repeat anitem times
						delay d
						click menu item "minimize" of menu "Window" of menu bar item "window" of menu bar 1
					end repeat
				end try
				try
					repeat anitem times
						delay d
						click menu item "minimize window" of menu "Window" of menu bar item "window" of menu bar 1
					end repeat
				end try
			end tell
		end tell
	end repeat
end minallwin

--  This is where we will rehide the hidden applications in the list

on rehide(N)
	set text item delimiters to ", "
	N as string
	set u to 0
	set z to count items of N
	repeat z times
		set u to u + 1
		--	get item u of N
		set hideapp to item u of N
		tell application hideapp to activate
		if (hideapp as text) is equal to "Finder" then
			tell application "Finder" to set visible to false
		else
			tell application "System Events"
				set visible of process (hideapp as text) to false
			end tell
		end if
	end repeat
end rehide
roncross@cox.net is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 11:25 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Site design © Mac Publishing LLC; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of Mac Publishing LLC.