Saturday, July 22, 2017

#1 2016-12-14 06:17:41 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 3111

Keystroke and 10.12.2

Hello

Since the delivery of 10.12.2, the script used to insert my signature plays the fool.
After every character defined as uppercase ones, one or several other characters defined as lowercase are inserted as uppercase.
Is it an already reported behavior ?
The active part of the script is :

Applescript:

set leMessage to "Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France)"


tell application "System Events" to tell process theApp
   set frontmost to true
   keystroke return & leMessage & return
end tell

where theApp is the process active when the script is executed.
If the target process is Safari, the result is :

YVan KOENIG RUNNiNg SIErra 10.12.2 iN FRENch (VALLAURIS. FRance)

If the target process is Firefox, the result is:

YVAN KOENIG running SIErra 10.12.2 in FrENch (VALLAURIS. FRAnce)

If the target process is TextEdit, the result is even worse:

YVAN KOENIG RuNNiNg SIERra 10.12.2 In FRENCh 5VALLAURIS. FRANce)

As you may see, the problem strikes also upon the opening paren which, on french keyboard is the lowercase counterpart of the character 5   [ ⇧)  --> 5 ]

I was able to retrieve a correct behavior using :

Applescript:

set leMessage to "Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France)"

set leMessage to return & leMessage & return
set messageChars to text items of leMessage
tell application "System Events" to tell process theApp
   set frontmost to true
   repeat with aChar in messageChars
       keystroke aChar
       delay 0.002 # I don't understand why it was missing, probably pasted from a wrong file
   end repeat
end tell

It seems that the keystroke tool type the characters too fast so that the uppercase mode remains active when the wanted lowercase chars are sent.
The signature displayed below was inserted with the edited code.

Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) mercredi 14 décembre 2016 12:17:30

Last edited by Yvan Koenig (2016-12-16 05:44:54 am)

Offline

 

#2 2016-12-15 10:24:40 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 3111

Re: Keystroke and 10.12.2

Problem confirmed by a friend running also 10.12.2.
It strike also in 10.12.13.

Reported as :
Report # 29683268, Under 10.12.2 (and 10.12.3) AppleScript keystroke command fails

Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) jeudi 15 décembre 2016 16:24:33

Offline

 

#3 2016-12-15 09:41:41 pm

nickorr
Member
Registered: 2010-03-05
Posts: 1

Re: Keystroke and 10.12.2

Yvan,

I've had the same issue with 10.12.2 and keystroke.  Putting the code in a loop didn't work for me, I had to also add a delay in between keystrokes for it to function properly.

Cheers,
Nick

Offline

 

#4 2016-12-16 05:43:27 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 3111

Re: Keystroke and 10.12.2

You're right nickorr.
I posted the wrong code.
The correct one sent to Apple contains a delay 0.002 instruction.
I will edit the original message.

Would be fine if many users send a report to Apple so that they take care of the problem.
When I filed my report I had only tested on the system used in French.
At last, I decided to boot in English and saw that the problem strike also in this configuration so I completed my report accordingly.

Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) vendredi 16 décembre 2016 11:43:20

Last edited by Yvan Koenig (2016-12-16 05:48:14 am)

Offline

 

#5 2017-01-04 02:30:55 pm

slashdot
Member
Registered: 2003-11-13
Posts: 287

Re: Keystroke and 10.12.2

just my 2 cents on this experience.

what i tested.
WORKED
- created a new account with a new username.  ran the script.

DID NOT WORK
- thought it was localized to my account
---- removed entire library folder > restarted
---- deleted my account created a new account with the same username
---- reinstalled OS worked for a second then still the issue


Haven't tried
- wipe and resintall > with same user account

Last edited by slashdot (2017-01-04 02:32:11 pm)

Offline

 

#6 2017-01-04 02:58:30 pm

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 3111

Re: Keystroke and 10.12.2

On my side I also have the problem on the external HD where I made a clean install of 10.12 before installing 10.12.3.
As my tests upon beta versions are related to localisation oddities, I doubt that something clobbered my user account on this disk.

Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) mercredi 4 janvier 2017 20:58:25

Offline

 

#7 2017-01-04 05:40:32 pm

slashdot
Member
Registered: 2003-11-13
Posts: 287

Re: Keystroke and 10.12.2

So it looks like it's definitely the OS 10.12 iteration of the os that results in these issues.  So won't clean and reinstall.  The odd thing.  it didn't work under "accountA" but it did in "accountB" and it didn't work in "accountA1" adding the "1" in "accountA" still didn't work.  Very strange but definitely a fix needed from apple's side.

so i guess wipe and clean isn't going to fix it.


Yvan Koenig wrote:

On my side I also have the problem on the external HD where I made a clean install of 10.12 before installing 10.12.3.
As my tests upon beta versions are related to localisation oddities, I doubt that something clobbered my user account on this disk.

Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) mercredi 4 janvier 2017 20:58:25

Last edited by slashdot (2017-01-04 05:40:47 pm)

Offline

 

#8 2017-01-05 05:39:02 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 3111

Re: Keystroke and 10.12.2

You may file a bug report.
I sent one as you may read in message #2

Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) jeudi 5 janvier 2017 11:38:40

Offline

 

#9 2017-01-05 12:29:59 pm

slashdot
Member
Registered: 2003-11-13
Posts: 287

Re: Keystroke and 10.12.2

Also, sent a bug report.  Made it into a sub-routine for those who need to use it repeatedly

Applescript:


set leMessage to "Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France)"
set AppName to "Terminal" -- change to app process

my charKeystroke(leMessage, AppName)

on charKeystroke(leMessage, AppName)
   set leMessage to return & leMessage & return
   set messageChars to text items of leMessage
   tell application "System Events" to tell process AppName
       activate
       set frontmost to true
       repeat with aChar in messageChars
           keystroke aChar
           delay 0.002 # I don't understand why it was missing, probably pasted from a wrong file
       end repeat
   end tell
end charKeystroke

Last edited by slashdot (2017-01-05 02:48:01 pm)

Offline

 

#10 2017-01-05 04:12:38 pm

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 3111

Re: Keystroke and 10.12.2

I would use a slightly enhanced version.

Applescript:

set leMessage to "Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France)"

tell application id "com.apple.TextEdit"
   activate
   --set AppName to its name
   if not (exists window 1) then make new document
   repeat until exists window 1
       delay 0.2
   end repeat
end tell

my charKeystroke(leMessage)

on charKeystroke(leMessage)
   set leMessage to return & leMessage & return
   set messageChars to text items of leMessage
   
   tell application "System Events"
       set frontmostProcess to first process where it is frontmost -- this will be the script process
       if name of frontmostProcess is in {"Script Editor", "AppleScript Editor", "Script Debugger"} then
           set visible of frontmostProcess to false -- hide the script process
           repeat while (frontmostProcess is frontmost) -- wait until the script is hidden
               delay 0.1
           end repeat
           set theProcess to name of first process where it is frontmost -- get name of frontmost process (ignoring the script process)
           set frontmost of frontmostProcess to true -- unhide the script process
       else
           set theProcess to name of frontmostProcess
       end if
       tell process theProcess
           set frontmost to true
           repeat with aChar in messageChars
               keystroke aChar
               delay 0.002
           end repeat
       end tell
   end tell
end charKeystroke

This way I may run it from the Editor.

Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) jeudi 5 janvier 2017 22:12:30

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)