Jump to content

Alfred window pops up after running an apple script (osa) in a workflow


Recommended Posts

I created an applescript to interact with Outlook messages that I'm launching with a hot key in a workflow as an osascript:

 

 

on run {}
    
    tell application "Microsoft Outlook"
        
        -- listSelectedItems : a list of all items selected in Entourage
        set listMessages to current messages
        
        -- Check to make sure items are selected, if not then quit
        if ((count of listMessages) < 1) then return
        
        repeat with eachMessage in listMessages
            move eachMessage to folder "Local Archive"
        end repeat
        
    end tell
    
end run
 
The script archives the messages as designed, but it pops the Alfred window each time. I didn't have this problem in v1 with an applescript.
Link to comment

I created an applescript to interact with Outlook messages that I'm launching with a hot key in a workflow as an osascript:

 

 

on run {}
    
    tell application "Microsoft Outlook"
        
        -- listSelectedItems : a list of all items selected in Entourage
        set listMessages to current messages
        
        -- Check to make sure items are selected, if not then quit
        if ((count of listMessages) < 1) then return
        
        repeat with eachMessage in listMessages
            move eachMessage to folder "Local Archive"
        end repeat
        
    end tell
    
end run
 
The script archives the messages as designed, but it pops the Alfred window each time. I didn't have this problem in v1 with an applescript.

 

I tried your code with one little tweak and got it to work.

 

I removed the "on run {}" from the top, and the "end run" from the bottom. After that I created a new workflow, added a Hotkey trigger and a Run Script action. I set the language in the action to be /usr/bin/osascript and used this code:

tell application "Microsoft Outlook"
	
	-- listSelectedItems : a list of all items selected in Entourage
	set listMessages to current messages
	
	-- Check to make sure items are selected, if not then quit
	if ((count of listMessages) < 1) then return
	
	display dialog "test"
	
	repeat with eachMessage in listMessages
		move eachMessage to folder "Todo"
	end repeat
	
end tell

 

Obviously,  I changed the folder name as well but it seems to be working well.

 

Hope this helps.

Link to comment

Thanks David, I got it working with your changes, however the Alfred window still pops up. The hotkey is set to "pass through to workflow" and I can't see any other settings that would be popping this. My Alfred hot key is double-tap ⌘, but I'm being careful not to fat finger it.

 

Steve

Link to comment

Thanks David, I got it working with your changes, however the Alfred window still pops up. The hotkey is set to "pass through to workflow" and I can't see any other settings that would be popping this. My Alfred hot key is double-tap ⌘, but I'm being careful not to fat finger it.

 

Steve

 

Double-tap ⌘ is the hotkey to action that script, or is your Alfred hotkey?

Link to comment

⌘+shift+> is my hotkey.

 

That's weird. I didn't get this when I was setting this up for testing. I'm still not really sure which of your hotkeys was double command. Was it Alfred? If so, can you try changing that hotkey temporarily to see if that resolves it? Just curious..

Link to comment

Yeah, I don't get it either. Everything looks right. sometimes the window doesnt pop. with some osa scripts it never pops.

I'm on Snow Leopard, in case that matters. I'll do a screen movie and share it so you can see it in action. Thanks for your help. I love Alfred.

Link to comment

I thought of that and removed Alfred 1 and Quicksilver which I haven't used since the early days of Alfred. I went through the Keyboard shortcuts section of System Prefs and removed all instances of those hot keys. I restarted Alfred 2 and Outlook. Still occurred. Then I changed the hotkey to ⌘+shift+plus. When I hit the old hotkey (⌘+shift+>) nothing happened--no window pop, no script run. When I hit the new hot key, it ran the script and popped the window.

Link to comment

The problem seems to have been resolved by using a hotkey set that doesn't include shift. I changed to ⌘+option+period and I don't get the window pop. One thing I noticed is that Alfred 1 would show the hotkey combo as ⌘+shift+. while 2.0 showed it as ⌘+shift+> (the shifted char for .) I have no idea if that's relevant, but I noticed it.

 

 

Thanks for your help.
 
Steve
Link to comment

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...