Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by GuiB

  1. Have you tried the "Mac Symbols" and the "Emoji Pack" snippet collections ? You can find them here: https://www.alfredapp.com/extras/snippets/ Or if you want to get access to you Mac built-in symbol characters, you can have access to them using the menu item "Edit/Emoji & Symbols" or using the CMD+CTRL+Space shortcut
  2. With what @deanishe said, make sure you don't have another workflow that already uses the Hotkey that you want as Alfred doesn't allow two times the same Hotkey even they are into different workflows. If you try to set a Hotkey that is already registered somewhere else, then it would look like nothing is happening.
  3. @lentaro as @BrianBarr mentioned, there's more way now using the Snippet Trigger. I just sent some workflow in another thread about that, so have a look at this thread and posts to have a way to output Rich Text using a Snippet Trigger. In short, just create a RTF or RTFD file and use it as your snippet.
  4. @rebdeg, ok, I went back home and had a look at this... it's more complex and I'll give another example if I find a simpler way to do it, but I got it working with some AppleScriptObjC. But in short, on your side you just have to change the file path on the first line and it should work. Look here for a Workflow as example: https://nofile.io/f/RXhJKD2bpYC/Example+-+Rich+Text+Snippet.alfredworkflow The main part is this (the AppleScript inside the Run Script is now this): set theFilePath to "path/to/your/RTFD/file.rtfd" ------------------------------------ use framework "Foundation" use scripting additions set pboard to its NSPasteboard's generalPasteboard() pboard's clearContents() set theURL to its (|NSURL|'s fileURLWithPath:theFilePath) set fileWrapper to its (NSFileWrapper's alloc()'s initWithURL:theURL options:0 |error|:(missing value)) set attrString to its (NSMutableAttributedString's alloc()'s initWithRTFDFileWrapper:fileWrapper documentAttributes:(missing value)) set theData to attrString's RTFDFromRange:{location:0, |length|:attrString's |length|()} documentAttributes:{DocumentType:"NSRTFD"} pboard's setData:theData forType:(its NSPasteboardTypeRTFD)
  5. @rebdeg, You're trying to expand a RTFD file (Rich Text Format Directory) instead of a simpler RTF file. RTFD are document, so contains the RTF file inside + associated images... I need to go at the moment, but will have a look later when I come back.
  6. @rebdeg, try adding a delay before pasting. It was working great without on my side, but yes, if your snippets takes a little more time to copy, then a delay will help. Try this new workflow (change de delay time to a value that work better on your side): https://nofile.io/f/NvOjpgwVFOC/Example+-+Rich+Text+Snippet.alfredworkflow
  7. @msw70, about HTML , just change the class to HTML ( read theFilePath as «class HTML» ): set theFilePath to "path/to/HTML/file.html" set the clipboard to (read theFilePath as «class HTML»)
  8. With the Snippet Trigger it is possible to do almost anything... It's not as easy as having a native way of inputting rich text into an Alfred native Snippets, but if you don't mind creating a workflow and a RTF file as your snippet content, then you can simply use a Run Script set to AppleScript that read the content of the file and put it into the clipboard and then paste it to the front application Here is a workflow as example to show you how to do it (basically, just change the path to the file and set your own rtf file path to use your content): https://nofile.io/f/gK6eCRmeHCU/Example+-+Rich+Text+Snippet.alfredworkflow Or, here is the main part of the Workflow to put the content of the RTF file into the clipboard, after that, just connect to a Dispatch Key Combo set to CMD+V to output to the front application set theFilePath to "path/to/RTF/file.rtf" set the clipboard to (read theFilePath as «class RTF »)
  9. @avclark, from the look at your image, you're mixing AppleScripting with Bash scripting. In your image, everything is AppleScript, but you line just before the last one `osascript ~/scripts/ht.applescript` and the Language that your Run Script is set (`/bin/bash`) To run an external AppleScript using a Run Script set into Bash language and passing an argument, just put: `osascript ~/scripts/ht.applescript "$1"` Arguments are passed differently between scripting languages since they have their own syntax. In bash, the first argument can be accessed with $1 (which is used here since alfred pass it's query as one string argument). To start learning, I think you're better building small scripts directly inside Alfred to play around with different scripting languages and start with a default Run Script and switch between languages to see what are the default scripts for each language. You'll see how to catch the arguments into a variable (the default script set a "query" variable to the argument passed). Also, if you want to run a script externally, you would need to make you external script executable by running a terminal command to change its permissions: `chmod +x`
  10. Look in this discussion (first attachment) for some tips and info on this and @Vero gave a workflow for that that may be useful to you (see second attachment) )
  11. Or set 2 environments variables using 2 chained Keyword objects connected to an Arg and Vars object and accessing them using `(system attribute "myEnvVar")` in AppleScript. @avclark, I made a small workflow to show you 3 options: 1 by using 2 Keyword object that each set an environment variable 1 by using 2 Keyword object where one set an environment variable and the output of the other is directly used as the passed argument to the AppleScript 1 by using 1 Keyword object to write your 2 words separated by a space and which the full string is sent to the AppleScript and where both words are extracted Link: https://nofile.io/f/owD6a5d5U2g/Example+-+Pass+two+variables+to+AppleScript.alfredworkflow
  12. To expand @deanishe suggestion, there's a "Snippet Triggers - Getting Started" example in Alfred that would show you some ways to do what you want (especially the "hellomsg" snippet). Look into "Alfred Preferences -> Workflows -> [+] -> Getting Started -> Snippet Triggers".
  13. @Jasondm007, sorry, I don't know what happened, but here is another try at uploading: https://nofile.io/f/RX05s5Z9c8o/Fallback+Search+-+Removed+Keyword.alfredworkflow -------- Edit: Make sure to add the Fallback Search to you Default Results Fallback Searches at : Alfred Preferences -> Default Results -> Setup fallback results -> + -> Workflow trigger -> Search Google for '{query}' (Removing keyword) or Search Google for '{query}' (Removing first word)
  14. I don't think there is a way to deactivate Alfred and reactivate it beside quitting it and opening it again. So, you'll be better to have another application that could do that. I mean, it closes Alfred when your specific game is front most and open Alfred when it is not... But I guess it would make Alfred less responsive and risk of missing keys. Therefore, I think your best solution would be to put your game application into the blacklist all of your interfering hotkeys. To do so, go into your workflows that have an interfering hotkey, open the Hotkey object, go into Related Apps, make sure the "Hotkey is only active when the following apps " is set to "don't have focus" and then drag and drop your application into the list field. Save the popup and then you should be good. Note that, however, you can't have a whitelist and a blacklist (you can't have two list: one set to "have focus" and the other to "don't have focus"), so this will only work if your hotkey doesn't already work only for specific app(s).
  15. Since a fallback search can't determine what you have in mind when you give it a string to process, there's no way it could intelligently remove the first word of a string (well, from my understanding). Therefore, I think you best bet would be to redefine the fallback searches that you wish them to process how you define it. I did a workflow as an example to show you as a way to make a more "intelligent" fallback search based on your criteria. I did two version, but I think the first one would be the best one to use as a replacement to the default fallback search, but need a little more work from your side. In short, you make a list of keywords separated by semicolon and if you send a string to this fallback search and the workflow find that the first word is into this keywords list, then it will remove it or if not found it would keep the string as is. The second example always remove the first word, so maybe best to use next to the default fallback search. To change the keywords list or add to it for the first method, just look into the environment variable in the Workflow preferences. I put ";" as the delimiter, but let you change it if you prefer another one Link: https://nofile.io/f/RX05s5Z9c8o/Fallback+Search+-+Removed+Keyword.alfredworkflow Best
  16. I'm with @Vero about avoiding simulated keystrokes and delay using AppleScript, but in the case of Firefox and interacting with different window and tab, it is hard to get around since there's no applescript dictionary to open a new window or a new tab directly with Firefox. The things that is more reliable is to set the Firefox preference "Open links in tabs instead of new windows" to what you prefer and then it will open links how this is defined (so in your case, since you say that it opens the URL in new window with the Alfred action, then I suppose it is not ticked and set to open in a new window). So, what I recommend is to check this checkbox in the Firefox preferences (Preferences -> Tabs -> [ ] Open links in tabs instead of new windows) and then press Command+N before running a workflow like the one from @Vero or try this script: In this one, I try to limit the bad behaviour of delay and keystrokes by checking if the action was done and if not repeat and check again. So, this should work quite reliably. set urlList to {"https://www.nba.com", "https://www.wikipedia.org", "https://www.cnn.com"} tell application "Firefox" activate repeat 40 times -- gives about 4 seconds to open Firefox if not opened if frontmost then exit repeat delay 0.1 end repeat tell application "System Events" to tell application process "Firefox" set oldNbrOfWindow to (count of windows) keystroke "n" using command down repeat 20 times if ((count of windows) > oldNbrOfWindow) then exit repeat delay 0.1 end repeat end tell repeat with the_url in urlList open location the_url end repeat -- close the first default tab tell application "System Events" keystroke tab using control down delay 0.2 keystroke "w" using command down end tell end tell
  17. Yes, I would say this has more to do on how the application and the OS deal with the received string than how Alfred send it to the application. I mean, to give you some more examples, here are multiple times the same thing where only the "http://" string is added or not to the URL and using only AppleScript: tell application "Safari" to open location "http://alfredforum.com" -- Works tell application "Safari" to open location "alfredforum.com" -- Works tell application "Firefox" to open location "http://alfredforum.com" -- Works tell application "Firefox" to open location "alfredforum.com" -- Doesn't work tell application "Google Chrome" to open location "http://alfredforum.com" -- Works tell application "Google Chrome" to open location "alfredforum.com" -- Doesn't work -- Using the default web browser open location "http://alfredforum.com" -- Works open location "alfredforum.com" -- Doesn't work As you can see here, using "http://" always works but not without (it's only working without in Safari when we directly specify the URL to be open with this application as you see it in Alfred). Therefore, I would say the behaviour we are seeing is not related to Alfred, but how the OS and the specific application deal with the URL that is passed to it. To add more to that, the difference when specifying the application we want to send the link and when using the default application, to use a default application, the OS needs to know the URL scheme to look at which application can open this kind of URL and select the one that is set to be the default. Therefore, if you don't put "http://" then the OS doesn't know if it needs to send the URL to the default web browser, the default file browser (here, the scheme would be "file://" instead of "http://") or any other kind of application that accepts URL (example: any applications that implement x-callback or the like). In the case of Safari that open the link even if there's no "http://" in front, then here the OS doesn't try to find which application can open the kind of link that we are sending since we directly specify that we want it to open the URL using Safari. Then, the link is passed directly to Safari and open it with its own method and may define its own way of dealing with it (like trying to be smart to determine that a passed URL is a web link or a file based on how it is constructed).
  18. The problem is because you need to write the complete URL for your link. I mean, you need to write the scheme of the URL to specify to the system that you are opening a web URL. So, in this case, you would need to write "http://" or "https://" in front of {query} if you don't want to write the full URL in your Workflow keyword node. With this, the OS will look and find which application can open this kind of link and use it. In short, change your URL field of the Open URL node to " http://{query} ", then you'll be able to open a link like "alfredforum.com" or write the complete URL when you invoke your workflow using your Keyword node ( "http://alfredforum.com" instead of "alfredforum.com" )
  19. You'll be better to post your problem at the workflow thread to have the discussion there (look at the attached link). But for your question, I think if you change this line: if '{query}' && '{query}'.include?(?.) To: if !'{query}'.empty? && '{query}'.include?(?.) Then I think this will clear your error
  20. Actually, I've done it from time to time as well as a joke to some of my friends
  21. To go with @vitor's suggestion, I think you could get a great solution by inverting your monitor colors (which you can have access by going to the Display pane in the Accessibility preferences section like @vitor said). If this could be a solution to you, I think you may want a faster access to this control so you can switch the color when you switch application. Therefore, you can have access to the inverting color function or the contrast slider by doing CMD+OPTION+F5. Also, if you prefer to have a direct hotkey to make the switch, you can add it to your Keyboard Shortcut Preferences at System Preferences -> Keyboard -> Shortcuts or have a look at this link for more explanation: https://www.cultofmac.com/215227/make-the-invert-display-keyboard-shortcut-work-again-in-mountain-lion-os-x-tips/
  22. Have you tried EggTimer ? There's an alarm function and different timer features... maybe you'll find what you're after!
  23. Just sending this here to give a solution for an integration between Spark and Alfred, so it is easier for people to find it while searching...
  24. I was intrigued by how to create an email plugin, so I had a look to create one for Spark... Here's what I've found to be the most robust way to make it work with Alfred. In short, I'm combining the script for MailMate found here and @Shana601 way by opening files in Spark (using a do shell script since it seemed to be more robust than the applescript open). I've found that multiple opening of files append the files to the attachment. Therefore, I'm opening a mailto: link to set the emails, subject and body and then another open for the files to be attached. Here is the file/plugin to put into your "~/Library/Application Support/Alfred 3/Plugins/Email/" folder: https://nofile.io/f/4Oe0tVz1Jjm/Spark.applescript Here is the script: -- Use Spark as default email application with Alfred -- Based on MailMate plugin script: https://www.alfredforum.com/topic/2354-add-support-for-mailmate-email-client/ -- Send an email with an attachment on url_encode(theText) return do shell script "printf " & quoted form of theText & " | xxd -u -plain | sed 's/\\(..\\)/%\\1/g' | tr -d '\\n'" end url_encode on create_mailto(_subject, _body, _email, _name) set _to to _email if (_name is not "") then set _to to _name & " <" & _email & ">" end if return "mailto:?to=" & url_encode(_to) & "&subject=" & url_encode(_subject) & "&body=" & url_encode(_body) end create_mailto on send_email_with_attachment(ename, eemail, esubject, ebody, eattachment) set _mailto to create_mailto(esubject, ebody, eemail, ename) tell application "Spark" activate open location _mailto with trust end tell repeat with attachment in eattachment do shell script "open -a Spark \"" & attachment & "\"" end repeat end send_email_with_attachment
  • Create New...