Am 06.06.2012 11:18, schrieb Bruce:
> I have been mucking around with this for about a year now and haven't
> found a solution.
>
> We have a few gambas applications that are treated as pop-ups by the
> users.  That is, they click on some type of launcher (be it a desktop
> item, a menu item or in our case a wbar icon) and the application
> starts.
> Then they minimize it, or go to another desktop, or any other way to
> hide the application window.
> Then they relaunch it...
>
> ... and get another instance running.
>
> However, sort of like things like Evolution, we only want to have one
> copy of these applications running.  So we need some sort of "mutex"
> checker that ensures that they can only run one instance of the
> application.
>
> So far, I have found that I can use gb.desktop to detect another
> instance via the window title and just exit gracefully with a "Another
> instance of xxxxxxxxxxx is running" message.
>
> Blah!
>
> That doesn't really do what I want.  What I want (what I really, really
> want) is a way to activate the window found and then exit.
>
> Any clues?
>
> regards
> Bruce

Hi Bruce,

I have successfully used this code which is from Jussi Lahtinen. I built 
it into two of my applications, and it works reliably, at least under 
Gambas2 on our somewhat older system:

PUBLIC SUB Form_Open()
DIM sOutput AS String

   EXEC ["pgrep", "-f", "-l", "-u", System.User.Name, "Stein3.gambas"] 
WAIT TO sOutput

   IF Split(Trim$(sOutput), gb.NewLine).Count > 1 THEN
     QUIT
   ENDIF

Just replace "Stein3" by your binary's name.

Regards

Rolf

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to