quicksilver / Quicksilver

Quicksilver Project Source
http://qsapp.com
Apache License 2.0
2.74k stars 285 forks source link

Applescripts and Process text... 3rd pane gone #144

Closed mackeyorama closed 13 years ago

mackeyorama commented 13 years ago

I used to be able to use applescripts with quicksilver and the process text operation but it hasn't been working for a while now for me. The Process Text command is still in the actions list and shows up when the applescript is in the first pane, but that is useless without being able to enter some text using period text entry. It should only show up as a third pane but it doesn't seem to recognise the scripts when they are in the second pane.

It seems to be a process text problem as many other actions still use the third pane such as "email to", and "move to" etc.

All the scripts I use worked a while ago (previous QS builds) and contain the quicksilver terms e.g.

    using terms from application "Quicksilver"
on process text 

I have done a bit of searching for a solution and this seems to have been a problem in previous builds but was supposed to be fixed. Is anyone else have this problem with snow leopard and B58 (3841)?

pjrobertson commented 13 years ago

It may have been fixed in the latest commit.

Can you please tell me the exact steps / commands you are inputting into QS and what is/isn't working so I can see if the latest version works. I'm sorry, I'm not following you 100% above (There's so much to QS that not everybody knows about!)

mackeyorama commented 13 years ago

Hi, Thanks for replying pjrobertson! I am using QS B58 (3841) I haven't had a look at the latest commit yet, but I shall try and outline the problem hopefully a bit clearer here.

My problem is with the QS, process text action for apple scripts. It allows QS to send text to apple scripts for them to do some desired action, sort of similar to the calendar event action that can process entered text.

These are the steps I used to be able to do: Method 1 Invoke QS > search for desired apple script > tab to 2nd pane (process text automatically appears, this still happens) > 3rd pane appears (this does not happen any more), tab to it and enter text that you want the script to perform an action on. here is a picture of what I get:

Alternative steps Method 2: Invoke QS > period(.) and enter some text > tab to next pane and search for apple script > third pane automatically appears with "process text" action in it (this no longer happens).

Below is a twitter apple script that uses process text, give it a go and you might see that the process text pane doesn't allow text entry in the third pane as in method 1 above. Process text does not appear at all in the second method. The script action below is not important it is only ment as an example that the process text pane no longer seems to work.

using terms from application "Quicksilver" on process text inputText tell application "Keychain Scripting" set twitter_key to first Internet key of current keychain whose server is "twitter.com" set twitter_login to quoted form of (account of twitter_key & ":" & password of twitter_key) end tell set twitter_status to quoted form of ("status=" & tweet) set results to do shell script "curl --user " & twitter_login & " --data-binary " & twitter_status & " http://twitter.com/statuses/update.json" -- display dialog results return nothing end process text end using terms from

pjrobertson commented 13 years ago

I've now tested this out, and can confirm it doesn't work as expected (thanks for the great/clear instructions)

Coincidentally, another developer mentioned this bug at the Developer Groups today, so we are looking into it

http://groups.google.com/group/quicksilver---development/browse_thread/thread/85ca4fbfd269c2b2

mackeyorama commented 13 years ago

And here I was thinking QS development was dead in the water again. So thank you for looking into my post. I was almost dare I say, thinking of finally switching to Launchbar! Especially since the last time I visited the blacktree site a few months ago the QS page wasn't even there, now I see it has its own domain. :))

I am now thinking of putting together some plugins again. Maybe not have to rely on Applescripts for twitter! Github still seems quite on the QS front is most of the action in the Google group or the new QSApp site?

Vive la QS!

pjrobertson commented 13 years ago

It's certainly not dead! Launchbar - bah!

Hopefully Rob is looking into this bug, and will be able to update us soon. It's most likely a bad commit that happened a while back, so if we can revert it we'll get the functionality back :)

One things (other than bug squashing) we've been working hard on is documentation. There's lots for developers in the wiki: http://qsapp.com/wiki and probably the best I can recommend is Rob's Plugin Development Reference: http://projects.skurfer.com/QuicksilverPlug-inReference.mdown

