Mac Forums

Mac Forums (
-   OS X - Development and Darwin (
-   -   AppleScript for checking value (

Povilas 11-06-2013 04:23 AM

AppleScript for checking value
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?

Mark FX 11-06-2013 01:46 PM

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.


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
                                return false
                        end if
                end tell
                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

Povilas 11-09-2013 11:04 AM

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
return false
end if

how to do this?

Mark FX 11-10-2013 02:02 PM

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

All times are GMT -4. The time now is 04:45 AM.

Powered by vBulletin
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.