Is there a way to actually exit program, instead of killing the process?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
mrmundo
Posts: 5
Joined: 20 May 2016, 02:48

Is there a way to actually exit program, instead of killing the process?

20 May 2016, 03:01

What I mean is, is there a way to simulate clicking the X on the window, instead of killing the process? (Not literally of course)

For example if I click exit magnifier while it's zoomed in, it zooms out smoothly and exits, if I kill the process with this

Code: Select all

Process, Close, Magnify.exe
this kills the magnifier and instantly zooms out without animation.

Why I need this is, I have bound magnifier to a hotkey on mouse button for when I'm away from the monitor. I click it, it launches magnifier at 200%, I click it again, it kills magnifier returning to normal zoom.

Why this is a problem: I noticed that If I kill the magnifier instead of exiting, every time there's an UAC popup, it launches the magnifier and it's very annoying, but if I exited the magnifier properly this doesn't happen.
User avatar
Masonjar13
Posts: 1555
Joined: 20 Jul 2014, 10:16
Location: Не Россия
Contact:

Re: Is there a way to actually exit program, instead of killing the process?

20 May 2016, 03:20

Code: Select all

winClose,ahk_exe Magnify.exe
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
User avatar
Nextron
Posts: 1391
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: Is there a way to actually exit program, instead of killing the process?

20 May 2016, 04:17

If it's magnifier specific, you can use Send #{Esc} to close it.

I've done something similar:
XButton2+MButton (hold X2) = Zoom until release
XButton2+MButton = Toggle zoom
XButton2+Scroll = Adjust zoom level

Code: Select all

XButton2 & MButton::
	KeyWait, MButton
	If !WinExist("ahk_class MagUIClass ahk_exe Magnify.exe"){ 
		Send, #=
		KeyWait, XButton2, T1
		If !(ErrorLevel)
			Return
		WinMinimize,ahk_class MagUIClass ahk_exe Magnify.exe
		KeyWait, XButton2
	}
	Send, #{Esc}
Return
#IfWinExist ahk_class MagUIClass ahk_exe Magnify.exe 
XButton2 & WheelUp::Send, #=
XButton2 & WheelDown::Send, #-
#If
mrmundo
Posts: 5
Joined: 20 May 2016, 02:48

Re: Is there a way to actually exit program, instead of killing the process?

20 May 2016, 07:56

Masonjar13 wrote:

Code: Select all

winClose,ahk_exe Magnify.exe
This is exactly what I wanted, don't know how I didn't find it. Thank you very much.

Nextron, looks interesting, may try it, thanks.
CHMike
Posts: 8
Joined: 16 Nov 2014, 16:44

Re: Is there a way to actually exit program, instead of killing the process?

21 May 2016, 22:42

If WinClose cannot work. What I have done is to use DOS command "TaskKill". So you should use "Run Taskkill" or "RunWait Taskkill".
User avatar
Masonjar13
Posts: 1555
Joined: 20 Jul 2014, 10:16
Location: Не Россия
Contact:

Re: Is there a way to actually exit program, instead of killing the process?

21 May 2016, 23:48

CHMike wrote:If WinClose cannot work. What I have done is to use DOS command "TaskKill". So you should use "Run Taskkill" or "RunWait Taskkill".
This produces the identical result as his original solution.
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], ReyAHK, Rohwedder and 259 guests