Facebook Twitter Gplus RSS

No tweets to display


OSX Maximize Window Hotkey [w/ QuickSilver]

Credit: macworld.com

    1. Open Apple Script Editor and paste this:
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
  1. Set this as a trigger in QuickSilver. I chose CMD+OPT+m
 

USB device won’t work after waking from sleep

I have a USB IR Receiver that I use to control Windows Media Center as well as volume for any other program playing music.  However, I always had the problem where the IR receiver would not work properly after resuming from sleep (even though the remote is the device that woke it up in the first place!).  I’ve struggled with this problem forever and recently found a fix.

One fix that has always worked for me was physically disconnecting and reconnecting the IR receiver from a USB slot. But the whole purpose of having a remote is so you don’t have to be right next to the computer.  Below is a way to automate this disconnect/reconnect process with software.

  1. Download Sleep/Resume Triggers below.  We will use this to automatically run a script right before the computer is suspended (goes to sleep).
    Windows Suspend/Resume Control (Power Triggers) Download Link #1 

  2. Download devcon from the link below.  This will allow you create a script that disconnects and reconnects the USB device properly.
    Devcon download link #1
  3. Hit the windows key and type “device”.  Choose “Device Manager” from the application list.
  4. Expand the “Universal Serial Bus controllers” item and find the USB device that has the problem.  Note the ID that appears between the parentheses at the end of the name:
  5. Right click and choose edit on the suspend.bat file in the installation directory (C:\Program Files\Derek Smith\Power Triggers). Replace the contents of the file with the text below, substituting USBCIR with the ID you found in step 4:
    devcon remove *USBCIR*
  6. Save the file and open PowerTriggers.exe.   Double click the Power Triggers icon in your system tray and choose the suspend.bat file for the Suspend action.
 

Move To… and Open Mailbox Hotkeys for Apple Mail

I’m a huge fan of keyboard shortcuts and a very hand application of them is in mail applications.  GMail has a move command which I use regularly by pressing v.  I wanted a hotkey in Apple Mail to do the same thing.  Below is a two step process to create a similar move command for Apple Mail with AppleScript.  At the bottom is a similar script that will open a mailbox of your choice with the keyboard.

1. Create a Mail Service to run the applescript

1.   Open Automator and create a new Service

Create Automator Service

2.   For the scope at the top, select the Mail application

Scope

3.   Drag the “Run Actionscript” action from the left pane into the workflow on the right.

"Run Actionscript" Action

3.   You’ll see the “Run Applescript” action appear on the right.

Run Applescript

Paste the following code into the text box replacing the text “(* Your script goes here *)”.

 tell application "System Events"
 activate

 ----- ----- BEGIN Config ----- -----
 --You should only need to edit these variables
--Change EmailName below to the name of your email account that appears in the left pane of the mail app
 set myAccount to "EmailName"
--List all the mailboxes from the account above that you wish to provide as options for the Move command
--These must match the mailbox names exactly
 set myMailAccounts to {"Inbox", "1 To-Do", "2 Wait", "3 Completed", "Archive"}
--Copy the name of a mailbox above to use as the default
 set myDefault to {"1 To-Do"}
 ----- ----- END Config ----- -----

 choose from list myMailAccounts with title "Move To..." with prompt "Choose Mailbox" default items myDefault
 set selectedMailbox to result as string
 end tell

 --Activate Mail in case the dialogue box was cancelled out of
 tell application "Mail"
 activate
 end tell

 --loop through options and decide which mailbox was selected
 repeat with i from 1 to count of myMailAccounts
 set this_item to item i of myMailAccounts

 if selectedMailbox is this_item then tell application "Mail"
 --if this mailbox was selected, open it
 activate
 set s to selection
 repeat with eachMessage in s
 move eachMessage to mailbox selectedMailbox of account myAccount
 end repeat
 end tell
 end repeat

4.   Change the settings in the CONFIG section of the code to suit your needs and save as whatever you like.  I called mine “Mail – Triage”

Note: You could also save this code as a standalone applescript; then set up something such as QuickSilver to call the script with a trigger of your choice. In theory this would work great.  However, QuickSilver trigger scopes would not work correctly for me.  If you have a fix for this, please let me know.

2. Assign the Service to a hotkey

  1. Open keyboard preferences and choose the “Keyboard Shortcuts” tab
  2. Click services on the left
  3. Find your Mail service on the right under the General heading
  4. Check the checkbox and assign a hotkey by clicking on the right

I’ve set mine up to use the hotkey Shift + Command + V. It may seem like a lot of keys, but it matches well with my other hotkeys (i.e. launching QuickSilver is Shift + Command + Space).

Usage

  • Select at least one email (or have an email window open and selected) then press the hotkeys.  The following dialogue should open.

Move To... Dialogue

  • To choose the mailbox quickly, just type the first letter or two then press enter.
  • That’s it!

Open Mailbox Hotkey

Repeat all the steps above, but use this script instead. You’ll notice a special mailbox used here called “Threaded”, this is a combination of Inbox and Sent items to make the experience more similar to GMail.

       tell application "System Events"
		activate
		
 ----- ----- BEGIN Config ----- -----
--You should only need to edit these variables
--Change EmailName below to the name of your email account that appears in the left pane of the mail app
set myAccount to "EmailName"
--List all the mailboxes from the account above that you wish to provide as options for the Open command
--These must match the mailbox names exactly
set myMailAccounts to {"Threaded", "Inbox", "Sent", "1 To-Do", "2 Wait", "3 Completed", "Archive"}
--Copy the name of a mailbox above to use as the default
set myDefault to {"Threaded"}
 ----- ----- END Config ----- -----
		
	choose from list myMailAccounts with title "Open Mailbox" with prompt "Choose Mailbox" default items myDefault
		set selectedMailbox to result as string
	end tell
	
	--Activate Mail in case the dialogue box was cancelled out of
	tell application "Mail"
		activate
	end tell
	
	--loop through options and decide which mailbox was selected
	repeat with i from 1 to count of myMailAccounts
		set this_item to item i of myMailAccounts
		
		if selectedMailbox is this_item then tell application "Mail"
			--if this mailbox was selected, open it
			activate
			if selectedMailbox is "Threaded" then
				set the selected mailboxes of the front message viewer to {item 1 of inbox, item 1 of sent mailbox}
				set the sort column of the front message viewer to date received column
				set the sorted ascending of the front message viewer to false
			else if selectedMailbox is "Inbox" then
				set the selected mailboxes of the front message viewer to {item 1 of inbox}
			else if selectedMailbox is "Sent" then
				set the selected mailboxes of the front message viewer to {item 1 of sent mailbox}
			else
				set selected mailboxes of the front message viewer to {mailbox this_item of account myAccount}
			end if
		end tell
		
	end repeat

If you have any suggestions for improvements, drop them in the comments below!


 
credit