Getting a value from a dropdown

In looking at a Windows XP SUT, I have some dropdowns from which I want to grab the selected value.

I’ve looked at the code in the contentsOfField sample here but that seems to be oriented towards text based data, rather than a dropdown, and consequently it’s not working for me.

Any clues, please?

Gary:

To identify the chosen value from a pop-up you need to look for the selected image.

One way to accomplish this is with an image collection. You can pass a folder name into a “ImageFound” function and see which one it finds with FoundImageName().

Example:
Months is a folder with an image for each month of the year.


If ImageFound("Months") then
  put FoundImageName()
end if

If your pop-ups are all Text then you can use the Text Image Generator to dynamically make a list of items.



if ImageFound (listOfTextImages(("256 Colors", "Thousands", "Millions"), "Default")) then
	put foundImageName()
else
	logError "Couldn't Identify Text"
end if

-- This function takes two parameters a list of strings and a text style
-- It Returns a list of Text Image definitions for use in image commands
function listOfTextImages list, theTextStyle
	repeat for each item of list
		insert (text: it, TextStyle: theTextStyle) into returnList
	end repeat
	return returnList
end function


[quote=“JonathanOSX”]Gary:

To identify the chosen value from a pop-up you need to look for the selected image.

One way to accomplish this is with an image collection. You can pass a folder name into a “ImageFound” function and see which one it finds with FoundImageName().

Example:
Months is a folder with an image for each month of the year.


If ImageFound("Months") then
  put FoundImageName()
end if

[/quote]

Jonathan,

I’m trying this solution, but what I am seeing is that FoundImageName() is returning the name of the containing folder, rather than the name if the image (file) that has been located.

Any further thoughts on this please?

Right. The foundImageName() function returns the name of the collection, with the idea that a collection represents a particular element on the screen and you want to know which element is present, not which exact representation of that element is showing.

For situations where you want to know the exact image that was found, the foundImageInfo() function can be used instead. It returns a property list that includes an imagePath property with the full path of the image file, so instead of foundImageName() you could do this:

put foundImageInfo().ImagePath.lastPathComponent

or, to eliminate the file extension, you can use the short name of the file itself:

put short name of file foundImageInfo().ImagePath