Cannot set the value of a text field, which I can read

I am writing GUI scripts for a flashcard application called Anki. My goal is to change a field in a browser.
The current value is the field is 'foo. I want to set it to ‘bar’.


tell application "System Events"
	tell application process "Anki"
		tell window 1
			tell splitter group 1
				tell group 1
					tell table 1
						tell row 8
							tell static text 1
								tell group 1
									tell static text 1
										set v to value
										set value to "bar"
									end tell
								end tell
							end tell
						end tell
					end tell
				end tell
			end tell
		end tell
	end tell
end tell

The command ‘set v to value’ returns ‘foo’, suggesting that the object is properly referenced.
However the command ‘set value to “bar”’ does not do anything. The is no error message either, nothing happens.

To help me with GUI scripting, I use an application called ‘UI Browser’ by PFiddlesoft.
It does tell me that the value of ‘static text 1’ is a modifiable text string.
Of course, I can also edit the field by hand with no issues.

I tried to rewrite the script as one line (set value of … of … etc).
I also tried inserting around at various points ‘activate’, ‘click’ and ‘delay’. Nothing helped.

Any help to put me on the right direction would be greatly appreciated!

Thanks in advance. W.

Hi. I rarely do any GUI scripting, but have you tried using the “keystroke” command to simulate typing the string?

I had to do this recently with a non applescript program and once I determined the UI info
Using the UIBrowser program I was able to determine the UI item/Depth.
PS you can also compact your tree a bit as well.
here’s the code that I used for using the SoulSeek program:

  • setting the value of the text field (which is search field)
  • clicking the search button to start the search

set searchfor to the clipboard as string
			tell application "System Events"
				tell process "SoulseekQt"
					set frontmost to true
					try
						set value of text field 1 of pop up button 1 of group 1 of group 1 of window "SoulseekQt build 2017.2.25" to searchfor
						click button 1 of group 1 of group 1 of window "SoulseekQt build 2017.2.25"
						delay 1
					end try
				end tell
			end tell

tell application "System Events"
	tell process "Anki"
		try
			set value of static text 1 of group 1 of static text 1 of row 8 of table 1 of group 1 of splitter group 1 of window 1 to "bar"
		end try
	end tell
end tell