Re: How close one program from another.

new topic     » goto parent     » topic index » view thread      » older message » newer message
DonCole said...

Hello my fellow Euphorians,

My next stupid question is,

How can I close one program from another?

Let's say I'm running an Euphoria program and Notepad.

Or an Euphoria program and another Euphoria program that I have compiled to an .exe file.

How can I close the second program from the first?

Don Cole

Hi, this is 'one' solution to the problem.. There are different ways to do that.

include tinewg.exw 
include std/math.e 
 
sequence WindowText="Editor" -- German version of Windows 
-- sequence WindowText="Notepad" -- Maybe this one for a English version 
 
Window("Close Test") 
 
constant b1=Control(Button,"Start Notepad",160,50,80,30) 
constant b2=Control(Button,"End Notepad",160,80,80,30) 
 
procedure run() 
	RunApp("Notepad.exe","") 
end procedure 
SetHandler(b1,Click,routine_id("run")) 
 
procedure endapp() 
atom handle=0 
sequence handles 
	handles=EnumWindows() 
	for i=1 to length(handles)  do 
		if and_bits ( GetWindowLong (handles[i],GWL_STYLE), or_all ({WS_VISIBLE,not_bits(WS_POPUP)})) then 
			if match(WindowText,GetText(handles[i])) then 
				handle=handles[i] 
				exit  
			end if 
		end if 
	end for  
	if handle then 
		if AskMsg("Really Close :"&GetText(handle),"Close App") then 
			SendMessage(handle,WM_CLOSE,0,0) 
		end if 
	else 
		InfoMsg("Not found","Close App")	 
	end if 
end procedure 
SetHandler(b2,Click,routine_id("endapp")) 
 
WinMain() 
 

Also it is written using tinewg, it should be easy to convert it to any other wrapper.
Andreas

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu