Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 392 Vote(s) - 3.52 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to exit program using autohotkey?

#1
I am using autohotkey to do some automate process.

I need help with closing chrome.exe

**I tried**



Process, Close, chrome.exe
; or
Run taskkill /im chrome.exe

but it give me chrome crashed error when I start it again.

Thanks

Reply

#2
Use `WinClose` to send a close message to the window, rather than killing the process:

SetTitleMatchMode 2
WinClose Google Chrome
Reply

#3
[mihai's helpful answer](

[To see links please register here]

) works well if a _single_ Chrome window (typically containing multiple _tabs_) is open.

However, **more work is needed if you want to close _all_ open Chrome windows**:

; Get all hWnds (window IDs) created by chrome.exe processes.
WinGet hWnds, List, ahk_exe chrome.exe

; Loop over all hWnds and close them.
Loop, %hWnds%
{
hWnd := % hWnds%A_Index% ; get next hWnd
WinClose, ahk_id %hWnd%
}

Also note that the [`WinClose` documentation](

[To see links please register here]

) calls using `WinClose`'s use of the `WM_CLOSE` message "somewhat forceful" and suggests the following `PostMessage` alternative, which mimics the user action of pressing <kbd>Alt-F4</kbd> or using the Window menu's `Close` item:

; Get all hWnds (window IDs) created by chrome.exe processes.
WinGet hWnds, List, ahk_exe chrome.exe

; Loop over all hWnds and close them.
Loop, %hWnds%
{
hWnd := % hWnds%A_Index% ; get next hWnd
PostMessage, 0x112, 0xF060,,, ahk_id %hWnd%
}

Reply

#4
Here is a function for 'soft closing' specific processes:

CloseAllInstances( exename )
{
WinGet LhWnd, List, % "ahk_exe " exename
Loop, %LhWnd%
PostMessage, 0x112, 0xF060,,, % "ahk_id " LhWnd%A_Index%
}

So you simply need to call the following line to close all chrome instances:

CloseAllInstances( "chrome.exe" )
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through