aardappel / procrastitracker

a Windows time tracking application
http://strlen.com/procrastitracker/
483 stars 53 forks source link

Fix and enable Chrome URL getting #81

Closed Ivan1248 closed 2 years ago

Ivan1248 commented 2 years ago

The bug was caused by a hard to spot error where != 0 was used instead of == 0 on the output of strcmp to indicate equality.

Unless I missed something, I think this fixes #65.

aardappel commented 2 years ago

Did you test that this works? Because from what I remember, URL getting is generally broken. It relies on current_chrome_url being populated by the code in ddeutil.h, and that code doesn't work anymore afaik. So we can merge this since it doesn't make things work, but that other code would need to be fixed as well.

aardappel commented 2 years ago

The interesting thing is your change of != to ==, which definitely seems a bug the existing code. When I change that locally, the reason it is failing to get the URL is that classname is HwndWrapper[DefaultDomain;;e9a066f1-a916-48e4-9cc4-3770a4e0e278], not the expected Chrome_WidgetWin_1, and that the HWND in question doesn't have the url properties queried from it below.

aardappel commented 2 years ago

Let me merge it and work from there.. but still not getting URLs on either Chrome or Edge..

Ivan1248 commented 2 years ago

Hi! Thank you for ProcrastiTracker!

It works on my computer (Chrome 92, Chrome 93 on Windows 10 build 19043) after switching tabs for 2 Wikipedia pages. I get Chrome_WidgetWin_1 both for Chrome and Edge.

aardappel commented 2 years ago

I wonder why I don't then..

aardappel commented 2 years ago

You're right, it works, it just only works on tab change, and then only the second time the function gets called.. the rest of the time it receives something else..

Further cleaned up error checking and debug code: https://github.com/aardappel/procrastitracker/commit/9e51ff9eae7a0589674f1a48633269b78c3bdd7c

Also uploaded a fresh installer to https://strlen.com/procrastitracker/ so whoever downloads from there benefits from this fix.

Thanks so much for finding this issue! Very simple yet so easily overlooked.. When I last looked at it I was debugging the code below GetClassName, so I was looking at data from the wrong invocation..