Jump to content

winterflags

Member
  • Posts

    22
  • Joined

  • Last visited

Posts posted by winterflags

  1. I've set up a simple Hotkey-triggered NSAppleScript that will keystroke the query currently in the clipboard:

     

    on alfred_script(q)
    	tell application "System Events"
    		keystroke q
    	end tell
    end alfred_script

     

    My question is, what if I use this to keystroke passwords? Can I do it securely?

     

    Obviously there is a clipboard history that needs to be disabled.

    Are there also Alfred logs somewhere that keep the results of the workflow/applescript?

    Does it matter if the script uses the "compile" settings or not?

     

    Thanks!

  2. 53 minutes ago, deanishe said:

    This should do the trick:

     

    set myName to computer name of (system info)

    if myName = "MACHINE NAME" then

        tell application "Alfred 3" to search

    end if

     

     

     

    Thanks a lot!

     

    Got it to work by assigning hotkey and binding it to a Run NSAppleScript with these contents:

     

    on alfred_script(q)
    	set myName to computer name of (system info)
    	if myName = "Computer-A" then
        		tell application "Alfred 3" to search
    	end if
    end alfred_script

     

  3. 4 hours ago, dfay said:

    You can use Applescript to write a workflow that behaves differently depending on which computer it's running on.  Basically you'd set your hotkey to call an Applescript like this:

     

    
    set theComp to computer name of (system info)
    if theComp = "computer A" then
    	// do something
    else if theComp = "computer B" then
    	return
    end if

     

     

    Thanks for that dfay, that should work nicely.

     

    I tried assigning an Alfred Hotkey to SHIFT + ALT + SPACE, and then tried to bind it to Run NSAppleScript and alternatively Run Script, can't get it to work however.

     

    Should this script be functional?

     

    set theComp to computer name of (system info)
    if theComp = "Computer-A" then
    	tell application "System Events" to keystroke "space" using {option down}
    else if theComp = "Computer-B" then
    	return
    end if

    I also tried to prepend/append:

    on alfred_script(q)
    end alfred_script

    … which didn't do anything.

     

    FYI, I got computer name via 

    scutil --get ComputerName

     

  4. Is there some way to exclude a certain workflow from syncing between my two computers running Alfred? I'm using Dropbox to sync Alfred.

     

    The reason is that when I access computer A from computer B via screen sharing, pressing ALT + SPACE will Show Alfred on computer B, and not computer A.

     

    So I've set up an alternative Hotkey to Show Alfred. But now I need to be able to only use it on computer A, and not computer B.

     

    Thanks!

  5. Create a File Action (or File Filter) and connect it to a Run Script Action with Language = /bin/bash and with input as argv (i.e. the defaults).

     

    Put this in the Script box:

    basename "$1"

     

    That will print the, well, basename (the bit after the last /) of the actioned file. Connect that to your Open URL Action and you're good to go.

     

    Perfect – it works. Alfred is such a great tool. Thanks!

  6. Hello everyone! I've started working on an Alfred workflow that's supposed to take a Finder item, and search for its filename on the web (preferably on a specific site using Google).

     

    My thought was to use the File Filter to select the file in Finder, and then use the Action menu to open my workflow.

     

    It should then just be a matter of passing the filename to Open URL along the pattern of: 

    https://www.google.com/search?q={query}%20site%3Amyhomepage.com

    But how do I get the filename and create a query out of it?

     

    Is there an easy way to do this using Alfred's native tools, or is a Bash/AppleScript/etc solution necessary?

     

    Advanced: What if I want to add some conditional rules, like removal of substrings or extension from the filename? (I'm still happy with just the basic functionality though)…

     

    Thanks!

  7. Edit: I realized that the thread topic is ambiguous. The problem I'm having is that including a certain AppleScript in my Alfred workflow makes the Alfred bar behave weird, refusing to go away.

     

    I've made a workflow that uses a List Filter to open a set of URLs depending on the argument provided.

     

    I also included an AppleScript that tells Evernote to open a certain notebook/stack. The script is visible as the /usr/bin/osascript in the image below.

     

    When I run the workflow with the AppleScript attached to it, the Alfred Input Window closes but then displays again – with the previous input still there. It behaves very erratically each time, sometimes "blinking" on/off in perpetuity, which seems to be impossible to stop, except by rebooting the computer.

     

    When I run the workflow without the Applescript attached, the Alfred Input Window closes normally.

     

    Something seems to force the Alfred window to remain open. Is it a bug in Alfred, or something with the AppleScript and how it's implemented in the workflow?

     

    Note that I didn't write the AppleScript myself, but it was retrieved from the forum link above. I understand that this isn't the proper forum for AppleScript support – but is Alfred behaving in an unexpected way here?

     

    Thanks for any help!

     

    LvNf6QB.png

     

    on run argv
        set destination to "stack:Communications"
    
    
        tell application "System Events"
             -- Let's make sure Evernote is running. If Evernote needs to be started, wait a sec!
             if not (exists process "Evernote") then
                  tell application "Evernote" to activate
                  delay (3)
             end if
             -- Now let's invoke a collection window by starting a global search.
             keystroke space using {option down}
             delay (0.5)
        end tell
    
    
        -- Sometimes it needs a moment for a collection window to be created.
        -- As long as no collection window exists, trying to change its query string will result in an error.
        -- We'll simply try again until we succeed.
    
    
        repeat
             set tryagain to true
             try
                  tell application "Evernote"
                       set query string of window 1 to destination
                  end tell
                  set tryagain to false
             on error
                  tell application "System Events"
                       keystroke space using {option down}
                  end tell
                  delay (1)
                  set tryagain to true
             end try
             if not tryagain then exit repeat
        end repeat
    end run
  8. Can Alfred Remote sleep/shutdown a computer, even if it is locked?

     

    (Or indeed perform other actions, even if the computer is locked).

     

    The reason I'm wondering is because OS X has a Wake-on-LAN function that wakes my iMac whenever I open my MacBook, disconnect or connect my iPhone to power. I have my iMac in my bedroom, and it's pretty annoying that the iMac wakes when I plug my phone in for charging over the night.

     

    So if I could make Alfred Remote force the iMac to sleep, without having to get up and type in the password to my iMac, it would be great.

  9. Hi @deanishe, thanks for your help!

     

    I'm not sure if I'm quite getting how to do this in practice. Also, I'm not sure how to get the echo to work with the whole Terminal Command (it also does other stuff).

     

    I've added some images just to make it more clear what I'm attempting:

     

    SHYCbVj.png

     

     

    FA63B22.png

     

     

    Terminal Command:

    lKDEjBU.png

     

    (The last image is obviously not going to work with the echo, as it stands).

  10. Based on a File Filter, I want to go to two locations with Terminal, within the same Workflow.

     

    Let's say the file filter path result is: ~/my/folder.

    1. The first part of the workflow will simply go to cd {query} which navigates to ~/my/folder.
       
    2. In the next part of the workflow, I want to keep the last part of the query – "folder" – i.e. the "Display Name" in the File Filter, and interject it in the path ~/my/other/folder.

    I guess there might be multiple ways to achieve this, and the way I've been trying to figure out has been to modify the query via string replacements, so that ~/my/ becomes ~/my/other/

     

    I have also tried to understand upstream variables and if it's possible to get the "Display Name" in the File Filter and simply take that variable and paste it into the path ~/my/other/ so that it becomes ~/my/other/{var} i.e. ~/my/other/folder, but I haven't succeeded.

     

    Appreciate any help with this since I've spent almost an hour now with no results!

  11. I'm experienced enough when it comes to Q&A sites that I know when it's appropriate to state the raison d'être in the question, and when it's not. It doesn't help the economy of the question to state superfluous information.

     

    In this case, I decided that it wasn't necessary, and I still don't believe it is. The question speaks for itself, and why I want to do it shouldn't really be a concern of yours. I wasn't grasping for a general answer, but really just wanted to know if this was the fastest way for Alfred to bind a keyboard command to a character.

     

    Besides, I'm not that unexperienced when it comes to programming that I would need to hear proverbs instead of answers to my questions. You're pretty presumptuous.

     

    TBH, it's pretty obvious that you're really just projecting an idée fixe of yours about XY problems. Interesting mental preoccupations for you, surely, but not really relevant here, and frankly a waste of time.

  12. Not sure why that would be a XY Problem.

     

    Either way, I've spent more time the last five minutes trying to understand what's wrong with my question, than it took to solve it.

     

    The answer was using another application that did it faster. Thanks anyway.

  13. I set up a very simple Workflow that allows me to print the back slash key "\" by pressing a keyboard combination.

     

    Trigger: Hotkey

    -> Copy "\" to clipboard & Automatic paste to front app

     

    However, this is pretty slow (takes about 2-3 seconds).

     

    Am I doing this the wrong way? Or are there actually options out there that can do this a bit faster?

     

    Thanks a lot!

  14. I have set Alfred to open with ALT + SPACE in Alfred Settings.  

     

    I'm wondering if there is a way to set Alfred to open only when using the LEFT ALT + Space combination.

     

    The reason for this is that I regularly use RIGHT ALT to access special keys on the keyboard, and I therefore sometimes accidentally bring up Alfred instead of typing in the current program.

     

    Thanks!

×
×
  • Create New...