Detecting that a Winbatch executable is already running?

Started by pguild, June 07, 2019, 05:17:52 PM

Previous topic - Next topic

pguild

My goal is to let the user minimize an application that uses a dialog box. I've got that covered with IntControl (49, 1, 0, 0, 0) ; allow minimize dialog box

When the user hits a hot key, the application will try to start.  Currently I am manually making this happen with Windows shortcut and setting the Windows shortcut key.  But even that is not working consistently. Sometimes it does and sometimes not.
.
If the application is already running, I don't want a second copy to be loaded.

When the application starts I want it to check to see if it is already running and if so, to do a Winshow of the running version and then exit.

I am trying to use Winexist, Wintitle, and winGetActive, and WinIdGet  to make this happen -- to no avail. I had this working many years ago, but I think Windows 10 is making this a challenge.

Any ideas?

www.DogTrainingPsychology.com -- "Don't wish it were easier, wish you were better."  as aphorism by Jim Rohn as quoted in the Kindle Book, GEMS OF WISDOM by Philip Seyer

td

Have no idea what you have tried but this standard example works just fine on Windows 10.

Code (winbatch) Select
WinHide('') ; Hide WinBatch box (not absolutley necessary.)

strTitle = 'Single Instance Example'

;  Prevent a second instance of the dialog.
if WinExist(strTitle)
   ;;WinShow(strTitle)
   WinActivate(strTitle)
   exit
endif

SininstFormat=`WWWDLGED,6.2`

SininstCaption=strTitle
SininstX=3183
SininstY=164
SininstWidth=227
SininstHeight=220
SininstNumControls=002
SininstProcedure=`DEFAULT`
SininstFont=`DEFAULT`
SininstTextColor=`DEFAULT`
SininstBackground=`DEFAULT,DEFAULT`
SininstConfig=0
SininstDPI=`192,10,20`

Sininst001=`026,172,050,016,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,10,@csDefButton,DEFAULT,DEFAULT,DEFAULT`
Sininst002=`138,172,050,016,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

IntControl (49, 1, 0, 0, 0)
ButtonPushed=Dialog("Sininst")
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

pguild

www.DogTrainingPsychology.com -- "Don't wish it were easier, wish you were better."  as aphorism by Jim Rohn as quoted in the Kindle Book, GEMS OF WISDOM by Philip Seyer