Windows-10-Toast-Notifications icon indicating copy to clipboard operation
Windows-10-Toast-Notifications copied to clipboard

Go to application on click?

Open Siecje opened this issue 8 years ago • 15 comments

When you click the notification is it possible to select the application that triggered the notification?

Siecje avatar Jan 23 '17 19:01 Siecje

Sorry for the late reply. I'm not entirely sure if this is possible will check the same.

jithurjacob avatar Feb 07 '17 03:02 jithurjacob

@Siecje I might have figured a way to enable this. Could you please explain the use case you are trying to implement

jithurjacob avatar Aug 29 '17 10:08 jithurjacob

When you click any other notification it takes you to the application that created the notification.

You get a notification from Slack and you click it and it opens Slack with the message that triggered the notification.

Siecje avatar Aug 29 '17 13:08 Siecje

I have same issue.

I tried some changes for solution but i couldn't.

I tried changes, message_map = {WM_DESTROY: self.on_destroy, } to message_map = {WM_LBUTTONDOWN: self.on_destroy, } or message_map = {WA_CLICKACTIVE: self.on_destroy, }

that's not working.

sonerb avatar Oct 29 '17 20:10 sonerb

Are there any updates on this?

Swardu avatar Jan 07 '18 11:01 Swardu

Also interested in updates here. My use case would be to open a webpage when the notification is clicked. At a high level, that means being able to start a process with parameters passed in, I suppose. Even being able to override a method on click would be very useful!

tayl avatar Feb 04 '18 15:02 tayl

I would love to do this guys. But I'm failing to implement this. Any help would be appreciated.

jithurjacob avatar Feb 05 '18 04:02 jithurjacob

@sonerb Actually it's works if you tried to put a simple print in on_destroy method you will see that it's working (only with WA_CLICKACTIVE)

stargame25 avatar Feb 06 '18 02:02 stargame25

For some reasons, if you set a WA_CLICKACTIVE to map, notification will be auto clicked anyway after duration counted down

stargame25 avatar Feb 06 '18 02:02 stargame25

I've been struggling with it for about a day now... I've found something that works for me..

I've changed the CB to a wndProc self.wc.lpfnWndProc = self.wndProc

used win32gui to get the messages. Shell_NotifyIcon(NIM_MODIFY, (self.hwnd, 0, NIF_INFO, WM_USER + 20, hicon, "Balloon Tooltip", msg, 200, title)) import win32gui win32gui.PumpMessages() and after debugging...

def wndProc(self,hWnd, message, wParam, lParam): if message == 1044: if lParam == 1029: self.on_click(hWnd, message, wParam, lParam) self.on_destroy(hWnd, message, wParam, lParam) elif lParam == 1028: self.on_destroy(hWnd, message, wParam, lParam) where lParam == 1029 it means notification was clicked. when lParam == 1028 it means notification is done without clicking.

Talavidan88 avatar Apr 28 '18 13:04 Talavidan88

I am also need that. Can you also add buttons and images support? Thanks.

dsolmann avatar Jul 19 '18 23:07 dsolmann

I'm real interested in some sort of click callback. Use case: Open an URL in browser on click.

@Talavidan88 Can you by any chance share a gist with a complete example. I'm having a hard time deciphering your instructions above. I think some of the formatting was lost.

teltmau5 avatar Aug 17 '18 19:08 teltmau5

Theoretically, if you had the handle of the window, you could win32gui.SetForegroundWindow

Scrxtchy avatar Aug 18 '18 16:08 Scrxtchy

@teltmau5 , I added this functionality in pull request #38 To open a link in browser just create and pass callback function like this:

def open_browser_tab(url):
    webbrowser.open(url, new=0)

Charnelx avatar Aug 19 '18 20:08 Charnelx

Sorry for the late reply. I'm not entirely sure if this is possible will check the same.

just fyi, @Charnelx made this work in pull request #38 . could you merge it and put that on pypi?

EDIT: actually could you merge all your pull requests? people are clearly liking this enough to help out :)

montarion avatar Jun 14 '19 21:06 montarion