frankspin Posted October 30, 2013 Posted October 30, 2013 I started working on a workflow with Airmail that would use Applescript to switch to the application, trigger the unified inbox hotkey, and perform a search on unified inbox. I can get the applescript to work up to the point where it tells Airmail to select the search field, after that it wont work. I hear OSX give off the default sound as if one of the keypresses are not going through but even with sticking multiple delays it stills seems like it's trying to fire off certain commands early. If anyone has any suggestions on what I can try I'm open to them. Current script I'm using: on alfred_script(q) tell application "Airmail" to activate tell application "System Events" key code 126 using {command down, shift down} keystroke "f" using {command down} set the clipboard to (q) tell application "System Events" keystroke "v" {command down} end tell end tell end alfred_script
jdfwarrior Posted October 31, 2013 Posted October 31, 2013 I started working on a workflow with Airmail that would use Applescript to switch to the application, trigger the unified inbox hotkey, and perform a search on unified inbox. I can get the applescript to work up to the point where it tells Airmail to select the search field, after that it wont work. I hear OSX give off the default sound as if one of the keypresses are not going through but even with sticking multiple delays it stills seems like it's trying to fire off certain commands early. If anyone has any suggestions on what I can try I'm open to them. Current script I'm using: on alfred_script(q) tell application "Airmail" to activate tell application "System Events" key code 126 using {command down, shift down} keystroke "f" using {command down} set the clipboard to (q) tell application "System Events" keystroke "v" {command down} end tell end tell end alfred_script Seems to work for me after modifying the line where you paste in the search string. You have... keystroke "v" {command down} I added "using" between the character and modifier keys
frankspin Posted October 31, 2013 Author Posted October 31, 2013 Hm, even with adding "using" I'm still not getting it to paste. I keep hearing the system beep as if I'm trying to do something where it can't. If I run it, let it fail, and then run it again it will work. I can't for the life of me figure what is going wrong with it on the first run.
jdfwarrior Posted October 31, 2013 Posted October 31, 2013 Hm, even with adding "using" I'm still not getting it to paste. I keep hearing the system beep as if I'm trying to do something where it can't. If I run it, let it fail, and then run it again it will work. I can't for the life of me figure what is going wrong with it on the first run. I have an idea Are you using a hotkey to trigger this and if so, what hotkey?
jdfwarrior Posted October 31, 2013 Posted October 31, 2013 Hm, even with adding "using" I'm still not getting it to paste. I keep hearing the system beep as if I'm trying to do something where it can't. If I run it, let it fail, and then run it again it will work. I can't for the life of me figure what is going wrong with it on the first run. Actually, it may be more than what I originally thought. So.. here's what I've come up with.. Ignore the previous post about the hotkey, I don't think that's what it is anymore.. The solution I have.. works but, only if search isn't currently active. on alfred_script(q) tell application "Airmail" to activate tell application "System Events" tell process "Airmail" to click menu item "Search Messages" of menu "Edit" of menu bar 1 delay .4 tell process "Airmail" to keystroke (q as string) end tell end alfred_script That seems to work as long as something other than search is active in Airmail and the reason is, is when search is active and you run the script, when it activates Airmail again, the search field loses focus. Telling it to search again at that point, doesn't focus on the search field so when it tries to type, it doesn't work. The above code works otherwise.. frankspin 1
frankspin Posted October 31, 2013 Author Posted October 31, 2013 Yep, that did it! Thank you! I wonder if I can someone make this work with an IF statement but that will be for another day.
jdfwarrior Posted November 1, 2013 Posted November 1, 2013 Yep, that did it! Thank you! I wonder if I can someone make this work with an IF statement but that will be for another day. An IF to determine IF Search is already selected you mean?
frankspin Posted November 1, 2013 Author Posted November 1, 2013 An IF to determine IF Search is already selected you mean? Yes.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now