Input destination in maps

I put together some simple code to access the search bar in “Maps”, pre-installed app on mac osx
the problem is, I can’t use the paste command, because it’s not/ seems not working.

Here’s my code:


set the clipboard to "Oslo"
tell app "System Events"
tell app "Maps" to activate
tell group 2 of toolbar 1 of window 1 of process "Maps"
tell text field 1 

#Click
#Delay 0.2
#Keystroke "v" using command down

end
end
end

Does this work?

activate application "Maps"
tell application "System Events"
	tell process "Maps"
		tell group 2 of toolbar 1 of window 1
			set value of text field 1 to "Oslo"
		end tell
	end tell
	keystroke return
end tell

Ah…I got it ! Usually I keep Maps not running all times,

do shell script "open -a Maps"
delay 1

…helped, not run nor activate did the job to run Maps for me,
so obviously the rest of the script couldn’t work.
Thanks, I like clear ui scripting (no to shortcuts emulation)

Solved.

:lol: wow, I found another hook interfering:
Assistive devices
AppleScript applications listed in :
system preferences/security & privacy/privacy
Become invalid after you edit/save them again.
Your AppleScript applications will ask you over and over again for accessibility rights, every time you edit them, even if they are in the list of enabled applications for accessibility devices

This effect is very annoying, so, what’s your opinion ? Is there a way to correct this bug with some workaround, like rewriting a plist with administrative rights with a script dialog, instead to navigate all times manually to the settings and subsettings, ect…:o

Perfectly wrong.

Since several versions of the operating system, GUIScripting is not driven thru Assistive Devices but ONLY from Security & privacy.
If you run the script in the script editor, you need to “authorize” Script Editor only once to be able to do the job.
If you run the script as an application, you need to “authorize” this application once and only once to do the job.

It’s at least what I get on my machine for years.

Yvan KOENIG running Sierra 10.12.1 in French (VALLAURIS, France) mardi 29 novembre 2016 14:27:09

2 Months ago I used yet 10.7, now I’m on 10.10.
And yes, with regular applications you have to authorize your application only once.

AppleScript applications behave differently, every time you edit/save them, you have to validate your AppleScript application again, even if it is checked in the list of authorized applications in the privacy window. To validate them again, I’ve the tedious task to uncheck-check the checkmark button whenever my AppleScript application changes. Sometimes this bug comes up, because only some of my AppleScript applications need that authentication.

Else I wouldn’t have the need to write this lines. This is what happens at least on my machine. :confused:

He is right though

Applets gets an generated id. That means that in most cases it will reuse that same bundle id when it overwrites but not in all cases. In some occasions an new bundle is created and you need to reauthorize it.

Have you tested this in all possible ways?

I have ten application scripts which behave exactly as I wrote.
If I store them in the Applications folder I’m not allowed to edit them and must make change on a copy so of course the authorization given to the original doesn’t apply to the copy.
I quickly understood that and since I took care to store them in a folder different from the Applications folder.

At this time I store them in the Documents folder.
If I have spared time I will try to store them in Applications from user domain which I never use.

Yvan KOENIG running Sierra 10.12.1 in French (VALLAURIS, France) mardi 29 novembre 2016 16:29:38

Puzzling

The script triggering Maps behave as described by Joy but there is an other puzzling behavior.

If I change the name of the city to reach, the script correctly fill the field but the value is not reflected on the map and the app issue a beep.
To force it to do its job, I tried to clear the text field by clicking the [X] button on its right end before setting a new value but it doesn’t change the behavior.

Yvan KOENIG running Sierra 10.12.1 in French (VALLAURIS, France) mardi 29 novembre 2016 17:04:27