> [Sorry, I've submitted my previous message too early by accident.]
> Can I use JSTalk to send and get text to the clipboard?
> Also, is it possible to simulate key presses?
> How would I go about doing these?
Key presses have always been a bit odd on Mac OS X. I've been wanting to build a plugin to help with this actually, but haven't gotten around to it yet.
Here's a sample script which grabs the clipboard, adds some text to it, puts it back on the clipboard, and then simulates a cmd-v key press.
var pasteBoard = [NSPasteboard generalPasteboard];
// grab a string on the paste board. var pbString = [pasteBoard stringForType:NSStringPboardType];
// make a new string based on it: var newString = pbString + "!!!";
// tell it we're going to be putting a single string type on the pasteboard [pasteBoard declareTypes:[NSStringPboardType] owner:null];
// and then put it on [pasteBoard setString:newString forType:NSStringPboardType]
// simulate a cmd-v // 55, and 9 are virtual key codes. There's probably a reference somewhere for this. CGInhibitLocalEvents(true); CGEnableEventStateCombining(false);
Thank you for your very complete example. I've just set up JSTalk and
ran successfully the default script in the Editor. I'll try your
example now...
But, I was wondering, should the "jstalk" file (from the binary Zip
you provided) be copied to any particular folder (besides being one
that's in the PATH)?
On Sep 5, 9:23 pm, Gus Mueller <g...@flyingmeat.com> wrote:
> Thank you for your very complete example. I've just set up JSTalk and > ran successfully the default script in the Editor. I'll try your > example now...
> But, I was wondering, should the "jstalk" file (from the binary Zip > you provided) be copied to any particular folder (besides being one > that's in the PATH)?
You've lost me here, sorry :)
How are you wanting to run the script? From a hotkey, out of the JSTalk editor, from the command line? Something else?
Sorry, Gus. I was referring to the files in the installation .zip. I
assume "JSTalk Editor.app" can go into the "Applications" folder. But
where does the "jstalk" file go into?
>> Thank you for your very complete example. I've just set up JSTalk
>> and
>> ran successfully the default script in the Editor. I'll try your
>> example now...
>> But, I was wondering, should the "jstalk" file (from the binary Zip
>> you provided) be copied to any particular folder (besides being one
>> that's in the PATH)?
> You've lost me here, sorry :)
> How are you wanting to run the script? From a hotkey, out of the
> JSTalk editor, from the command line? Something else?
> Sorry, Gus. I was referring to the files in the installation .zip. I > assume "JSTalk Editor.app" can go into the "Applications" folder. But > where does the "jstalk" file go into?
Oh- that's a command line tool for JSTalk.
Good question. So, I'm not sure where the "recommended" place to put unix executable places is these days. In my home dir, I've got ~/unix/ bin , which I add to my $PATH, and that's where I put odd scripts and such that I don't want clobbered by the system.
You might try that if sounds reasonable. Or if anyone else has any other suggestions...?
Ah, ok. I've been putting stuff like that in "/usr/local/bin" -- I
think that's the correct place (that directory was recommended in some
other program's installation instructions), but I'm not really really
sure. ;)
>> Sorry, Gus. I was referring to the files in the installation .zip. I
>> assume "JSTalk Editor.app" can go into the "Applications" folder. But
>> where does the "jstalk" file go into?
> Oh- that's a command line tool for JSTalk.
> Good question. So, I'm not sure where the "recommended" place to put
> unix executable places is these days. In my home dir, I've got ~/ > unix/
> bin , which I add to my $PATH, and that's where I put odd scripts and
> such that I don't want clobbered by the system.
> You might try that if sounds reasonable. Or if anyone else has any
> other suggestions...?