TwitchDropsMiner
TwitchDropsMiner copied to clipboard
ValueError: string too long w.r.t. win32.NOTIFYICONDATAW
I get the following error after minimizing the script to the tray. No idea what changed as the error was not there a few days ago.
Exception in thread Thread-1 (setup_handler):
Traceback (most recent call last):
File "C:\Users\Wok\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1052, in _bootstrap_inner
self.run()
File "C:\Users\Wok\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 989, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\Wok\PycharmProjects\TwitchDropsMiner\.venv\Lib\site-packages\pystray\_base.py", line 400, in setup_handler
self.visible = True
^^^^^^^^^^^^
File "C:\Users\Wok\PycharmProjects\TwitchDropsMiner\.venv\Lib\site-packages\pystray\_base.py", line 184, in visible
self._show()
File "C:\Users\Wok\PycharmProjects\TwitchDropsMiner\.venv\Lib\site-packages\pystray\_win32.py", line 59, in _show
self._message(
File "C:\Users\Wok\PycharmProjects\TwitchDropsMiner\.venv\Lib\site-packages\pystray\_win32.py", line 337, in _message
win32.Shell_NotifyIcon(code, win32.NOTIFYICONDATAW(
^^^^^^^^^^^^^^^^^^^^^^
ValueError: string too long (132, maximum length 128)
Package Version
---------- -------
aiohttp 3.9.3
aiosignal 1.3.1
attrs 23.2.0
frozenlist 1.4.1
idna 3.6
multidict 6.0.5
pillow 10.2.0
pystray 0.19.5
pywin32 306
six 1.16.0
truststore 0.8.0
yarl 1.9.4
Nevermind, the error stopped happening after I have finished mining Apex drops.
I have upgraded the required packages, just in case.
Package Version
---------- -------
aiohttp 3.9.5
aiosignal 1.3.1
attrs 23.2.0
frozenlist 1.4.1
idna 3.7
multidict 6.0.5
pillow 10.3.0
pystray 0.19.5
pywin32 306
six 1.16.0
truststore 0.9.0
yarl 1.9.4
Hello.
The error going away doesn't resolve the underlying issue, which in this case appears to be a 128 characters limit on a tray icon title. This can apparently be exceeded, if a drop that's currently being mined has a long name, or belongs to a game that has a long name, or a combination of these two.
The simplest solution would be to just always trim the tray icon title down to <128 characters, but that'd just make it ugly and weirdly cut-off in these cases. A proper solution would be to always leave the main title and progress percentage up, while only trimming the drop's name. If that's isn't enough, then trim the game's name as well. Maybe the application title could be removed as well, solely to allow for more characters to be displayed. I'll try to put out a patch for this soon.
This should now be solved via https://github.com/DevilXD/TwitchDropsMiner/commit/f987fecdd06b7b51d2557479ff255599050ef212 in the latest master build.