Bring Window to Front

  • Hi all,

    I am very new to Cocoa, Objective-C, and Macs in general but I am
    hoping to eventually drop all Windows programming in favour of Apple
    (I am a Windows develop by trade).

    I am working on my first real Cocoa app and I have a query:

    How do I force a window to restore from the dock?  I have done some
    research and found the function to restore a window with the genie
    effect, but the problem is that the window I want to restore belongs
    to another program.  I want to find the appropriate window for this
    program and force it to the front in a restored state.  The program
    is Paralells desktop (though I am sure that makes no difference).

    Does anyone know how I might do this?  In Windows I can use
    FindWindow with a classname to get the handle of the foreign window
    and use that.  It appears that Carbon has a findWindow and a
    FindWindowOfClass, but I am not sure if they are what I need.

    thanks,
    Jamie Frater
  • Hi Jamie, good to know we're getting new developers :)

    Probably your two best bets are:

    * The Accessibility Framework
    * Applescript

    I don't know a huge amount about the former, but for the latter,
    assuming Parallels has a basic AppleScript dictionary, you jut need
    to use NSAppleScript to run a script like:

    tell app "Parallels"
    set miniaturized of window "aWindow" to false
    activate
    end

    There are probably also some CoreGraphics or such-like functions that
    I'm not aware of available :)

    Mike.

    On 1 Oct 2006, at 15:57, Jamie Frater wrote:

    > Hi all,
    >
    > I am very new to Cocoa, Objective-C, and Macs in general but I am
    > hoping to eventually drop all Windows programming in favour of
    > Apple (I am a Windows develop by trade).
    >
    > I am working on my first real Cocoa app and I have a query:
    >
    > How do I force a window to restore from the dock?  I have done some
    > research and found the function to restore a window with the genie
    > effect, but the problem is that the window I want to restore
    > belongs to another program.  I want to find the appropriate window
    > for this program and force it to the front in a restored state.
    > The program is Paralells desktop (though I am sure that makes no
    > difference).
    >
    > Does anyone know how I might do this?  In Windows I can use
    > FindWindow with a classname to get the handle of the foreign window
    > and use that.  It appears that Carbon has a findWindow and a
    > FindWindowOfClass, but I am not sure if they are what I need.
    >
    > thanks,
    > Jamie Frater
    > _______________________________________________
    > Do not post admin requests to the list. They will be ignored.
    > Cocoa-dev mailing list      (<Cocoa-dev...>)
    > Help/Unsubscribe/Update your Subscription:
    > http://lists.apple.com/mailman/options/cocoa-dev/mike.abdullah%
    > 40gmail.com
    >
    > This email sent to <mike.abdullah...>
  • On the Mac, you don't have access to the windows and other controls of
    separate processes. All that information is kept in a separate process
    space. Also, since there are multiple, disparate frameworks on the Mac
    (Carbon and Cocoa), even if you had access to the pointer, you'd need to
    know if it was an NSWindow or a Carbon WindowRef.

    Your best options are the Accessibility API, or potentially AppleScript
    if the target app supports it.

    Good luck!

    Jamie Frater wrote:
    > Hi all,
    >
    > I am very new to Cocoa, Objective-C, and Macs in general but I am
    > hoping to eventually drop all Windows programming in favour of Apple
    > (I am a Windows develop by trade).
    >
    > I am working on my first real Cocoa app and I have a query:
    >
    > How do I force a window to restore from the dock?  I have done some
    > research and found the function to restore a window with the genie
    > effect, but the problem is that the window I want to restore belongs
    > to another program.  I want to find the appropriate window for this
    > program and force it to the front in a restored state.  The program is
    > Paralells desktop (though I am sure that makes no difference).
    >
    > Does anyone know how I might do this?  In Windows I can use FindWindow
    > with a classname to get the handle of the foreign window and use
    > that.  It appears that Carbon has a findWindow and a
    > FindWindowOfClass, but I am not sure if they are what I need.
    >
    > thanks,
    > Jamie Frater
    > _______________________________________________
    > Do not post admin requests to the list. They will be ignored.
    > Cocoa-dev mailing list      (<Cocoa-dev...>)
    > Help/Unsubscribe/Update your Subscription:
    > http://lists.apple.com/mailman/options/cocoa-dev/<jstiles...>
    >
    > This email sent to <jstiles...>
  • Hiya,

    Thanks to you and to Mike who both suggested Applescript or the
    Accessibility API.  I have contacted the authors of parallels to see
    if either options are possible.

    The application I am writing allows users to put an xml file (plist)
    into a shared network directory which my app reads and outputs any
    one or all of the following:

    1) growl notification (clickable and can launch any specified app -
    with or without password protection for security over the network)
    2) sound notification (can play any sound on the Mac)
    3) read text with any specified voice and any specified text

    I already have the app working with directory change notifications
    (using KQueue), and all of the above options.  The main reason for
    writing it was so that I could monitor notifications coming from some
    Windows apps I run for work on my parallels desktop and my Windows
    laptop in another room.  Through some other small Windows apps I have
    written it is also notifying me of Windows shutdowns and logins.

    Do you think that many people would consider this to be a useful app
    - making it worth selling on the net, or do you think I should keep
    it for a personal app and think of other ideas for commercial apps in
    the future?  I am hoping to eventually replace all of my Windows
    development with Apple dev so I can drop Windows entirely.

    At the moment I haven't come up with any ideas as amazing as things
    like Delicious Library that are good enough to provide me with a
    living - but I am hoping I eventually will.

    Again, thanks for the help,
    Jamie

    On 1 Oct 2006, at 19:21, John Stiles wrote:

    > On the Mac, you don't have access to the windows and other controls
    > of separate processes. All that information is kept in a separate
    > process space. Also, since there are multiple, disparate frameworks
    > on the Mac (Carbon and Cocoa), even if you had access to the
    > pointer, you'd need to know if it was an NSWindow or a Carbon
    > WindowRef.
    >
    > Your best options are the Accessibility API, or potentially
    > AppleScript if the target app supports it.
    >
    > Good luck!
    >
    >
    > Jamie Frater wrote:
    >> Hi all,
    >>
    >> I am very new to Cocoa, Objective-C, and Macs in general but I am
    >> hoping to eventually drop all Windows programming in favour of
    >> Apple (I am a Windows develop by trade).
    >>
    >> I am working on my first real Cocoa app and I have a query:
    >>
    >> How do I force a window to restore from the dock?  I have done
    >> some research and found the function to restore a window with the
    >> genie effect, but the problem is that the window I want to restore
    >> belongs to another program.  I want to find the appropriate window
    >> for this program and force it to the front in a restored state.
    >> The program is Paralells desktop (though I am sure that makes no
    >> difference).
    >>
    >> Does anyone know how I might do this?  In Windows I can use
    >> FindWindow with a classname to get the handle of the foreign
    >> window and use that.  It appears that Carbon has a findWindow and
    >> a FindWindowOfClass, but I am not sure if they are what I need.
    >>
    >> thanks,
    >> Jamie Frater
    >> _______________________________________________
    >> Do not post admin requests to the list. They will be ignored.
    >> Cocoa-dev mailing list      (<Cocoa-dev...>)
    >> Help/Unsubscribe/Update your Subscription:
    >> http://lists.apple.com/mailman/options/cocoa-dev/jstiles%
    >> 40blizzard.com
    >>
    >> This email sent to <jstiles...>
  • On 1 Oct 2006, at 23:29, Jamie Frater wrote:

    > Hiya,
    >
    > Thanks to you and to Mike who both suggested Applescript or the
    > Accessibility API.  I have contacted the authors of parallels to
    > see if either options are possible.

    er, you shouldn't have to write to them.  Just use Script Editor to
    see if Parallels has a basic AppleScript dictionary.

    And with the Accessibility API, the whole point of it being, you
    know, Accessibility, is that it should work with all apps and windows.

    (apologies if that comes across a little grumpily, it's really not
    meant to be!)

    Mike.
    >
    > The application I am writing allows users to put an xml file
    > (plist) into a shared network directory which my app reads and
    > outputs any one or all of the following:
    >
    > 1) growl notification (clickable and can launch any specified app -
    > with or without password protection for security over the network)
    > 2) sound notification (can play any sound on the Mac)
    > 3) read text with any specified voice and any specified text
    >
    > I already have the app working with directory change notifications
    > (using KQueue), and all of the above options.  The main reason for
    > writing it was so that I could monitor notifications coming from
    > some Windows apps I run for work on my parallels desktop and my
    > Windows laptop in another room.  Through some other small Windows
    > apps I have written it is also notifying me of Windows shutdowns
    > and logins.
    >
    > Do you think that many people would consider this to be a useful
    > app - making it worth selling on the net, or do you think I should
    > keep it for a personal app and think of other ideas for commercial
    > apps in the future?  I am hoping to eventually replace all of my
    > Windows development with Apple dev so I can drop Windows entirely.
    >
    > At the moment I haven't come up with any ideas as amazing as things
    > like Delicious Library that are good enough to provide me with a
    > living - but I am hoping I eventually will.
    >
    > Again, thanks for the help,
    > Jamie
    >
    > On 1 Oct 2006, at 19:21, John Stiles wrote:
    >
    >> On the Mac, you don't have access to the windows and other
    >> controls of separate processes. All that information is kept in a
    >> separate process space. Also, since there are multiple, disparate
    >> frameworks on the Mac (Carbon and Cocoa), even if you had access
    >> to the pointer, you'd need to know if it was an NSWindow or a
    >> Carbon WindowRef.
    >>
    >> Your best options are the Accessibility API, or potentially
    >> AppleScript if the target app supports it.
    >>
    >> Good luck!
    >>
    >>
    >> Jamie Frater wrote:
    >>> Hi all,
    >>>
    >>> I am very new to Cocoa, Objective-C, and Macs in general but I am
    >>> hoping to eventually drop all Windows programming in favour of
    >>> Apple (I am a Windows develop by trade).
    >>>
    >>> I am working on my first real Cocoa app and I have a query:
    >>>
    >>> How do I force a window to restore from the dock?  I have done
    >>> some research and found the function to restore a window with the
    >>> genie effect, but the problem is that the window I want to
    >>> restore belongs to another program.  I want to find the
    >>> appropriate window for this program and force it to the front in
    >>> a restored state.  The program is Paralells desktop (though I am
    >>> sure that makes no difference).
    >>>
    >>> Does anyone know how I might do this?  In Windows I can use
    >>> FindWindow with a classname to get the handle of the foreign
    >>> window and use that.  It appears that Carbon has a findWindow and
    >>> a FindWindowOfClass, but I am not sure if they are what I need.
    >>>
    >>> thanks,
    >>> Jamie Frater
    >>> _______________________________________________
    >>> Do not post admin requests to the list. They will be ignored.
    >>> Cocoa-dev mailing list      (<Cocoa-dev...>)
    >>> Help/Unsubscribe/Update your Subscription:
    >>> http://lists.apple.com/mailman/options/cocoa-dev/jstiles%
    >>> 40blizzard.com
    >>>
    >>> This email sent to <jstiles...>
    >
    > _______________________________________________
    > Do not post admin requests to the list. They will be ignored.
    > Cocoa-dev mailing list      (<Cocoa-dev...>)
    > Help/Unsubscribe/Update your Subscription:
    > http://lists.apple.com/mailman/options/cocoa-dev/mike.abdullah%
    > 40gmail.com
    >
    > This email sent to <mike.abdullah...>
previous month october 2006 next month
MTWTFSS
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Go to today