Jump to content

Compton

Member
  • Posts

    11
  • Joined

  • Last visited

Everything posted by Compton

  1. 1. Activate Alfred preferences 2. Go to "Workflows" tab 3. Click the "+" sign at the lower left corner 4. Select "blank workflow" 5. Right click to add a workflow object 6. Select trigger -> hotkey 7. Assign hotkey 8. Right click again to add an action 9. Select action -> run NSAppleScript 10. Add the code below activate application "Evernote" tell application "System Events" keystroke "n" using {command down} end tell 11. Connect the hotkey and action by dragging a line between them 12. Trigger the hotkey to activate the script Not sure if this is what you wanted but perhaps you can work your way from here.
  2. Your workflow works but I noticed that you used NSApplescript whereas my problematic workflow was done with "run script" action with /usr/bin/osascript. The same script (without the "on alfred" handler) does not function properly with /usr/bin/osascript. Anyway, thanks for the solution and the other suggestions. I'll definitely look into bash scripting.
  3. Frankly I'm not interested in TextEdit. I'm interested in making sure that I'm not sharing torrent files when I'm connected to my university VPN through a tunneling application called Viscosity. The script is supposed to check whether Transmission is active before turning on the VPN connection and if it is, to turn off file sharing. This is what I started with: on is_running(appName) tell application "System Events" to (name of processes) contains appName end is_running if is_running("Transmission") then tell application "Transmission" to activate tell application "System Events" tell process "Transmission" click menu item "Pause All" of menu "Transfers" of menu bar 1 end tell end tell tell application "Transmission" close window 1 end tell end if tell application "Viscosity" disconnectall delay 1 connect "HY_VPN" end tell The problem is the same as in the simplified Safary/TextEdit/Preview script; Transmission gets unnecessarily activated every time the script is launched through Alfred, regardless of whether it is running or not. In other words, the script acts as if the test condition is true when in fact it is false. I guess I have to give up with trying to run the script directly from Alfred. The script works fine if I save it as an application in Applescript Editor and then only launch it through Alfred. My final request to Shawn Rice is to create a workflow of the Safari/TextEdit/Preview script and share it. I would like to import it to Alfred and see what happens. In any case, thank you very much for trying to help.
  4. It works for me too (as it always has) if Safari is running. In that case only TextEdit is activated. However, if Safari is not running, then TextEdit and Preview get launched. I created a blank workflow with input = keyword and action = run script (language osascript) and pasted your code in. Still both programs get launched if Safari is not running. If Safari is running, only TextEdit gets launched. Can you make sure that you have terminated all three programs (Safari, TextEdit & Preview) and then run the script through alfred using a keyword activation? If it still works for you, then I guess I have to give up and believe that the problem is between my ears
  5. Just downloaded the linked workflow on my friend's computer and exactly the same thing occurs. If I run the "troubleshooting2" script through alfred while Safari is not running, the computer behaves as if the condition is true and untrue at the same time, i.e. it launches both programs. However, this does not happen if the same exact code is run in Applescript Editor. tell application "System Events" if (name of processes) contains "Safari" then set is_running to "true" else set is_running to "untrue" end if end tell if is_running = "true" then tell application "TextEdit" to activate end if if is_running = "untrue" then tell application "Preview" to activate end if
  6. If I copy and paste your script in Applescript Editor, I get the message "It's true" or "It's not true". If I paste the same exact script in an Alfred Workflow and run it, I get no message at all. Here's my workflow with two different actions, "troubleshooting1" and "troubleshooting2": https://dl.dropboxusercontent.com/u/345710/Troubleshooting.alfredworkflow The "troubleshooting1" action runs your script. Like I mentioned, nothing happens if I run it through Alfred but I get the messages if I run it through Applescript Editor. The "troubleshooting2" is my script which is supposed to check (for demonstration purposes) whether Safari is active and if it is, it launches TextEdit. If Safari is not active, it is supposed to launch Preview. This is what happens in Applescript Editor. However, both TextEdit and Safari are launched whenever I run the script through Alfred. If I copy and paste the script from Alfred to Applescript Editor, the script again works correctly. I'm running Alfred 2.0.7 (205) with OSX 10.8.4.
  7. I wrote a script which worked perfectly in Applescript editor. I then created a workflow with the same exact script and the outcome is very different. The script checks whether an application called "Trasmission" is running and if so, performs certain things. Below is the simplified version of the script. This simplified version is supposed to launch Transmission if its not running. If Transmission is running, the script is supposed to launch TextEdit. This is exactly what happens if the script is run in Applescript Editor. However, if I copy and paste the script into Alfred and run with the "usr/bin/osascript" language, both scripts are run as s if the variable "is_running" is both true and untrue. Could someone please explain what is going on? Thanks. tell application "System Events" if (name of processes) contains "Transmission" then set is_running to "true" else set is_running to "untrue" end if end tell if is_running = "true" then tell application "Transmission" to activate tell application "System Events" tell process "Transmission" click menu item "Pause All" of menu "Transfers" of menu bar 1 end tell end tell tell application "Transmission" close window 1 end tell end if if is_running = "untrue" then tell application "TextEdit" to activate end if
×
×
  • Create New...