• 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
Numbers and AppleScript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Numbers and AppleScript


  • Subject: Numbers and AppleScript
  • From: "koenig.yvan" <email@hidden>
  • Date: Thu, 04 Sep 2014 14:14:10 +0200

Hello everybody

To help an user, I wrote a script which replace several strings in cells of a table and apply a color to the replaced strings.
To do that I was forced to use a temporary text file (TextEdit one).
As some cells are embedding linefeed characters, I replaced them by the characterID 8629 ("↵") so that the script may paste the datas with colored strings in the table.
This works well.

I tried to use the Find - Replace dialog to replace back the  ("↵")  by linefeed.
I discovered that the Find Replace dialog doesn't accept the linefeed ( no more character ID 8232 or character ID 8233) in the replace field so the final replacement must be done by hand for each occurrence.
I'm bored because the feature is available in the good old Numbers v2.3.

As I had already wrote the skeleton of a handler using the Find - Replace dialog.

At first thought it seemed to be a simple task and I got :

my Rechercher_Remplacer("lapin", "crétin")
--=====

on Rechercher_Remplacer(avant, |après|)
local nom_du_dialog, X_bouton, Y_bouton
tell application "Numbers" to activate


tell application "System Events" to tell application process "Numbers"
keystroke "f" using {command down}
set nom_du_dialog to title of window 1
tell window nom_du_dialog
title of buttons
set value of first text field to avant
set value of second text field to |après|
delay 0.2
set {X_bouton, Y_bouton} to position of button -3
click at button -3


--click at {X_bouton + 5, Y_bouton + 5} # Issue the error :  Il est impossible de rendre {916, 806} en type list." number -1700 from {916, 806} to list
end tell


--keystroke "w" using {command down} -- Close the dialog


end tell -- System Events…
--do shell script "/usr/bin/cliclick c:" & (X_bouton + 5) & "," & (Y_bouton + 5)
--tell application "ASObjC Runner" to click button once at {X_bouton + 5, Y_bouton + 5}
return
end Rechercher_Remplacer

--=====


Alas, click at button -3 doesn't launch the Find Replace, it just highlight the first occurrence of the string to replace
Trying to trigger the button by its coordinates issue an error number -1700 as I already reported here.
I tried to trigger the button with cliclick but got the same behaviour.
Same result with the feature click button available in ASObjC Runner.

I’m really puzzled. How may I launch the Find - Replace process ?

At first look, there is no anomaly in the code itself. The event log is :

tell application "Numbers"
activate
end tell
tell application "System Events"
keystroke "f" using {command down}
get title of window 1 of application process "Numbers"
--> "Rechercher et remplacer"
set value of text field 1 of window "Rechercher et remplacer" of application process "Numbers" to "lapin"
set value of text field 2 of window "Rechercher et remplacer" of application process "Numbers" to "crétin"
get title of button -3 of window "Rechercher et remplacer" of application process "Numbers"
--> "Tout remplacer"
get position of button -3 of window "Rechercher et remplacer" of application process "Numbers"
--> {1329, 1043}
click window "Rechercher et remplacer" of application process "Numbers" at button -3 of window "Rechercher et remplacer" of application process "Numbers"
--> missing value
end tell
tell application "ASObjC Runner"
click button once at {1334, 1048}
end tell


Yvan KOENIG (VALLAURIS, France) jeudi 4 septembre 2014 14:13:20







 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Numbers and AppleScript
      • From: "koenig.yvan" <email@hidden>
  • Prev by Date: Re: Adobe Photoshop Bounds of a layer?
  • Next by Date: Re: Adobe Photoshop Bounds of a layer?
  • Previous by thread: Re: excel rows
  • Next by thread: Re: Numbers and AppleScript
  • Index(es):
    • Date
    • Thread