• 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: System Event & TextEdit & Mac Os 10.2
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: System Event & TextEdit & Mac Os 10.2


  • Subject: Re: System Event & TextEdit & Mac Os 10.2
  • From: kai <email@hidden>
  • Date: Sat, 18 Sep 2004 19:39:10 +0100


On Fri, 17 Sep 2004 11:37:09 -0300, Bernardo Hoehl <email@hidden> wrote:


I have this script that I am using do build a Demo of my Applications,
it simulates typing.

It works fine on Os 10.3.5, but in OS 10.2,  I get an error that the
pressKey event is not understood.

[snip]

Code:

tell application "TextEdit"
	activate
end tell

my typeText("Eu posso interagir com seus aplicativos, como estou
fazendo no TextEdit agora," & return & "por exemplo: digitando texto
lentamente," & return & "ou mesmo...Digitar texto" & return)
on typeText(texto)
	set the_item to 1
	repeat with i from 1 to the count of texto
		set theChar to character the_item of texto
		tell application "System Events"
			keystroke theChar
		end tell
		set the_item to the_item + 1
		delay 0.2
	end repeat
end typeText

In addition to Paul's explanation about the differences between Jaguar and Panther in this context, you might also like to note that the Standard Additions 'delay' command in Jaguar requires an integer. If you do pass a real number to it, you probably won't be rewarded with an error - but the value is evidently rounded to an integer. So the difference between the entered and the actual delay would be:


entered --> actual
    0.0 --> 0.0
    0.1 --> 0.0
    0.2 --> 0.0
    0.3 --> 0.0
    0.4 --> 0.0
    0.5 --> 0.0
    0.6 --> 1.0
    0.7 --> 1.0
    0.8 --> 1.0
    0.9 --> 1.0
    1.0 --> 1.0

While on the subject, I hope you won't mind my observing that the repeat loop in your 'typeText' handler seems to contain a little more information than it really requires. By that I mean the two variables, 'the_item' and 'i', both appear to act as loop counters - although only the 'the_item' is actually used. You might therefore like to try simplifying the handler by saying something like:

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

on typeText(texto)
repeat with the_item from 1 to count texto
tell application "System Events" to keystroke character the_item of texto
delay 0.2
end repeat
end typeText


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

...or, without explicitly counting:

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

on typeText(texto)
	tell application "System Events" to repeat with theChar in texto
		keystroke theChar
		delay 0.2
	end repeat
end typeText

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

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


  • Prev by Date: Re: Producing Barcodes
  • Next by Date: Re: Count lines in a textfile
  • Previous by thread: Re: System Event & TextEdit & Mac Os 10.2
  • Next by thread: Re: [ANN] XMail 2.0.1 beta
  • Index(es):
    • Date
    • Thread