Jump to content

GuiB

Member
  • Posts

    366
  • Joined

  • Last visited

  • Days Won

    19

Everything posted by GuiB

  1. 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 »)
  2. @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`
  3. 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) )
  4. 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
  5. 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".
  6. @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)
  7. 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).
  8. 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
  9. 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
  10. 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).
  11. 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" )
  12. 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
  13. Actually, I've done it from time to time as well as a joke to some of my friends
  14. 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/
  15. Have you tried EggTimer ? There's an alarm function and different timer features... maybe you'll find what you're after!
  16. 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...
  17. 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://d.pr/f/jSrHh3 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
  18. Beside @deanishe suggestion to use the native shortcuts, you can use Preview to create an image file from the image in your clipboard. Just copy an image as you want, then open Preview and create a new file using "File -> New from Clipboard" in the menubar (or CMD+N). Then you should see your image and be able to save it in the format that you want.
  19. @politicus, hey, thanks for the kind words! This is really appreciated!
  20. Those are coming from your Fallback Results. You can modify your Fallbacks list at: Alfred's Preferences > Features > Default Results > Fallbacks > Setup Fallback Results . Just select the fallbacks that you don't want to see anymore and remove them with the minus ("-") button.
  21. As an alternative to the 'find' keyword @vitor said, myself I'm doing it using the Quick Search feature. Make sure the "Quick Search" preference is activated in "Alfred's Preference > File Search > Quick Search" and then you can simply insert a space or an apostrophe " ' " to put Alfred into the "find" files mode. Then, to reveal a file in Finder, Alfred as shortcuts that you can use and set to different action and one of those actions is "Reveal in Finder (if local)"; Look into: "Alfred's Preferences > Advanced > cmd + ↩" or other modifier key shortcut. My Alfred is set so that CMD+Enter is set to this actions ("Reveal in Finder (if local)"). Then, when I search for something in Alfred using a core feature and want to reveal the selected item in Finder, I can simply press CMD+Enter and Finder would pop with the file. So in short, to reveal a file in Finder using Alfred I do: Pop Alfred (CMD+Space is my hotkey) Press space to put Alfred into the Quick File Search mode Write into Alfred what you want to search (ex: myfile) Alfred would show a list of items, select the one that you want to reveal Press CMD+Enter (or the modifier key you've set in the Alfred's Advanced Preferences) Then Finder should pop with your file selected About right clicking to reveal a context menu, as @vitor again said, the Alfred's alternative is the File Actions menu. From my understanding, I don't think you only want the Get Info pane as vitor showed you, but mainly the list of File Actions. Therefore, when you do your Show Actions shortcut as vitor told you, you will get a list of actions that can be a little like the Finder context menu, but not exactly the same list, but maybe you'll find what you're looking for. To name a few, there's the 'Open', 'Open With', 'Get Info', 'Show Package'... Make sure to activate the default actions that you want when you are into the Alfred's Actions Preferences Pane (look for the list next to: Default Actions). If you can't find a specific action that you wish to call on your file, then you may have look finding a Workflow here in the forum that would create a file action that do what you want or you can create one using the "File Action" object in the Workflows editor. I hope this help! Best
  22. @Beiling, it would be great to have this feature directly possible in the standard Alfred Snippets section, but if you don't mind creating Workflows for your snippets, look in my attached post to have a look at a way to paste image from Alfred. You will have an example to set a snippet and to use it directly from a Hotkey. Just duplicate the objects to create another snippet and make sure to replace "/path/to/your/image" in the Run Script with the path to your actual image and you should be good to go.
  23. Here it is: https://cachefly.alfredapp.com/Alfred_2.9_446.dmg
  24. I'm not sure I get exactly what you want, especially in regards to making Google Hangouts the Default for Calls in FaceTime, but if you want to instantiate a Call with Hangouts using a selected phone of a contact in Alfred, then here is a solution. To open Hangouts to make a phone call of a specific number, I got this to work with this link: https://hangouts.google.com/?action=chat&pn=+1XXXXXXXXXX (where "+1XXXXXXXXXX" is the phone number you want to call) So, you then need to create a Contact action linked to the Phone field of a contact and use the Alfred Open URL workflow object with "https://hangouts.google.com/?action=chat&pn={query}" to instantiate the call. Here is a workflow that do that: https://nofile.io/f/xZr0Xmps7tF/Call+with+Hangouts.alfredworkflow To Install: Install the Workflow Go into "Alfred Preferences > Features > Contacts > Custom Actions" and create a new action with "Phone" as Contact Field and "Call with Hangouts" as the Action
×
×
  • Create New...