Re: keystroke (ASCII character 28) using shift down
Re: keystroke (ASCII character 28) using shift down
- Subject: Re: keystroke (ASCII character 28) using shift down
- From: Bill Cheeseman <email@hidden>
- Date: Sun, 12 Sep 2004 13:21:29 -0400
If I comment out the lines after what you call the problem line, it works
fine for me here. I open your script in Script Editor, place the insertion
point anywhere in the Script Editor editing window, then run the script
within Script Editor, and it selects the character to the left of the
insertion point.
It hangs on the next line, if I uncomment it, because the Cut menu item is
in Script Editor's Edit menu, not its File menu. When I change the script to
use the Edit menu, it cuts the selected character. I didn't try the
subsequent steps, but they will presumably work with the same correction.
You will have trouble, however, if you intend to use some other text editor
as the frontmost application. You won't be able to run the script from
Script Editor, because Script Editor would have to become the frontmost
application so that you could hit the Run button. For the same reason, you
won't be able to run it as an applet by double-clicking it in the Finder,
because when you double-click it in the Finder, the Finder will become the
frontmost application. You can probably solve both problems by defining the
text editor process as item 2, not item 1, of active processes -- after
taking appropriate steps to ensure the text editor starts out as the
frontmost application.
You could probably also solve this problem by using item 1 of processes and
running your script from a script menu.
I'm curious to know what you're trying to accomplish. The approach you're
taking seems a little awkward. It might work better to try the 'set' command
on the value of the targeted text view of the window.
on 2004-09-12 9:38 AM, Mark Butcher at email@hidden wrote:
> I'm having trouble getting System Events to invoke a keystroke,
> specifically the 'shift-left arrow' to select the previous character to
> the insertion point. Here is the problem line:
>
> keystroke (ASCII character 28) using shift down -- left arrow key
>
> Here is the script:
>
> tell application "Finder"
> set frontprocess to name of processes whose frontmost is true
> set frontprocess to item 1 of frontprocess
> end tell
>
> tell application "System Events"
> tell process frontprocess
> keystroke (ASCII character 28) using shift down -- left arrow key
> --key code 123 using shift down -- left arrow key
> click menu item "Cut" of menu "File" of menu bar item "File" of menu
> bar 1
> keystroke (ASCII character 29) using shift down -- right arrow key
> click menu item "Paste" of menu "File" of menu bar item "File" of
> menu bar 1
> end tell
> end tell
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
The AppleScript Sourcebook - http://www.AppleScriptSourcebook.com
Vermont Recipes - http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden