Doom Posted March 3, 2014 Share Posted March 3, 2014 It should be possible to stop the script immediately when the user is still typing. When I have a slower workflow I see, that when I write "word", that the script is still showing the items for "w". Link to comment Share on other sites More sharing options...
deanishe Posted March 8, 2014 Share Posted March 8, 2014 That would require Alfred to kill the workflow process, which might leave the workflow's saved/cached data in an invalid state. The alternative—Alfred running multiple instance of your workflow—could also result in corrupt data, API bans for running too many queries and other problems. What does your workflow do? Caching results and/or not responding to one-letter queries might help with the performance. Link to comment Share on other sites More sharing options...
Doom Posted March 16, 2014 Author Share Posted March 16, 2014 (edited) i thought about a checkbox, when i activate it, the process will be killed immediately. i have many cachesystems and work with the ram, i think php isnt fast enough. i have a workflow, which creates new files on the current location. the problem is, when i type too fast, e.g. "new index.php", and press enter, it creates a file named index.txt (default extension, when i dont write an extension, e.g. when i write index or index.) i worked for a long while and tried the folowing thing: if the last char is a dot, then »tell application "Alfred 2" to search« (opens alfred window), but this works sometimes, doesnt work, when i am too fast and it recognizes just "new index" API bans for running too many queries a limit would also be a possibility. it could run 5 threads parallel and when the first thread dies, the next thread could start. Edited March 16, 2014 by Doom Link to comment Share on other sites More sharing options...
deanishe Posted March 16, 2014 Share Posted March 16, 2014 It sounds like the problem is, as you say, that PHP isn't fast enough. Link to comment Share on other sites More sharing options...
vitor Posted March 17, 2014 Share Posted March 17, 2014 Similar requests have been made multiple times from multiple people, including me, at one point, and they’re still being discussed.However, for your particular case, why are you using a Script Filter to type a file name? Script filters are slow and inadequate for when you need to dynamically type an action that will be acted on depending on what you typed; they’re more geared towards retrieving and presenting information. I ran into that same wall with PinAdd, and had to change how the workflow works to get around that. This case is way simpler, though, why not use just a Keyword? It works well for this purpose. Link to comment Share on other sites More sharing options...
Doom Posted March 17, 2014 Author Share Posted March 17, 2014 i like script filters. the history is live and works with this script filters and i need this for many more extensions, nearly all of my extensions works with script filters the way how to display the items is what i prefer Link to comment Share on other sites More sharing options...
deanishe Posted March 17, 2014 Share Posted March 17, 2014 How are you getting the current directory? Are you running an AppleScript to get it? Link to comment Share on other sites More sharing options...
vitor Posted March 18, 2014 Share Posted March 18, 2014 The last example you showed, FirePanther, looks like a great example of a good use case for a Script Filter — you’re searching for something, which means you will see results update and act on those (i.e., you need to first see them to decide to act on them, and the passed arguments are fully formed in those options), while on the “new file” example, what you write will have a direct influence in what command is output.Even though the question was not directed at me deanishe, when I need to do it, I usually do something like this -- with this method -- if a Finder window is open, it’ll return the path to the frontmost one, else it’ll return the path to the desktop tell application "Finder" to return (quoted form of POSIX path of (insertion location as alias)) -- with this method -- if a Finder window is the frontmost window app, it’ll return the path of the frontmost one, else it’ll return the path to the home directory tell application "System Events" if (name of first process whose frontmost is true) is "Finder" then tell application "Finder" to return (POSIX path of (folder of the front window as alias)) else return (POSIX path of (path to home folder)) end if end tell If I need the result in bash, or something like that, I do something like myDir=$(osascript -e '<the above code>'. Link to comment Share on other sites More sharing options...
Doom Posted March 18, 2014 Author Share Posted March 18, 2014 How are you getting the current directory? Are you running an AppleScript to get it? yes, with cache for fast typing function getActiveFinder() { $cache = '/tmp/alfred-finder.cache'; if (is_file($cache) && filemtime($cache) > time() - 2) { $finder = file_get_contents($cache); } else { // activate finder $finder = @exec('osascript -e "tell application \\"Finder\\" to return POSIX path of (insertion location as alias)"'); file_put_contents($cache, $finder); } return $finder; } Link to comment Share on other sites More sharing options...
deanishe Posted March 18, 2014 Share Posted March 18, 2014 (edited) Even though the question was not directed at me deanishe, when I need to do it, I usually do something like this I was just thinking that running AppleScripts all the time would slow the workflow down considerably: it takes ~0.3 seconds on my machine. Still, he's caching it, so I dunno. Edited March 18, 2014 by deanishe Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now