Standalone with launch command

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
xanant
Posts: 25
Joined: Sun Nov 09, 2014 5:38 pm

Standalone with launch command

Post by xanant » Sun Dec 27, 2015 12:55 pm

My standalone consists of a "main stack" (splash) that opens a "substack" (effective standalone) that launches (at the preOpenStack) an application that must ever remain open, and NOT minimized, in the background. The command "launch" does work correctly and opens the application "SMTP Server". My question is: how auto bringing to the fore my standalone? I'll explain. The command launch at the preOpenStack is the following:

on preOpenStack
   -- connect to DB
    DataBaseConnect
   -- launches the mail host SMTPServer
    launch "C:\Program Files\Free SMTP Server\localsrv.exe"
end preOpenStack

The "SMTPServer" opens correctly but remains in front of my standalone. How can I place it back automatically :D without having to use a manual :cry: "mouse click" on the standalone to bring it to the front?
Can someone help me? Thanks a lot.

Martin Koob
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 256
Joined: Sun May 27, 2007 8:19 pm

Re: Standalone with launch command

Post by Martin Koob » Sun Dec 27, 2015 3:33 pm

Hi

I am not sure if you can do this in Windows but If you are using a Mac you can use Applescript to do this.

I have an app that starts copying a file in the Finder and I wanted the Finder to come to the foreground so the user will see the copy progress dialog while the copying is happening then when copying is finished I wanted to have my standalone come back to the foreground.

I am using the glx_app_getProp() function from the GLX application framework to get the name of my application to use in the Applescripts (http://www.bluemangolearning.com/liveco ... framework/)
I don't know how to get the application name without using GLX. I guess you could hardcode it.

This is the code to create and run the applescript to find the process ID of my application for use in the later Applescript, then bring the finder to the foreground to see the copy progress dialog, then start the copying of the file.

Code: Select all

      if the environment is "development" then
         put "LiveCode-Commercial" into tAppName
      else if the environment is "standalone application" then
         put glxapp_getProp("application name") into tAppName
      end if
     # get the process ID of this app
      put "tell application" && quote & "System Events" & quote & CR & \
            "return (id of first process whose name is" && quote & tAppName & quote & ")" & CR &\
      "end tell" into tScript
      do tScript as applescript
      put the result into tMyProcessID
      # Switch to Finder to see copy progress
      do "tell application " & quote & "Finder" & quote & CR & "activate" & CR & "end tell" as applescript
      revCopyFolder tSourceFolder, tDestinationFolder
Then later in my script I have more code to create Applescript code and execute it that switches back to my application when the copy is done.

Code: Select all

   
   # Switch back to this application using processID when copying is finished
   put "tell application" && quote & "System Events" & quote & CR & \
         "tell process id" && tMyProcessID & CR & \
         "set the frontmost of it to true" & CR &\
   "end tell" & CR &\
   "end tell" into tScript
   do tScript as applescript
Not sure how to do the equivalent thing in Windows but if there is a similar scripting architecture perhaps that could be a way to handle that.

Hope that helps.

Martin

xanant
Posts: 25
Joined: Sun Nov 09, 2014 5:38 pm

Re: Standalone with launch command

Post by xanant » Sun Dec 27, 2015 8:01 pm

Hi Martin
unfortunately I have to work on Windows but I do not know if there is a kind of AppleScript for this OS.
The second "script" of your procedure is just what I need (.. set the frontmost of it to true). My intention was to use only LiveCode architecture, something such as "set the systemWindow of this stack to true", but it is not working. It would seem a simple thing, but instead is not.
Thank you anyway for your suggestion that I'll consider whether possible use with Windows..
Greetings
Sandro

xanant
Posts: 25
Joined: Sun Nov 09, 2014 5:38 pm

Re: Standalone with launch command

Post by xanant » Sun Jan 17, 2016 10:14 pm

Hi
someone else can help me? :(
thanks

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Standalone with launch command

Post by Klaus » Mon Jan 18, 2016 3:31 pm

Hi xanant,

the Windows equivalent to Mac OS Applescript is VBScript!
Do a websearch for: vbscript bring application to front
and check the 99300 results :D

Sorry, no idea how to do it, I'm a Mac guy.
But you can also:
...
do fld "vbscript" as vbscript
...
in Livecode!


Best

Klaus

xanant
Posts: 25
Joined: Sun Nov 09, 2014 5:38 pm

Re: Standalone with launch command

Post by xanant » Mon Jan 18, 2016 11:28 pm

Hi Klaus
thanks for your reply.
I'm also a "Mac guy" (little), but this time I have to work in windows, of which I have very little knowledge. I thought the question was simpler in Livecode. Does that mean I will review the proposed 99300 ... :?
Ciao
Xanant

Martin Koob
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 256
Joined: Sun May 27, 2007 8:19 pm

Re: Standalone with launch command

Post by Martin Koob » Tue Jan 19, 2016 12:29 am

I am a totally Mac guy but if LiveCode can run scripts in vbScript with "do ------- as vbScript" then you should be able to do it. I looked up bring window to front and found this following which is probably what you need.


https://msdn.microsoft.com/en-us/librar ... s.84).aspx

Martin

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Standalone with launch command

Post by Klaus » Tue Jan 19, 2016 11:40 am

Hi xanant,
[quote="xanant"Does that mean I will review the proposed 99300 ...[/quote]
well, better you than us, buddy! :D

Oh, Martin did it for you, lazybone! 8)

Best

Klaus

xanant
Posts: 25
Joined: Sun Nov 09, 2014 5:38 pm

Re: Standalone with launch command

Post by xanant » Thu Jan 21, 2016 2:13 pm

Hi
thank you guys for the tips that made me discover new and interesting things, but above all to have solved my problem.
It would be nice, in a future LiveCode version, a command revTalk to make it easier.
P.S. I'm sorry for Klaus, but I'm happy to avoid view the 99300 results :wink:

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”