New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Ľ Advice and insight from world-class Apple enthusiasts Ľ Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

AppleScript for checking value


Post Reply New Thread Subscribe

 
Thread Tools
Povilas

 
Member Since: Nov 06, 2013
Posts: 2
Povilas is on a distinguished road

Povilas is offline
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?
QUOTE Thanks
Mark FX

 
Mark FX's Avatar
 
Member Since: Aug 13, 2011
Location: West Sussex, UK
Posts: 168
Mark FX has a spectacular aura about

Mark FX is offline
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
QUOTE Thanks
Povilas

 
Member Since: Nov 06, 2013
Posts: 2
Povilas is on a distinguished road

Povilas is offline
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?
QUOTE Thanks
Mark FX

 
Mark FX's Avatar
 
Member Since: Aug 13, 2011
Location: West Sussex, UK
Posts: 168
Mark FX has a spectacular aura about

Mark FX is offline
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
QUOTE Thanks

Post Reply New Thread Subscribe


« creating a text file | Java Programming ? »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Storing Applescript in text files JonathonK OS X - Operating System 0 12-28-2012 04:40 PM
Finder won't start laurag OS X - Operating System 5 04-13-2012 05:46 PM
Applescript help with serial port access ljimber OS X - Development and Darwin 0 06-24-2011 11:46 AM
help needed to link up buttons on HUD Window to Applescript nick_harambee OS X - Development and Darwin 0 09-30-2010 08:26 AM
[ANN] New comprehensive AppleScript book hanaan OS X - Development and Darwin 0 11-06-2004 07:28 PM

All times are GMT -4. The time now is 04:14 PM.

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

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?