If you have any ideas about plugins then post in the Dev groups (Google Groups are for support). We've actually just started a post on making a Twitter plugin as well (you weren't the original developer were you?) http://bit.ly/gGLQ8G

skurfer commented 13 years ago

Yes, I’m looking into it. I’d like a fix to be in B59, but I don’t want to hold it up if that’s all we’re waiting on.

FYI, I’m starting by looking at this commit and this one. Still trying to figure out what they did and if its relevant.

mackeyorama commented 13 years ago

Cheers Rob! I agree go ahead with B59, it is a very obscure action for most people. It is a good one though.

skurfer commented 13 years ago

Still working on this. Debugging shows that validIndirectObjectsForAction: is never being called. From that I see that AppleScriptProcessTextAction has no indirectTypes defined, but

  1. Adding them (and adding indirectOptional = false) doesn’t fix it
  2. FileCopyToAction has no indirectTypes, but it does bring up the third pane. (Strangely, FileMoveToAction has indirectTypes.)

So I’m not sure what to check from here. There must be something else that triggers the third pane besides property list settings for the action. Any theories?

skurfer commented 13 years ago

OK, fixed it, but now I have to figure out why to make sure it doesn’t break anything else. This line always returns 1. Turns out if it returns 2 instead, you get a third pane.

pjrobertson commented 13 years ago

Interesting, I'm not sure as to why this was '1' in the first place. Is there a bad commit changing it? Otherwise - what's making it work in 54 and not 58?

I'd be happy to do some testing if you get a pull request out :)

... Looking quicksilver at commits: f7d3fe1849c538387368https://github.com/quicksilver/Quicksilver/commit/f7d3fe1849c538387368d06f50453c7b57a4dacc#diff-6 and 7dc05ba63f51cc096ae6https://github.com/quicksilver/Quicksilver/commit/7dc05ba63f51cc096ae6367fd8fc817aded6a116 it looks like it always used to be 1. If it just returns 1, what does this give. If it works returning 1 then if may be a problem with Etienne's commit returning 0 too often?

Also, this looks a bit funny (in commit f7d3fe1849c538387368 L:209/216)

-- just the placement of the closing bracket before the ?

On 13 April 2011 06:19, skurfer < reply@reply.github.com>wrote:

OK, fixed it, but now I have to figure out why to make sure it doesnt break anything else. [This line][ac] always returns 1. Turns out if it returns 2 instead, you get a third pane.

[ac]: https://github.com/quicksilver/Quicksilver/blob/master/Quicksilver/PlugIns-Main/QSCorePlugIn/Code/QSAppleScriptActions.m#L237

Reply to this email directly or view it on GitHub: https://github.com/quicksilver/Quicksilver/issues/144#comment_991829

skurfer commented 13 years ago

That first commit you link to: I wondered about that too, but when I looked at it again this afternoon, I noticed that Etienne was adding it and hard-coding it to return 1. It didn’t exist at all before that commit. He later came in and added a ton of logic, but I’m not sure why (yet). It still always returns 1 because the scriptPath is always nil, at least when a script in your Actions folder is in the first pane.

Not sure about the last one. Maybe it throws a syntax error with the parentheses.

So for pull requests, I can’t figure out how to limit them to certain commits. I see the thing to adjust the range, but I can’t figure out how to do what I think I want to do. :) Anyway, I’d like to split up my pull requests, but if I can’t, will you accept one that has the new proxy, the new menu bar, and this fix?

pjrobertson commented 13 years ago

Looks good.

I'm not to sure about the original poster's 'second method':

Alternative steps Method 2: Invoke QS > period(.) and enter some text > tab to next pane and search for apple script > third pane automatically appears with "process text" action in it (this no longer happens).

I can't get an AppleScript in the 2nd pane - is this even possible?

mackeyorama commented 13 years ago

Sorry for the open,close have to be careful on the iPad where your finger fAlls. I will upload a picture of a script in the second pane when I am back at my desktop, i can confirm that it is possible though. I think unless it shows up in the actions catalogue you cannot use it in the second pane, I will confirm this also. It might also need the process text command in the AppleScript.

pjrobertson commented 13 years ago

