• 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 deactivate an app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to deactivate an app


  • Subject: Re: How to deactivate an app
  • From: "Gerriet M. Denkmann" <email@hidden>
  • Date: Thu, 02 Feb 2012 23:59:29 +0700

On 2 Feb 2012, at 00:51, Leo wrote:

> What happens if you send
>
> set frontmost of process yourApp to false
>
> then, using the name of your app? Will it reveal the previous app by a chance?

It seems that "process" has to be followed by a number.

I tried this in AppleScript Editor:

tell application "System Events"
	set proCount to count of processes
	repeat with x from (1) to (proCount)
		set appName to name of process x
		if appName = "AppleScript Editor" then
			set frontmost of process x to false
			exit repeat
		end if
	end repeat
end tell

and it had no effect and no error messages. Tried it inside my app - again, no effect.

> If not, then is there any way to capture the name of the app you need to activate at an earlier stage, so you can send it "set frontmost  to true" later?

I am getting the previous app by watching for the relevant Carbon events. But then there is no need to use Apple Script to activate it - activateWithOptions: is probably more efficient.

Kind regards,

Gerriet.

>
>
> On 2/1/12 1:44:49 AM, Gerriet M. Denkmann wrote:
>> On 1 Feb 2012, at 11:33, Leo wrote:
>>
>>> If I understand your goals correctly, you can send the following AppleScript script:
>>>
>>> tell application "System Events" to set frontmost of process yourApp to true
>> I tried the following in AppleScript Editor:
>>
>> set appList to "processes"
>> tell application "System Events"
>> 	set proCount to count of processes
>> 	set appList to appList&  "("&  proCount&  "):"
>> 	repeat with x from (1) to (proCount)
>> 		set appName to name of process x
>> 		set appList to appList&  appName&  ","
>> 	end repeat
>> end tell
>> log appList
>>
>>
>> But the resulting list of apps has only a very rough resemblance to the list displayed by Command-Tab.
>>
>> So the following:
>> NSString *source = @"tell application \"System Events\" to set frontmost of process 2 to true";
>> NSAppleScript *appleScript = [ [ NSAppleScript alloc ] initWithSource: source ];
>> NSDictionary *errorInfo;
>> NSAppleEventDescriptor *aed = [ appleScript executeAndReturnError:&errorInfo ];
>> [ appleScript release ];
>>
>> does work in that is activates some app, but process 2 is NOT the previous active app.
>>


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


References: 
 >Re: How to deactivate an app (From: Leo <email@hidden>)

  • Prev by Date: Re: PDFView focus ring
  • Next by Date: Re: Square NSWindow corners?
  • Previous by thread: Re: How to deactivate an app
  • Next by thread: Re: How to deactivate an app
  • Index(es):
    • Date
    • Thread