PDA

View Full Version : Objective C - Application Open?




tom3097
Dec 21, 2005, 10:40 AM
Is there a way for when an application launches it checks to see if certain applications are open.

If so change the properties of certain items on a window.

Objective C or Applescript, which ever can do it. Please note that i know only limited Applescript and hardly and Objective C.



robbieduncan
Dec 21, 2005, 10:48 AM
You could shell out to ps to get a list of running processes and check that?

tom3097
Dec 21, 2005, 10:58 AM
You could shell out to ps to get a list of running processes and check that?

Note sure how to do that, and does objective-c allow editing of an applications window. i.e. change some text.

HiRez
Dec 21, 2005, 11:34 AM
Note sure how to do that, and does objective-c allow editing of an applications window. i.e. change some text.Change what text? Are you talking about in your application or in some other running application? In the first case, certainly, if you're trying to change text in some other running application, no, or not easily anyway. At least not without that application's cooperation, or through AppleScript or something. Applications are generally not supposed to go poking around in other applications changing things without their knowledge. As for getting a process list you can look up "man ps" in the Terminal and the see Apple documentation for NSPipe and TSTask.

tom3097
Dec 21, 2005, 11:37 AM
Change what text? Are you talking about in your application or in some other running application? In the first case, certainly, if you're trying to change text in some other running application, no, or not easily anyway. At least not without that application's cooperation, or through AppleScript or something. Applications are generally not supposed to go poking around in other applications changing things without their knowledge. As for getting a process list you can look up "man ps" in the Terminal and the see Apple documentation for NSPipe and TSTask.

Thanks, and its changing text in my application not some other application.

HiRez
Dec 21, 2005, 11:41 AM
Thanks, and its changing text in my application not some other application.Some Cocoa UI controls, such as NSTextField, have a method -setStringValue: where you can pass them an NSString to change their value (the text). This can also be accomplished through Cocoa bindings. If you mean the window's title, either set it directly in IB or send the window a -setTitle: message with an NSString.

logicat2001
Dec 26, 2005, 10:50 AM
Look at NSWorkspace (http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ObjC_classic/Classes/NSWorkspace_index.html).