• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: GUI screen capture?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GUI screen capture?


  • Subject: Re: GUI screen capture?
  • From: kai <email@hidden>
  • Date: Wed, 29 Sep 2004 07:10:51 +0100


On Mon, 27 Sep 2004 15:01:13 -0400, Bill White wrote:

Any idea on why the following doesn't work?

tell application "Finder" to activate

tell application "System Events"

    tell process "Finder"

        keystroke "3" using {command down, shift down}

    end tell

end tell

It compiles and runs without error, but doesn't produce a screenshot. I must
be missing something very simple.

On Mon, 27 Sep 2004 18:25:17 -0400, Bill White wrote:

Thanks Paul and Steve. I know about "screencapture" but just wondered why
System Events' "keystroke" doesn't work for such a simple thing. Seems
counterintuitive to me.

I sympathise, Bill - although some context might be relevant here.

When using the keystroke command, we're essentially specifying a character, rather than a particular key. This works pretty much as expected for many characters:

--------------------------
keystroke "abcdefghijklmnopqrstuvwxyz`,;'[]\\" using shift down
--> "ABCDEFGHIJKLMNOPQRSTUVWXYZ~<:"{}|"
--------------------------

Passing a bunch of pre-shifted characters has (unsurprisingly) little effect:

--------------------------
keystroke "ABCDEFGHIJKLMNOPQRSTUVWXYZ~<:\"{}|" using shift down
--> "ABCDEFGHIJKLMNOPQRSTUVWXYZ~<:"{}|"
--------------------------

In addition, the use of a numeric keypad is evidently assumed for certain characters:

--------------------------
keystroke "0123456789.+-*/=()" using shift down
--> "0123456789.+-*/=()"
--------------------------

To work around this in your screen capture script, you could try something like:

--------------------------

tell application "System Events" to keystroke "#" using command down

--------------------------

This approach is keyboard-dependent and might need "£" on a British keyboard layout, for example. You should also find that the above one-line statement is sufficient without additional calls to the Finder.

---
kai
_______________________________________________
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


  • Follow-Ups:
    • Re: GUI screen capture?
      • From: Bill White <email@hidden>
  • Prev by Date: Re: Create record in FileMaker
  • Next by Date: size of rich text messages
  • Previous by thread: Re: GUI screen capture?
  • Next by thread: Re: GUI screen capture?
  • Index(es):
    • Date
    • Thread