win icon indicating copy to clipboard operation
win copied to clipboard

How to kill HWND ?

Open wilon opened this issue 6 years ago • 2 comments

hwnd := win.FindWindow(nil, syscall.StringToUTF16Ptr("someApp"))
// I want to kill hwnd, how?

wilon avatar Feb 01 '18 13:02 wilon

Have you tried

win.SendMessage(hwnd, win.WM_CLOSE, 0, 0)

?

krpors avatar Apr 18 '18 20:04 krpors

It might be prudent to use the non-blocking variant

win.PostMessage(yourHWND, win.WM_CLOSE, 0, 0)

The program you are trying to close might open a popup dialog (e.g. requesting to save the modified document it was showing) and that will block your program!

StephanVerbeeck avatar Apr 02 '19 07:04 StephanVerbeeck