Re: Moving an application to the foreground



Arnaud Nicolet wrote:
Jonathan Hoyle wrote:

I have a REALbasic 5.5.5 application which kicks off a support
application using the Launch() method from the FolderItem class.  The
problem is, I want my REAlbasic application to remain in the
foreground, yet after I launch the support app, the support app moves
to the forefront.  (This is true even when I pass "false" into the
Launch() method.)

I thought that perhaps a work-around would be to somehow force the main
application back into the foreground subsequent to the support app's
launching.  Unfortuntaely, i do not see a way to do this in REALbasic.
Is there perhaps an AppleTalk command that would do this for me?  How
would I execute it in REAlbasic?


My answer is for Mac:
The simplest way would be to make it as an AppleScript:
OSX script:
On run {AppName,MyAppName} --AppName is the name of your application which must remain in the background, while MyAppName is the name of your application (since I do not know if "tell current application" works in an RB-AppleScript environment)


tell application "System Events"
repeat
set p to every process whose name contains "Finder"
if (count items of p) > 0 then exit repeat
end repeat
end tell
--Now, we know that the app AppName has been launched
tell application "QuickTime Player" to activate
End Run
For OS9, replace the "System Events" application by the "Finder" (since it's the "Finder" which handled processes for Mac OS9; for MacOS X, the "Finder" also handles process, but it's in the Legacy suite).


If you don't want to rely on AppleScript, use declares (or the MBS plugin) to do the equivalent.

Oops, sorry. The script I posted was the one I used to test. Here's the right one:


On run {AppName,MyAppName} --AppName is the name of your application
which must remain in the background, while MyAppName is the name of your
application (since I do not know if "tell current application" works in
an RB-AppleScript environment)

tell application "System Events"
    repeat
        set p to every process whose name contains AppName
        if (count items of p) > 0 then exit repeat
    end repeat
end tell
--Now, we know that the app AppName has been launched
tell application MyAppName to activate
End Run

I apologize.
.



Relevant Pages

  • Re: Moving an application to the foreground
    ... The problem is, I want my REAlbasic application to remain in the foreground, yet after I launch the support app, the support app moves to the forefront. ... if > 0 then exit repeat ...
    (comp.lang.basic.realbasic)
  • Re: Dynamic Object Reference
    ... is there another MVP or MS member that can? ... >> the name of the form to instatiate and launch. ... Otherwise I need to repeat the ...
    (microsoft.public.dotnet.framework.windowsforms)
  • RE: Paint Seems Corrupted - Often Wont Open & Interferes with Shutdow
    ... have to completely repeat all the steps that I was intending to use paint ... MSPaint will then function normally. ... or more times in a computing session, Shutdown will hang immediately after ... shutdown problem only occurs after the MSPaint launch failure occurs. ...
    (microsoft.public.windowsxp.general)
  • Re: Dynamic Object Reference
    ... > the name of the form to instatiate and launch. ... You definitely don't need to repeat the code, and you should (IMO) use ... a dictionary from sender to the type of form you want to create, ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: "Conventional ICBMs"
    ... alarms previously, is irrelevant. ... The Norway incident was consistent with an SLBM launch profile, ... ANY, and I repeat, ANY situation that invites a repeat of a situation circa ...
    (rec.aviation.military)