Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Simon Dorfman http://www.SimonDorfman.com/

« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS 

Quick search with Quicksilver and EasyFind

// A script to quickly search files and folders using Quicksilver and EasyFind.

(*
A script to quickly search files and folders using Quicksilver [1] and EasyFind [2].
Written by Simon Dorfman, January 8, 2006. www.SimonDorfman.com

Save this script to ~/Library/Application Support/Quicksilver/Actions/EasyFind.scpt
You'll need to have "Enable access for assisstive devices" enabled under Universal Access in System Preferences.
To use:
	1. activate Quicksilver
	2. type "." (i.e. hit the period key)
	3. type the text you want to search for (i.e. httpd.conf)
	4. press tab
	5. start typing "EasyFind.scpt"
	6. once Quicksilver finds "EasyFind.scpt", press return
	
[1] http://www.versiontracker.com/dyn/moreinfo/macosx/22549
[2] http://www.versiontracker.com/dyn/moreinfo/macosx/11706
*)

using terms from application "Quicksilver"
	on process text t
		tell application "EasyFind" to activate
		tell application "System Events"
			tell process "EasyFind"
				set value of text field 1 of window 1 to t --type text in search field
				--uncomment your preferred search option, or save separate scripts with each option
				click radio button 1 of radio group 1 of window 1 --"Files & Folders"
				--click radio button 2 of radio group 1 of window 1 --"Only Files"
				--click radio button 3 of radio group 1 of window 1 --"Only Folders"
				--click radio button 4 of radio group 1 of window 1 --"File Contents"
				click button 4 of window 1 --start search
			end tell
		end tell
	end process text
end using terms from

Resize Front Two Windows Side by Side, Filling Screen

// An applescript that resizes the front two windows of the active application side by side, filling the screen.

-- An applescript that resizes the front two windows of the active application side by side, filling the screen.
-- Written by Simon Dorfman, January 4, 2006. www.SimonDorfman.com

-- Save this script to ~/Library/Scripts/Applications/Run from QuickSilver Triggers, Don't move these/Front 2 Windows Side by Side - Control + Option + C.scpt
-- I use keyboard shortcut Control + Option + C to run it.  I think of the C as standing for "Compare".
-- You'll need to have "Enable access for assisstive devices" enabled under Universal Access in System Preferences.

--set screen dimension variables
set menubarHeight to 22
set screenWidth to word 3 of (do shell script "defaults read /Library/Preferences/com.apple.windowserver | grep -w Width") as number
set screenHeight to word 3 of (do shell script "defaults read /Library/Preferences/com.apple.windowserver | grep -w Height") as number
--if you plan to use this on just one computer where the screen dimensions won't change, this script will run faster if you just hard code your screen resolution with these two lines:
--set screenWidth to 1280
--set screenHeight to 854
{screenWidth, screenHeight}

tell application "System Events"
	set frontApp to name of first application process whose frontmost is true
end tell

--some apps are wacky and put the windows higher for some reason, adjust for this bug.
if (frontApp is equal to "Finder" or frontApp is equal to "Microsoft Entourage") then
	set menubarHeight to 44
end if
--leave room for the Excel Toolbar
if (frontApp is equal to "Microsoft Excel") then
	set menubarHeight to 55
end if

try
	tell application frontApp
		set bounds of window 1 to {0, menubarHeight, (screenWidth / 2), screenHeight}
		set bounds of window 2 to {(screenWidth / 2), menubarHeight, screenWidth, screenHeight}
	end tell
on error the error_message number the error_number
	display dialog "Error: " & the error_number & ". " & the error_message buttons {"OK"} default button 1
end try

Keyboard shortcut for the green "zoom" button

// Ever since I started using OS X as my main OS (back at version 10.1), I kept wishing for a keyboard shortcut for the green button at the top left of each window. I wanted a quick way to maximize a window. Sadly, such a shortcut never came into being. I finally took the time to write an applescript to do the job. You can paste this script into Script Editor and save it in your ~/Library/Scripts/ folder. I saved my script as "Click Green Maximize Button of Frontmost Window.scpt". I then used QuickSilver's Triggers feature to assign the keyboard shortcut Control-Option-Z to run the script. I picked that key combination because it's easy to press. I remember it by thinking of the Z as standing for Zoom. Get QuickSilver here: http://www.versiontracker.com/dyn/moreinfo/macosx/22549

tell application "System Events"
	if UI elements enabled then
		set FrontApplication to (get name of every process whose frontmost is true) as string
		tell process FrontApplication
			click button 2 of window 1
			--button 2 is the green "zoom" button for all applications
			--window 1 is always the frontmost window.
		end tell
	else
		tell application "System Preferences"
			activate
			set current pane to pane "com.apple.preference.universalaccess"
			display dialog "UI element scripting is not enabled. Check 'Enable access for assistive devices'"
		end tell
	end if
end tell
« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS