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 

Force Shutdown a program

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






PostPosted: Sun Nov 04, 2007 1:24 pm    Post subject: Force Shutdown a program Reply with quote

Dear all,
I'm a newbie in AHK, so please help me how to close a program without any asking for example when a word document is running, how to close the document but not display a dialog (ask to save document or not).
Please help me.Thanks
Back to top
charmander91



Joined: 27 Oct 2007
Posts: 37
Location: olney, maryland

PostPosted: Sun Nov 04, 2007 10:18 pm    Post subject: Reply with quote

ooh i actually have this, i did it to close somoenes document when they press a, but i made it so that when u exit and it says, "changes have been made, would you like to save?" it tabs to "No" and presses enter. here's what i have, maybe u can make an if/then statement to make it see if word is open, but im too lazy to try it out.

Code:

~a::
   sleep, 5000
   Send, {ALTDOWN}{F4}{ALTUP}{TAB}{ENTER}
;  or
;  Send, !{f4}{tab}{enter}
   Return

_________________
ehh... ill draw a pic of a charmander later
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Guest






PostPosted: Mon Nov 05, 2007 4:02 am    Post subject: Reply with quote

charmander91 wrote:
ooh i actually have this, i did it to close somoenes document when they press a, but i made it so that when u exit and it says, "changes have been made, would you like to save?" it tabs to "No" and presses enter. here's what i have, maybe u can make an if/then statement to make it see if word is open, but im too lazy to try it out.

Code:

~a::
   sleep, 5000
   Send, {ALTDOWN}{F4}{ALTUP}{TAB}{ENTER}
;  or
;  Send, !{f4}{tab}{enter}
   Return

Thank you so much, but it is not what i mean, I want to close immediately a window without displaying dialog for asking.
Thanks
Back to top
Lexikos



Joined: 17 Oct 2006
Posts: 2739
Location: Australia, Qld

PostPosted: Mon Nov 05, 2007 4:07 am    Post subject: Reply with quote

Process, Close
Back to top
View user's profile Send private message
Guest






PostPosted: Mon Nov 05, 2007 10:51 am    Post subject: Reply with quote

lexikos wrote:
Process, Close

But it still display dialog ask to save the changes or not. So it is not what I expected.
Thanks,
Back to top
kidmar



Joined: 04 Oct 2007
Posts: 30

PostPosted: Mon Nov 05, 2007 11:14 am    Post subject: Reply with quote

Did you try the windows' Kill.exe?
Back to top
View user's profile Send private message
kidmar



Joined: 04 Oct 2007
Posts: 30

PostPosted: Mon Nov 05, 2007 1:18 pm    Post subject: Reply with quote

try WinKill command too
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2739
Location: Australia, Qld

PostPosted: Mon Nov 05, 2007 9:19 pm    Post subject: Reply with quote

Anonymous wrote:
lexikos wrote:
Process, Close

But it still display dialog ask to save the changes or not. So it is not what I expected.
Thanks,
Strange, since Notepad doesn't. I guess you'll have to automate closing the dialog.
Back to top
View user's profile Send private message
charmander91



Joined: 27 Oct 2007
Posts: 37
Location: olney, maryland

PostPosted: Mon Nov 05, 2007 11:40 pm    Post subject: Reply with quote

hmm... try this then

Code:

~a::
   Send, {ALTDOWN}{F4}{ALTUP}{TAB}{ENTER}
;  or
;  Send, !{f4}{tab}{enter}
   Return


this will only work with microsoft word though. you may need to do something where it recognizes the title.
_________________
ehh... ill draw a pic of a charmander later
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Guest






PostPosted: Wed Nov 07, 2007 4:01 am    Post subject: Reply with quote

kidmar wrote:
try WinKill command too

I opened a Notepad document, written somethings (no save) then tried this ahk code:

[/code]

IfWinExist, Untitled - Notepad
WinKill ; use the window found above
else
WinKill, Calculator
[code]

But the dialog displayed, beside I don't want to use followed code to do:

~a::
sleep, 5000
Send, {ALTDOWN}{F4}{ALTUP}{TAB}{ENTER}
; or
; Send, !{f4}{tab}{enter}
Return

I want to close immediately document (or process), Notepad program for instance from the operation system, bypass the controling of sofware (Notepad program).
Thanks,
Back to top
Lexikos



Joined: 17 Oct 2006
Posts: 2739
Location: Australia, Qld

PostPosted: Wed Nov 07, 2007 5:07 am    Post subject: Reply with quote

If Process, Close doesn't work, try this:
Code:
Run, taskkill /F /PID %pid%,, Hide
...where pid contains the Process ID. Alternately, identify by process name:
Code:
Run, taskkill /F /IM winword.exe

XP Pro, 2003 and Vista have taskkill; I'm not sure about other versions.

If you don't have taskkill, search for PsKill.
Back to top
View user's profile Send private message
Guest






PostPosted: Wed Nov 07, 2007 5:55 am    Post subject: Reply with quote

lexikos wrote:
If Process, Close doesn't work, try this:
Code:
Run, taskkill /F /PID %pid%,, Hide
...where pid contains the Process ID. Alternately, identify by process name:
Code:
Run, taskkill /F /IM winword.exe

XP Pro, 2003 and Vista have taskkill; I'm not sure about other versions.

If you don't have taskkill, search for PsKill.

yeahhhhhhhhhh, that is what i expected, thank you very much, especially Lexikos and Kidmar, thousands of kisses to you.
Back to top
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