Cool, that'd be good. I've just done a bit of googling. Unfortunately http://docs.blacktree.com/quicksilver/creations/scripts is down, although I did find this:

http://osdir.com/ml/macosx.quicksilver.user/2008-09/msg00332.html

I see what you have to do to get AppleScripts as Actions - just place them in the Actions folder in the QS support folder. I've tried this and don't see the 3rd pane appear. But - is this really necessary? I mean - you know that QS is going to 'process' the text anyway.

Was it definitely in a previous version, I'd have thought this was always the way it was, especially since the link above says:

There is no way to write an Applescript action that uses the third pane. But you can work with both text and files in the first pane, depending on how you write your script.

which means to me that the 3rd pane has never appeared for other people...

philostein commented 13 years ago

Hey, wouldn't you be able to make Triggers for Applescript actions if Process Text works?

⇧⌃T for SuperTweet.scpt>Process Text>[text] - for example.

That'd be pretty neat. Lots of other possibilities I reckon.

pjrobertson commented 13 years ago

Tested the AppleScript/Trigger combo and it works with Rob McBroom's fix :)

On 13 April 2011 21:11, philostein < reply@reply.github.com>wrote:

Hey, wouldn't you be able to make Triggers for Applescript actions if Process Text works?

⇧⌃T for SuperTweet.scpt>Process Text>[text] - for example.

That'd be pretty neat. Lots of other possibilities I reckon.

Reply to this email directly or view it on GitHub: https://github.com/quicksilver/Quicksilver/issues/144#comment_994788

skurfer commented 13 years ago

Regarding “method 2”… You can’t get just any old AppleScript in the second pane, but you can get the ones in your Actions folder because they become actions. ;) Using this alternate method never broke. (I tested it before digging into this.) There isn’t supposed to be a third pane in this case. You just enter text in the first pane, then run the action on it (which passes it to the script).

Regarding the post on OSDir…

There is no way to write an Applescript action that uses the third pane.

This is true if treating it like an action (in the second pane), but if you call it up in the first pane, the Process Text… action is default and that does provide a third pane. I believe that for this to work, you have to keep a copy of the script somewhere that will get it into the catalog (such as ~/Library/Scripts/). And there’s some magic involved. If the script has this structure:

using terms from application "Quicksilver"
    on process text theText
        do some stuff with theText
    end process text
end using terms from

Quicksilver somehow knows it can take text and will make “Process Text…” the default. Otherwise, the default action for AppleScripts will be “Run”.

Regarding triggers…

Yes, you can use this in a trigger and I do several times a day. I have to track my time at work. I have a script that takes text and logs it to a file. So I made a trigger for Time Log ⇥ Process Text… ⇥ [blank]. When I invoke the trigger, I get a text input field. I type and hit return and I’m done. This could work equally well for Twitter and, like you said, a lot of other things.

Did I overlook anything? :)

skurfer commented 13 years ago

There is no way to write an Applescript action that uses the third pane.

Hey, I wonder if this is why Etienne was messing with the argumentCount. If a script in Actions could somehow specify an argument count of 2, it would cause the third pane to show. I think that’s it since his commit message read “Allow action to configure their argument count”.

mackeyorama commented 13 years ago

You covered everything nicely Rob. I may have been delusional but I am almost certain there was a time when process text did appear in the third pane. I have done a little testing and and have found the reason "method 2" was not working for me and I assumed since the process text was not appearing that nothing was happening. It was a network issue unrelated to QS, so as Rob says above it was not broken but process text doesn't appear any more in that case.

The third pane should appear automatically for "method 1" after the process text action appears so that text can be entered. That seems to be working again, can we call this one closed?

philostein commented 13 years ago

I just tried to create a SuperTweet.scpt>Process Text>[text] trigger, and the prefs trigger creation interface wouldn't allow me to tab to the third pane. I saved the trigger, but the shortcut didn't do anything.

pjrobertson commented 13 years ago

That's what this bug fixes. If you're on the bleeding edge, this would be working :)

On 13 April 2011 23:46, philostein < reply@reply.github.com>wrote:

