jithurjacob / Windows-10-Toast-Notifications

Python library to display Windows 10 Toast Notifications
MIT License
970 stars 168 forks source link

Go to application on click? #3

Open Siecje opened 7 years ago

Siecje commented 7 years ago

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

jithurjacob commented 7 years ago

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

jithurjacob commented 7 years ago

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

Siecje commented 7 years ago

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.

sonerb commented 6 years ago

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.

Swardu commented 6 years ago

Are there any updates on this?

tayl commented 6 years ago

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!

jithurjacob commented 6 years ago

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

stargame25 commented 6 years ago

@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 commented 6 years ago

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

Talavidan88 commented 6 years ago

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.

dsolmann commented 6 years ago

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

teltmau5 commented 6 years ago

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.

Scrxtchy commented 6 years ago

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

Charnelx commented 6 years ago

@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)
montarion commented 5 years ago

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 :)