• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to pause another application or even thread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to pause another application or even thread


  • Subject: Re: How to pause another application or even thread
  • From: Fei Li <email@hidden>
  • Date: Mon, 7 Jul 2003 13:38:39 -0600

Thanks for responding, and it works very well.

But I still have another question. How can I pause a not scriptable application. What Apple event should I send.

Thanks a lot!
Fei

On Friday, July 4, 2003, at 11:00 AM, Thomas Finley wrote:

On Friday, July 4, 2003, at 12:16 PM, Fei Li wrote:
Hello all,
If there's any possible to pause another application(process) or even
specific thread in that application?

Processes? Sure. See the man pages kill(2) with the signals SIGSTOP and SIGCONT. However, you're not really trying to pause and unpause a process, so let's move on.

What I want to do is when QuickTime Player is playing something, I want to
pause and continue the playing from my application. This is also useful if
we want to control other application, but I don't know how to do it.

That's quite a different question entirely. The common and preferred method to control another application is not by randomly interfering with its threads and runtime state, but rather (at least in OS X) to send Apple events.

There are many ways to do this, but one of the easier way is to just write an applescript within your cocoa app and execute it. Something along the lines of:

NSDictionary *errorDictionary;
NSString *scriptString =
@"tell application \"QuickTime Player\"\n"
@" stop the first movie of movies of the first window of windows\n"
@"end tell\n";
NSAppleScript *stopScript =
[[[NSAppleScript alloc] initWithSource:scriptString] autorelease];
if (![stopScript executeAndReturnError:&errorDictionary]) {
NSLog(@"Error in executing stop movie script! %@", errorDictionary);
}

(This is "fast enough", but you probably want to keep the script around in your object and not create a new one every time if this is something you do often.)
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: How to pause another application or even thread (From: Thomas Finley <email@hidden>)

  • Prev by Date: NSMutableArray subclass (alternatives?)
  • Next by Date: Re: NSMutableArray subclass (alternatives?)
  • Previous by thread: Re: How to pause another application or even thread
  • Next by thread: Objective C++, C++, and templates
  • Index(es):
    • Date
    • Thread