I just tried to create a SuperTweet.scpt>Process Text>[text] trigger, and the prefs trigger creation interface wouldn't allow me to tab to the third pane. I saved the trigger, but the shortcut didn't do anything.

Reply to this email directly or view it on GitHub: https://github.com/quicksilver/Quicksilver/issues/144#comment_995452

skurfer commented 13 years ago

Patrick is right. If you’re using B58, you won’t be able to create the trigger. And if you have a working trigger (as I did from B54), it won’t do anything because it requires a non-existent third pane.

Anyway, yes, I believe this is fixed. I felt like the fix was a bit hacky, but now that I think I understand what Etienne was up to, I feel better about how I went about it.

pjrobertson commented 13 years ago

Hence the importance of comments ;)

I think we need a discussion about those things... It's a hang up for me from times when assignments would get 0 for bad commenting :o

On 13 April 2011 23:58, skurfer < reply@reply.github.com>wrote:

Patrick is right. If youre using B58, you wont be able to create the trigger. And if you have a working trigger (as I did from B54), it wont do anything because it requires a non-existent third pane.

Anyway, yes, I believe this is fixed. I felt like the fix was a bit hacky, but now that I think I understand what Etienne was up to, I feel better about how I went about it.

Reply to this email directly or view it on GitHub: https://github.com/quicksilver/Quicksilver/issues/144#comment_995528

philostein commented 13 years ago

[bug] Sorry guys, this still doesn't work for me in ß59 (10.6.7).

Process Text… in pane 2 refuses to go to pane 3, with any valid custom text Action selected in pane 1.

pjrobertson commented 13 years ago

@skurfer made the initial fix, so he'll probably have the best idea of what's going on

On 29 April 2011 19:45, philostein < reply@reply.github.com>wrote:

[bug] Sorry guys, this still doesn't work for me in 59 (10.6.7).

Process Text in pane 2 refuses to go to pane 3, with any valid custom text Action selected in pane 1.

Reply to this email directly or view it on GitHub: https://github.com/quicksilver/Quicksilver/issues/144#comment_1074581

skurfer commented 13 years ago

So what’s in the first pane exactly? You can’t select an action there, so I’m not sure what you mean.

philostein commented 13 years ago

In pane 1, you can select custom AppleScript Actions from the ~/Library/Application Support/Quicksilver/Actions folder that take text using the 'on process text' code. Aren't they the scripts 'Process Text…' should provide a third pane for?

Example Command:

SuperTweet.scpt>Process Text…>[text]

Shouldn't the third pane appear in text mode to allow text entry? I thought it was the compliment to:

[text]>SuperTweet.scpt

skurfer commented 13 years ago

OK I see, but I’m pretty sure the contents of ~/Library/Application Support/Quicksilver/Actions are not in the catalog (by default). I have three scripts there, but only one of them can be brought into the first pane and only because I copied it to ~/Library/Scripts.

Anyway, yes it should work as you describe if one of these scripts appears in the first pane. Can you post the script it’s not working with?

philostein commented 13 years ago

My Actions folder is in the Catalog, so I can call the scripts there into pane 1. Digression: wouldn't navigating to the folder to get a script into pane 1 have the same outcome, even if the script wasn't in the Catalog?

Here's an example Action script called 'Text test':

using terms from application "Quicksilver"
    on process text _text
        show large type _text
    end process text
end using terms from

It works as this command:

[text]>Text test.scpt

but not:

Text test.scpt>Process Text…>[text]

Topical tenuous connection: Could it have something to do with argument count? Colin got a count of 2 to produce the third pane with some scripts.

skurfer commented 13 years ago

wouldn't navigating to the folder to get a script into pane 1 have the same outcome, even if the script wasn't in the Catalog?

Yes, you’re right. I just tried it and I got the third pane as expected.

Here's an example Action script called 'Text test’:

I copied the script exactly as you have it and saved it to ~/Library/Scripts. When I call it up in the first pane, I get “Process Text…” with a third pane.

Could it have something to do with argument count? Colin got a count of 2 to produce the third pane with some scripts.

The argument count is what triggers the third pane, yes. However, if the action in the second pane is “Process Text…”, the argument count is hard-coded to 2 (this was how I fixed it originally). The argument count returned by the script should be ignored.

