Jump to content

Search Sparrow workflow


Recommended Posts

This doesn't seem to work when the Sparrow window is not open, but closed.

Hello,

 

I had this problem too so i tried adding a delay of 0.5 seconds into the script - it now opens sparrow first before searching.

 

the script now reads...

 

 

on alfred_script(q)
delay 0.5
    tell application "Sparrow" to activate --- activates sparrow
    tell application "System Events"
        tell process "Sparrow" --- implying Sparrow is already activated
            key code 3 using {command down, option down} --- send cmd+alt+F to Sparrow invoking search
            keystroke q --- enter the query
        end tell
    end tell
end alfred_script
Link to comment

Hello,

 

I had this problem too so i tried adding a delay of 0.5 seconds into the script - it now opens sparrow first before searching.

 

the script now reads...

 

 

on alfred_script(q)
delay 0.5
    tell application "Sparrow" to activate --- activates sparrow
    tell application "System Events"
        tell process "Sparrow" --- implying Sparrow is already activated
            key code 3 using {command down, option down} --- send cmd+alt+F to Sparrow invoking search
            keystroke q --- enter the query
        end tell
    end tell
end alfred_script

Cool, that works. Would be cool to extend the script to launch Sparrow first (if it's not already launched) and than execute the script. I am not big into programming, but it should be something like this:

 

on alfred_script(q)
tell application "System Events"
    set isSparrowRunning to (count of (every process whose name is "Sparrow")) > 0
end tell
if isSparrowRunning then
    tell application "Sparrow" to activate --- activates sparrow
    tell application "System Events"
        tell process "Sparrow" --- implying Sparrow is already activated
            key code 3 using {command down, option down} --- send cmd+alt+F to Sparrow invoking search
            keystroke q --- enter the query
        end tell
    end tell
else
	tell application "Sparrow " to launch
	delay 0.5
    tell application "Sparrow" to activate --- activates sparrow
    tell application "System Events"
        tell process "Sparrow" --- implying Sparrow is already activated
            key code 3 using {command down, option down} --- send cmd+alt+F to Sparrow invoking search
            keystroke q --- enter the query
        end tell
    end tell
end if
end alfred_script

 

 

 

It doesn't work as it should, launching Sparrow works, but when it's launched, the window focus and search does not work.  I guess we have to set some delays. Maybe somebody can help out.

Edited by 69wpm
Link to comment
  • 2 weeks later...

If you close the sparrow window instead of hiding it, the sparrow button in the dock needs to be clicked in order for sparrow to generate the window again. So I got it to work completely by scripting in the click on the 'Sparrow' item in the dock:

 

on alfred_script(q)
	delay 0.5
	tell application "Sparrow" to activate --- activates sparrow
	tell application "System Events"
		tell process "Dock"
			click UI element "Sparrow" of list 1 --- click the dock item to generate a window
	        end tell
		tell process "Sparrow" --- implying Sparrow is already activated
			key code 3 using {command down, option down} --- send cmd+alt+F to Sparrow invoking search
			keystroke q --- enter the query
		end tell
	end tell
end alfred_script
Link to comment

So Sparrow doesn't need to be in your dock:

 

on alfred_script(q)
	tell application "System Events"
		set isSparrowRunning to exists (processes where name is "Sparrow")
	end tell
	if not isSparrowRunning then
		tell application "Sparrow" to launch
		delay 0.5
	end if
	tell application "Sparrow" to activate --- activates sparrow
	tell application "System Events"
		tell process "Sparrow" --- implying Sparrow is already activated
			key code 3 using {command down, option down} --- send cmd+alt+F to Sparrow invoking search
			keystroke q --- enter the query
		end tell
	end tell
end alfred_script

 

also an easy link: download

Link to comment
  • 6 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...