Jump to content

Compton

Member
  • Posts

    11
  • Joined

  • Last visited

Posts posted by Compton

  1. On 2017-01-02 at 4:31 PM, rr326 said:

    Is there a way to open a new note IN EVERNOTE (and have the window open up and start typing there)?

     

    Sorry if I'm not using this right, but it seems like all the ENN options create the note directly in the Alfred window. I'd like to be able to just open up evernote with a new note being created.  

     

    (And I could make my own one workflow -with some guidance)

     

    Thanks.

     

    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. 

     

    big-thank-you3.gif

  3. Lastly... why, if you're trying to control Transmission would you want to activate TextEdit? I don't get it.

     
    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.  

    Incidentally, the modified code below works just fine in Alfred's osascript --

     

    tell application "System Events"
      if (name of processes) contains "Safari" then
        set is_running to true
      else
        set is_running to false
      end if
    end tell
    
    
    if is_running is true then
      tell application "TextEdit" to activate
    end if
    
    if is_running is false then
      tell application "Preview" to activate
    end if

     

     

    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. The code checks to see if the application is running and then based on that runs through two if's (not an else, or else if to ensure that it should execute both). Even in Alfred, this returns the correct value every time. If it executed both, I should get 2 dialogs and I only get one each time. So, without looking at the full code, I'm not sure how much help I can be.

     

     

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