philostein commented 13 years ago

I'm glad it's working for someone, but it still doesn't work for me. I put the same script in ~/Library/Scripts/ (which is definitely in my Catalog) and tried it from there. Still nothing, even with Process Text… dragged to the top of the Actions list so it appears first. I saved the code I gave you directly to ~/Library/Scripts/ and tried that, but no luck. No third pane. I recently re-installed ß59 after trying a github build.

skurfer commented 13 years ago

If you’re able to build from source, you could try the poor-man’s debugger and just add a few lines like this here and there in PlugIns-Main/QSCorePlugIn/Code/QSAppleScriptActions.m starting around line 232.

NSLog(@"argument count %@", argumentCount);

You might also want to log the value for actionId.

philostein commented 13 years ago

I'll give it a go, thanks.

philostein commented 13 years ago

I put some NSLog(@"argument count %@", argumentCount); lines in QSAppleScriptActions.m.

When running a 10.5 compiled QS, I don't see any NSLog messages in the Console or in XCode's debugger window. That's from either: build and run in XCode, or launching from the app icon in /private/tmp. I don't have any other unzipped QS's on the system.

When making the [action]>Process Text… (still no pane 3) Command, I only get a response from the Console when pressing enter:

30/04/2011 13:42:53 Quicksilver[7051] Unhandled AE conversion from descriptor (null)

I have yet to see any NSLog messages. Need to activate something?

philostein commented 13 years ago

Get this a lot in the Debugger Console:

2011-04-30 14:07:46.001 Quicksilver[7201:80f] Incorrect NSStringEncoding value 0x0000 detected. Assuming NSStringEncodingASCII. Will stop this compatiblity mapping behavior in the near future.

pjrobertson commented 13 years ago

That's unrelated. Make sure you've clicked 'Build -> Clean All' in XCode, then 'Build & Run' to get the NSLog to show up in the console or XCode debugger

On 30 April 2011 15:08, philostein < reply@reply.github.com>wrote:

Get this a lot in the Debugger Console:

2011-04-30 14:07:46.001 Quicksilver[7201:80f] Incorrect NSStringEncoding value 0x0000 detected. Assuming NSStringEncodingASCII. Will stop this compatiblity mapping behavior in the near future.

Reply to this email directly or view it on GitHub: https://github.com/quicksilver/Quicksilver/issues/144#comment_1078363

philostein commented 13 years ago

No dice. Clean All Targets then Build and Run. No NSLogs in Debugger window and Console.

Here's my project info.

Base SDK is 10.5, Project Format 3.1-Compatible

http://dl.dropbox.com/u/157506/QS%20XCode%20project%20info.png

pjrobertson commented 13 years ago

That all looks fine. You just need to make sure the NSLog is in the right place Rob suggested. If you're building it correctly then it should all be displaying.

Try using the 'Debug' version. Or one of us could build it for you ... or maybe it is in there, but another action is being called so it's not appearing.

If you click the line number Rob suggested, a little blue arrow will appear on that line number. Then make sure the 'breakpoints' button is pressed in XCode and click 'build and debug' (you have to have 'debug' in the drop down on the top left). When you run the action Quicksilver should then freeze and you should be able to see some stuff in XCode debugger.

On 30 April 2011 15:54, philostein < reply@reply.github.com>wrote:

No dice. Clean All Targets then Build and Run. No NSLogs in Debugger window and Console.

Here's my project info.

Base SDK is 10.5, Project Format 3.1-Compatible

http://dl.dropbox.com/u/157506/QS%20XCode%20project%20info.png

Reply to this email directly or view it on GitHub: https://github.com/quicksilver/Quicksilver/issues/144#comment_1078430

skurfer commented 13 years ago

If you don’t want to hit this breakpoint 3 times for every script in your catalog when the app starts, you can turn them off and hit Build and Run, then after the app is loaded, turn on the breakpoints and do your test. It sounds to me like that method never gets called. I wonder if it’s a 10.5 thing, but I don’t have a 10.5 machine to test.

skurfer commented 13 years ago

I did a quick recording to show how you can watch the value of argumentCount change.

