nikivi Posted August 8, 2016 Share Posted August 8, 2016 I have a workflow : http://www.packal.org/workflow/iterm-sessions I want to open switch to the tab and open my iTerm window. I can do that with a hotkey. So I can make a new applescript object in the end of the workflow that would simulate my hotkey to open my iTerm window like this : The problem with it is that this will close my iTerm window if I am running this workflow from iTerm window itself. I need some kind of conditional statement, somethings like this : Maybe that will branch off to two different paths depending if iTerm is frontmost or not. If it is not, it would simulate the hotkey, and if already in iTerm, don't. Thank you for any help. Link to comment
dfay Posted August 9, 2016 Share Posted August 9, 2016 what is your question exactly? How to tell if an app is frontmost in Applescript? see http://apple.stackexchange.com/questions/171709/applescript-get-active-application It would probably be more reliable to just tell application "iTerm" to activate , then go from there -- it sounds like you always want iTerm to be activated in the end. Link to comment
nikivi Posted August 9, 2016 Author Share Posted August 9, 2016 what is your question exactly? How to tell if an app is frontmost in Applescript? see http://apple.stackexchange.com/questions/171709/applescript-get-active-application It would probably be more reliable to just tell application "iTerm" to activate , then go from there -- it sounds like you always want iTerm to be activated in the end. I want to make something like this : And in the applescript it will check if iTerm is frontmost, if it is, it will go to one branch, if not, go to another. Perhaps I can do it some other way. Link to comment
deanishe Posted August 9, 2016 Share Posted August 9, 2016 Why not just add two Hotkeys, one for when iTerm is the active app, and one for every app but iTerm? Link to comment
nikivi Posted August 9, 2016 Author Share Posted August 9, 2016 (edited) Why not just add two Hotkeys, one for when iTerm is the active app, and one for every app but iTerm? Oh, this is actually a smart way to go about this. One issue is that I would like to have the same hotkey and Alfred doesn't for some reason allow me to use the same hotkey for the second one even though the second one should be activated only when iTerm is in focus. Copying the hotkey, just copies the hotkey object, it doesn't transfer the hotkey in there. Edited August 9, 2016 by nikivi Link to comment
deanishe Posted August 9, 2016 Share Posted August 9, 2016 Then you will have to set a workflow variable that you can filter on to get your if-else. Link to comment
nikivi Posted August 9, 2016 Author Share Posted August 9, 2016 I am trying to make it work now but I am not really sure how would the if-else filter work with my workflow variable. Can you perhaps show me how one can do that if you have time? Here is the workflow I am working with : https://infinit.io/_/33EnBNF Thank you. Link to comment
deanishe Posted August 9, 2016 Share Posted August 9, 2016 (edited) You set a workflow variable, then put a filter on each branch. For example, you set the variable ACTIVE_APP, then one filter is if {var:ACTIVE_APP} is equal to iTerm and the other is if {var:ACTIVE_APP} is not equal to iTerm. Edited August 9, 2016 by deanishe Link to comment
nikivi Posted August 9, 2016 Author Share Posted August 9, 2016 (edited) I think I have done something wrong as it does not work. Here is what I did : I believe you set the variable here, not sure what value I should give it so left it blank. Created two filters for each branch : Top filter : Bottom filter : Edited August 9, 2016 by nikivi Link to comment
dfay Posted August 9, 2016 Share Posted August 9, 2016 I still don't get why you wouldn't just activate iTerm right at the start, then write one set of actions based on the knowledge that is active..... Don't you want it active at the end in any case? Link to comment
nikivi Posted August 9, 2016 Author Share Posted August 9, 2016 I still don't get why you wouldn't just activate iTerm right at the start, then write one set of actions based on the knowledge that is active..... Don't you want it active at the end in any case? I just want a global hotkey that I can use from any application that I am in right now. Of course I can activate iTerm afterwards myself but it would be nicer if it would be activated for me. Link to comment
dfay Posted August 9, 2016 Share Posted August 9, 2016 right. set a global hotkey in Alfred that runs an Applescript that tells iTerm to activate, then proceed from there. Link to comment
deanishe Posted August 9, 2016 Share Posted August 9, 2016 I think I have done something wrong as it does not work. Here is what I did : I believe you set the variable here, not sure what value I should give it so left it blank. You can't set the variable in the configuration sheet. How are you going to set that dynamically based on whether iTerm is active? Link to comment
nikivi Posted August 10, 2016 Author Share Posted August 10, 2016 Thank you all for help. I have made it work with having this script be run right after the hotkey trigger : dfay 1 Link to comment
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