Hi there!
I use this code to check if an instance is already open but, everytime I click on the program I get a warning about the opened instance but every new instance doesn`t close and it remains opened.
How Can I do to close every new instance? :o
Many thanks!
`detects if a form is alread open, run it twice to see the effect
Declare findwindow as "FindWindowA" of "user32"
Classname as string
Windowname as string
result as integer
end declare
object myform as form
center
caption="myform"
end object
detect
myform.showmodal
sub detect
findwindow.classname="TForm1"
findwindow.windowname="myform"
findwindow.execute
if findwindow.result>0 then
showmessage "This window is already open"
end if
end sub
How to close a previous instance?
How to close a previous instance?
Something like this??
best regards
Declare findwindow as "FindWindowA" of "user32"
Classname as string
Windowname as string
result as integer
end declare
``=============added==============================
declare setfocus as "SetForegroundWindow" of user32
hwnd as integer
end declare
``================================================
object myform as form
center
caption="myform"
end object
detect
myform.showmodal
sub detect
findwindow.classname="TForm1"
findwindow.windowname="myform"
findwindow.execute
if findwindow.result>0 then
showmessage "This window is already open"
``==========added=============
setfocus.hwnd=findwindow.result
setfocus.execute
END
``============================
end if
end sub
best regards
Declare findwindow as "FindWindowA" of "user32"
Classname as string
Windowname as string
result as integer
end declare
``=============added==============================
declare setfocus as "SetForegroundWindow" of user32
hwnd as integer
end declare
``================================================
object myform as form
center
caption="myform"
end object
detect
myform.showmodal
sub detect
findwindow.classname="TForm1"
findwindow.windowname="myform"
findwindow.execute
if findwindow.result>0 then
showmessage "This window is already open"
``==========added=============
setfocus.hwnd=findwindow.result
setfocus.execute
END
``============================
end if
end sub
How to close a previous instance?
Wow... Perfect!!!
Tnx a lot!!! :D
Tnx a lot!!! :D
-
- Posts: 3
- Joined: Sat Aug 27, 2016 7:16 am
How to close a previous instance?
thank you !
-
- Posts: 1
- Joined: Fri Sep 03, 2021 8:01 am
Re: How to close a previous instance?
Turns out the problem was the SetWinDelay instruction. From the docs: Although a delay of -1 (no delay at all) is allowed, it is recommended.In my case i am calling my applicaton.exe multiple times.I want to check whether another instance is running or not.Could not close the previous instance of this script. Keep Waiting? Hey all, I'm getting this error, and googling it seems to be of no help.