http://dl.dropbox.com/u/2214419/Quicksilver/debugger.mov

Though if argumentCountForAction: is never being called, you might need to search the project for references to it and set a breakpoint where it’s supposed to be called (but isn’t).

philostein commented 13 years ago

Thanks Rob, most helpful. I could see this turning into a back and forth of epic proportions…

I copied your workflow as best I could:

http://dl.dropbox.com/u/157506/Phil's%20Debugger.mov

Line 232 doesn't get highlighted when Process Text… is called, and there's nothing in the last Debugger window. I'm probably doing something wrong - on first build and run, QS usually hangs and I have to do it again, and my Trigger shortcuts also show up as unknown. Re-installing ß59 fixes that. I'll search the project for argumentCountForAction: and see if I can get a breakpoint to er… break.

Cheers!

philostein commented 13 years ago

I searched for argumentCountForAction: and found it in:

QSActionProvider.m, QSAction.m, QSAppleScriptActions.m

I set breakpoints on them, and after Build and Debugging QS and typing towards a script Action, the first break was in QSAction.m - I then stepped over a few times.

http://dl.dropbox.com/u/157506/Phil's%20Debugger%202.mov

skurfer commented 13 years ago

There seem to be two argumentCountForAction: methods. I wonder which one is getting called on your system.

Do what you did before, but when you get to line 194 in QSAction.m, do a “step into” instead of “step over”. It’ll go into identifier first so just step over all that, but then it should take you into argumentCountForAction: at which point you can see which file you’re in and what values are being returned. Also, make sure line 193 says “provider” and not “protvider”. (I can see that the file had unsaved changes, so the ’t’ probably wasn’t in the code at compile time, but just make sure.)

philostein commented 13 years ago

I did that, and got this highlighted:

return [[[[QSAction actionWithIdentifier:action] objectForKey:kActionSelector] componentsSeparatedByString:@":"] count] - 1;

It's in QSActionProvider.m

Here's a shot:

http://dl.dropbox.com/u/157506/Step%20in%20line%20194.tiff

Guess: returning an argument count of 1 instead of 2?

skurfer commented 13 years ago

OK, so you’re being taken to a completely different method to get the argument count, which I assume is based on the value of provider. It doesn’t seem to know it’s dealing with an AppleScript. Set a breakpoint at 192 in QSAction.m. (Actually 193 is probably better. If you do 192 like me, you’ll need to “step over” once.)

Once provider has been set, go see what’s in it. Take a look at the upper right panel in this screenshot. Expand out the stuff under provider until you can see the name. What is it?

http://dl.dropbox.com/u/2214419/Quicksilver/provider.png

philostein commented 13 years ago

QSActiom.m 193 doesn't seem to have a submenu for provider in the variable column.

http://dl.dropbox.com/u/157506/QSAction%20m%20193.tiff

No QSActionProvider or NSObject submenus.

pjrobertson commented 13 years ago

...just throwing it out there - it might be an idea to jump on iChat and use 'screen sharing' so Rob can debug your computer himself!? :)

On 2 May 2011 13:27, philostein < reply@reply.github.com>wrote:

QSActiom.m 193 doesn't seem to have a submenu for provider in the variable column.

http://dl.dropbox.com/u/157506/QSAction%20m%20193.tiff

No QSActionProvider or NSObject submenus.

Reply to this email directly or view it on GitHub: https://github.com/quicksilver/Quicksilver/issues/144#comment_1086454

philostein commented 13 years ago

I told you it'd get epic… ;)

Whatever's easier for you guys.

skurfer commented 13 years ago

That had crossed my mind. I’ll send a DM to LoveQuicksilver with my IM info.

skurfer commented 13 years ago

Patrick, you’ll be happy to know that it was all your fault. Well, it makes me feel better anyway. :)

I couldn’t quite explain what I was seeing in the debugger, but I remembered something I thought of yesterday. This is handled by the Core Support plug-in. Has anything atypical happened with that plug-in in the last few months? ;)

So maybe we should say something on the users’ list about removing it from ~/Library/Application Support/Quicksilver/PlugIns if it exists there.