AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Closing applications

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Fri Jan 28, 2005 4:58 pm    Post subject: Closing applications Reply with quote

I want to close some applications (I have started) at the end of the script.
Currently I do it using "Process Close ..." but this is a hard kill. Would be nice to close it softly (application should be able to ask for saving files etc.)
like it is done by WinClose if used with the main window (similar to Delphis' Application.Terminate ).

example:
run, helper1.exe ,,, PID1
run, helper2.exe ,,, PID2
runwait, mainapp.exe
process, close, PID2
process, close, PID1

Leo.
Back to top
leonix



Joined: 28 Jan 2005
Posts: 2

PostPosted: Fri Jan 28, 2005 5:00 pm    Post subject: Reply with quote

uups I forgot to login. It was me that posted that question

Leo.
Back to top
View user's profile Send private message
BoBo
Guest





PostPosted: Fri Jan 28, 2005 5:28 pm    Post subject: Reply with quote

Quote:
WinClose
--------------------------------------------------------------------------------
Closes a window.

WinClose [, WinTitle, WinText, SecondsToWait, ExcludeTitle, ExcludeText]

This command sends a close message to a window. The result depends on the window (it may ask to save data, etc.)

It (tries to) close every window. If the window is named "Program Manager" (which is the Desktop) then it would offer to shutdown the system.
It's bad step-brother:

Quote:
WinKill
--------------------------------------------------------------------------------
Forces a window to close.

WinKill [, WinTitle, WinText, SecondsToWait, ExcludeTitle, ExcludeText]


OK. Let's go back to RTFM Wink
Back to top
Guest






PostPosted: Fri Jan 28, 2005 6:39 pm    Post subject: Reply with quote

Bobo,

this was not my question. I want to do
WinClose PID
I do not have the WinTitle of my application;
it can be that it is all the same WinTitle or WinText
with the PID it would be selectively exactely the window I want.

You understand!?

Leo. Smile
Back to top
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Fri Jan 28, 2005 6:56 pm    Post subject: Reply with quote

Thanks for clarifying.

If there is only one instance of the target application in existence, I recommend using "WinClose ahk_class ClassName" (as shown by Window Spy).

If there is more than one instance, you can discover the windows that belong to a particular PID with the following:
http://www.autohotkey.com/forum/viewtopic.php?t=1367
Back to top
View user's profile Send private message Send e-mail
Rajat



Joined: 28 Mar 2004
Posts: 1717

PostPosted: Fri Jan 28, 2005 6:59 pm    Post subject: Reply with quote

if u know the PID then use a loop to get the PIDs of all (matching) windows and when its found, get its ahk_id and use winclose.
_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group