Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Communicate with the Clipboard? And Keystrokes?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Andy L  
View profile  
 More options Sep 5 2009, 3:00 pm
From: Andy L <underwater...@gmail.com>
Date: Sat, 5 Sep 2009 12:00:32 -0700 (PDT)
Local: Sat, Sep 5 2009 3:00 pm
Subject: Communicate with the Clipboard? And Keystrokes?
[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?

Thanks in advance. Looking forward to knowing this... It'd be great if
I could migrate my clipboard-enhancing scripts to JavaScript.

-Andy


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gus Mueller  
View profile  
 More options Sep 5 2009, 4:23 pm
From: Gus Mueller <g...@flyingmeat.com>
Date: Sat, 5 Sep 2009 13:23:49 -0700
Local: Sat, Sep 5 2009 4:23 pm
Subject: Re: Communicate with the Clipboard? And Keystrokes?
On Sep 5, 2009, at 12:00 PM, Andy L wrote:

> [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);

var keyDown = true;
var keyUp   = false;

// command down:
CGPostKeyboardEvent(0, 55, keyDown);

// v down, then up
CGPostKeyboardEvent(0, 9, keyDown);
CGPostKeyboardEvent(0, 9, keyUp);

// command up
CGPostKeyboardEvent(0, 55, keyUp);

CGEnableEventStateCombining(true);
CGInhibitLocalEvents(false);

Hope that helps,

-gus

--  

August 'Gus' Mueller
Flying Meat Inc.
http://flyingmeat.com/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andy L  
View profile  
 More options Sep 5 2009, 7:44 pm
From: Andy L <underwater...@gmail.com>
Date: Sat, 5 Sep 2009 16:44:49 -0700 (PDT)
Local: Sat, Sep 5 2009 7:44 pm
Subject: Re: Communicate with the Clipboard? And Keystrokes?
Hi Gus,

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:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gus Mueller  
View profile  
 More options Sep 6 2009, 2:55 pm
From: Gus Mueller <g...@flyingmeat.com>
Date: Sun, 6 Sep 2009 11:55:24 -0700
Local: Sun, Sep 6 2009 2:55 pm
Subject: Re: Communicate with the Clipboard? And Keystrokes?
On Sep 5, 2009, at 4:44 PM, Andy L 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?

thanks,

-gus

--  

August 'Gus' Mueller
Flying Meat Inc.
http://flyingmeat.com/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andy  
View profile  
 More options Sep 6 2009, 11:22 pm
From: Andy <underwater...@gmail.com>
Date: Mon, 7 Sep 2009 04:22:34 +0100
Local: Sun, Sep 6 2009 11:22 pm
Subject: Re: Communicate with the Clipboard? And Keystrokes?
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?

- Andy

On Sep 6, 2009, at 7:55PM, Gus Mueller wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gus Mueller  
View profile  
 More options Sep 6 2009, 11:54 pm
From: Gus Mueller <g...@flyingmeat.com>
Date: Sun, 6 Sep 2009 20:54:49 -0700
Local: Sun, Sep 6 2009 11:54 pm
Subject: Re: Communicate with the Clipboard? And Keystrokes?
On Sep 6, 2009, at 8:22 PM, Andy wrote:

> 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...?

-gus

--  

August 'Gus' Mueller
Flying Meat Inc.
http://flyingmeat.com/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andy  
View profile  
 More options Sep 7 2009, 12:03 am
From: Andy <underwater...@gmail.com>
Date: Mon, 7 Sep 2009 05:03:24 +0100
Local: Mon, Sep 7 2009 12:03 am
Subject: Re: Communicate with the Clipboard? And Keystrokes?
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.  ;)

Thanks.

-Andy

On Sep 7, 2009, at 4:54AM, Gus Mueller wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »