AppleScript for checking value

Joined
Nov 6, 2013
Messages
2
Reaction score
0
Points
1
Hi, I'am new with scripting and don't have lots of experience. Need script for checking two words. Don't have idea how to do this. One text should be in textedit for example text 'Hi' and script should check is this text is "Hi". How to take text for checking from external application is the main question?
 
Joined
Aug 13, 2011
Messages
200
Reaction score
7
Points
18
Location
West Sussex
I dont fully understand your question, but I think your asking how to find a specific word in the frontmost active TextEdit document, if this is correct, then the simple Applescript below shows a very basic way to do this.

Code:
tell application "System Events"
	set openApps to name of every application process whose visible is equal to true
	if openApps contains "TextEdit" then
		tell application "TextEdit"
			set the wordList to every word of document 1
			if the wordList contains "Hi" then
				return true
			else
				return false
			end if
		end tell
	else
		display alert "The TextEdit application is not running." giving up after 30
	end if
end tell

If this is not what your after, then you had better rephrase your question, and be more clear about what your trying to achieve.

Regards Mark
 
OP
P
Joined
Nov 6, 2013
Messages
2
Reaction score
0
Points
1
thank you for reply it's helpful

I have additional question. Is there possibility to find text field using AXValue and then set it for use this example.
For instance there is text field with identifier "size.popup" in untitled window. I need to do:

set the worldList to "size.popup" (instead of "set the wordList to every word of document 1")

if the wordList contains "2" then
return true
else
return false
end if

how to do this?
 
Joined
Aug 13, 2011
Messages
200
Reaction score
7
Points
18
Location
West Sussex
Sorry I don't understand your question.

AXValue ?

what text fielld are you reffering to ?

Are you working in Xcode, with a custom textfield on a window in Interface Builder ?

You'll have to explain what your working with, in order for us to be able to help you.

Regards Mark
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top