Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Automate data entry (web page with pop up buttons) in Applescript

Hi guys


Leopard 10.5.8, intel


My code is copying one Excel cell at a time and storing as a variable (always called typistSomething). Then it flips to a Safari window and enters all the variables quickly, one after the other. All is well, I am just having problems with changing pop up buttons! I've paired down my code to try to work on the problem area. In the following example, you have to imagine that I've just copied a media type (say, "Movie") to the clipboard, then the pop up button I get to needs to be changed to "Movie" from its default blank state. I don't think I can 'set' a pop up button like I'm trying to. Here goes:



set typistType to «class ktxt» of ((the clipboard as text) as record)


--enter type to Entry Form

activate application "Safari"

tell application "System Events"

tell process "Safari"

set pop up button "Please select the type of video file" of group 6 of UI element 1 of scroll area 1 of group 1 of UI element 1 of scroll area 1 of group 1 of window "Video Metadata" to keystroke typistType

end tell

end tell



You see, I might be getting mixed up with 'keystroke' instruction, and just 'setting' it. I have highlighted the name of the field in dark red just to separate it from my bad bits. I'm afraid I'm a real beginner with this. What do you think? I've looked at the pop up button in UI Browser, and if I hover over the selection I want then it tells me, amongst other things, menu item "Movie" (menu item 5).

Thank you

David

MacBook Pro, Mac OS X (10.5.8), Applescript, pop up button

Posted on May 29, 2012 4:51 PM

Reply
Question marked as Best reply

Posted on May 30, 2012 6:56 AM

Just in case it might help, here's an example of how you can change the value of the "View" pop up button in this page.


tell application "Safari" to activate

tell application "System Events"

tell process "Safari"

set thePopUpButton to pop up button 1 of group 34 of UI element 1 of scroll area 1 of group 1 of group 1 of group 3 of window 1

if value of thePopUpButton is not "Only notes" then

clickthePopUpButton

keystroke "Only notes" & return

end if

end tell

end tell

Message was edited by: Pierre L.

4 replies
Question marked as Best reply

May 30, 2012 6:56 AM in response to davidbread

Just in case it might help, here's an example of how you can change the value of the "View" pop up button in this page.


tell application "Safari" to activate

tell application "System Events"

tell process "Safari"

set thePopUpButton to pop up button 1 of group 34 of UI element 1 of scroll area 1 of group 1 of group 1 of group 3 of window 1

if value of thePopUpButton is not "Only notes" then

clickthePopUpButton

keystroke "Only notes" & return

end if

end tell

end tell

Message was edited by: Pierre L.

May 30, 2012 4:04 PM in response to Pierre L.

Pierre, thank you so much for your help - this works and I'm very enthusiastic.


There is one small problem, and that is delay. After click thePopUpButton, and before the keystroke that sets it, there is a delay of between 4 and 5 seconds. Really weird. What do you think this could be? I've tried changing simple stuff.... like I tried getting rid of the if, and changed the keystroke from a fixed value to a variable (based on clipboard) but it's always the same.


Again, thank you. Even with a delay, this means the script can be made bombproof, and therefore safe to leave going for long periods of time. Really good.

Thanks

David

May 30, 2012 5:49 PM in response to davidbread

All I can say is that there's no delay when I run the previous script on my MacBook Pro 2.66 GHz (mid-2010) under Mac OS X 10.7.4. I really don't know where that delay might come from.


By the way, “group 34” should now be replaced with “group 36” in the script. To find out the exact reference to the pop up button, just use the following statement:

return pop up buttons of groups of UI elements of scroll areas of groups of groups of groups of window 1


Message was edited by: Pierre L.

Automate data entry (web page with pop up buttons) in Applescript

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.