[SOLVED]Bringing Separate Livecode apps on Top via launcher

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: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

[SOLVED]Bringing Separate Livecode apps on Top via launcher

Postby Lagi Pittas » Fri Jul 14, 2017 5:08 pm

Hi

I have a program that can use different data , graphics, etc nad I want 1 version to run in 3 different configurations.

So I have copied the whole directory 3 times renamed the application differently and setup the config and data files graphics etc to be different for each directory.

I created a little launcher program with 3 buttons that have a button like

Code: Select all
on mouseUp
    launch "C:\Users\xxxx\Documents\multi\nameXXX\progxxx.exe"
end mouseUp


Fine and dandy - it worked first time - I should hope so!!

I already had a on relaunch handler in the main stack that just beeped to stopp people running multiple copies of the original.

My problem is if I set systemwindow to true on relaunch you would expect the window to come to the top but it doesn't. The first time each application is run it does show at the top but pressing the launcher with

set the systemwindow of me to true


has no effect.

I can think of a "simple" way but I woulkd like to do it the obvious way.

The simple way is putting "the launcheR button in the app - but that means a lot of real estate movement.

Here is how I used to do it in Foxpro - if anybody can show me how to "wrap" this with infinite livecode on windows with a C interface i then have a good reason to make a move to version 8 - at least for the launcher which will be three times the size of the main app - go figure.

LOCAL lcWinName, lnHWnd

lcWinName = "Your window title name"
DECLARE INTEGER BringWindowToTop IN WIN32API LONG HWND

DECLARE INTEGER ShowWindow IN WIN32API LONG HWND, LONG nCmdShow

DECLARE INTEGER FindWindow IN WIN32API STRING, STRING

lnHWnd = FindWindow(0, m.lcWinName)
IF m.lnHWnd <> 0
ShowWindow(m.lnHWnd, SW_RESTORE)
BringWindowToTop(m.lnHWnd)
ENDIF


edit

to further explain - we could call these routine like this

BringWindowToTop(tnHWND)
ShowWindow(m.lnHWND, 3)

and there were other calls we could "bind" like

DECLARE INTEGER GetForegroundWindow IN user32 - so you could see which window was in the foreground . - simples.

Any help/ideas/cake welcome.

KIndest Regards Lagi
Last edited by Lagi Pittas on Fri Jul 21, 2017 5:29 pm, edited 1 time in total.
Lagi Pittas
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
 
Posts: 230
Joined: Mon Jun 10, 2013 1:32 pm

Re: Bringing Separate Livecode apps on Top via launcher

Postby Klaus » Fri Jul 14, 2017 6:02 pm

Hi Lagin,

I found that sometimes "... of me" does not work reliably when ME is referring to a stack, try with:
Code: Select all
set the systemwindow of stack "name of the stack here" to TRUE

And since LC and "do XYZ as VBSCRIPT" on Windows, I am sure there are lots of VB code snippets around on the internet
that will bring an EXE to front.


Best

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

Re: Bringing Separate Livecode apps on Top via launcher

Postby bogs » Fri Jul 14, 2017 8:54 pm

Klaus wrote:<sic>...
I found that sometimes "... of me" does not work reliably when ME is referring to a stack, try with:
Code: Select all
set the systemwindow of stack "name of the stack here" to TRUE


Curious, does "this stack" work more reliably than "of me"? Or is it always better to use the "stack "name of the stack" ?
Code: Select all
set the systemWindow of this stack to true
or
Code: Select all
set the system window of stack "mySuperStack" to true
I would suspect the 2nd (referring by specific name) is the better solution, right?
Image
bogs
 
Posts: 384
Joined: Sat Feb 25, 2017 10:45 pm

Re: Bringing Separate Livecode apps on Top via launcher

Postby FourthWorld » Fri Jul 14, 2017 9:33 pm

I've found that on some OSes it's necessary to set the style of the stack to palette in addition to setting the systemWindow to true, if you want it above other apps' windows.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
 
Posts: 5305
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles

Re: Bringing Separate Livecode apps on Top via launcher

Postby Lagi Pittas » Fri Jul 14, 2017 9:43 pm

I Tried that - No Cigar.

I thought this is what widgets were invented for - I wanted tio stay clear of any other Exes be they VB or delphi.

I will see how slow a shellexecute with a small delphi program will be instead of getting all messy with VB.

Regards Lagi

p.s. still wish Ali ir Mark would come to the rescue with a short course in calling from LCB. :D
Lagi Pittas
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
 
Posts: 230
Joined: Mon Jun 10, 2013 1:32 pm

Re: Bringing Separate Livecode apps on Top via launcher

Postby FourthWorld » Fri Jul 14, 2017 10:51 pm

You might consider filing a bug report on this.

Though FWIW I just tested on my Win10 box and systemWindow seems to be working well with the latest v9 build.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
 
Posts: 5305
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles

Re: Bringing Separate Livecode apps on Top via launcher

Postby Lagi Pittas » Mon Jul 17, 2017 10:32 am

Hi Richard

I'm going to install 9 and see what happens

Thanks again

Lagi
Lagi Pittas
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
 
Posts: 230
Joined: Mon Jun 10, 2013 1:32 pm

[SOLVED] Re: Bringing Separate Livecode apps on Top via laun

Postby Lagi Pittas » Fri Jul 21, 2017 5:24 pm

Hi

problem solved in 2 ways.

Ok was to lazy to write it in another language so I built the "launcher" into the program with buttons that had dynamic labels and paths, and dynamically changed the database files - took all of 15 minute, no third party, job done.

But Then I ran the old launcher program noticed that the called program stack was ALWAYS above all other programs including editors, IDE everything. So ..... donning my Deerstalker

I wonder if I

Code: Select all
set the the systemwindow of  stack "stackname" to TRUE


on program 1 maybe the second program I run can't take the top position? I originally assumed that the last program executed/launched with systemwindowset to true would percolate to the top - It doesn't.

So I added 6 lines to the program code.

At the end of the openstack I added

Code: Select all
set the systemwindow of  stack "stackname" to TRUE
   wait 250
   set the systemwindow of  stack "stackname" to false


And I added exactly the same to the end of the relaunch command (which only has a beep in it if they try to run more than 1 instance of the same program). This code probably isn't needed but it works and so ill see next time i'm in the program.

The thing works exactly as I envisaged it (at least on windows)

Basically I'm setting the stack to be on top waiting a quarter of a second - (could be much less but who cares) and then setting the system window to false so that any other program running after it can get top spot.

At least now I know what I can do if I want to take over the desktop - hope no lawyers are lurking ;-)

Kindest Regards Lagi
Lagi Pittas
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
 
Posts: 230
Joined: Mon Jun 10, 2013 1:32 pm

Re: [SOLVED]Bringing Separate Livecode apps on Top via launc

Postby sphere » Thu Sep 14, 2017 6:32 pm

Hi,

i've tested the last code of Lagi and it works.
But it also seems to have a side effect, like the window is refreshing. A real fast backdrop and back again.
sphere
 
Posts: 407
Joined: Sat Sep 27, 2014 10:32 am
Location: Hummelo, the Netherlands


Return to Getting Started with LiveCode - Experienced Developers

Who is online

Users browsing this forum: Bing [Bot] and 5 guests