carrot69 / keep-presence

Keeps your computer awake by moving the mouse or pressing a key when you step away.
Creative Commons Zero v1.0 Universal
257 stars 38 forks source link

TypeError: 'NoneType' object is not subscriptable #21

Open m-jonas opened 6 months ago

m-jonas commented 6 months ago

Hi,

First of all let me tell you - I love your work, this tool is brilliant!

I am having an error when running following command: python.exe .\keep-presence.py -s 30 -p 5 -m both -c on Windows 11, using Python 3.10 and running 'main' branch code which is identical with v1.0.7 tag.

10:20:49 User activity detected
--------
10:21:19 Idle detection
Traceback (most recent call last):
  File "C:\Users\XXXX\OneDrive - XXXX\Documents\repositories\keep-presence\src\keep-presence.py", line 175, in <module>
    execute_keep_awake_action()
  File "C:\Users\XXX\OneDrive - XXXX\Documents\repositories\keep-presence\src\keep-presence.py", line 157, in execute_keep_awake_action
    move_mouse()
  File "C:\Users\XXXX\OneDrive - XXXX\Documents\repositories\keep-presence\src\keep-presence.py", line 121, in move_mouse
    new_x = currentPosition[0] + delta_x
TypeError: 'NoneType' object is not subscriptable

It happens only when I lock my computer with CTRL+ALT+DEL. Otherwise it switches between active and idle just fine:

image

I am experimenting with currentPosition indices at line 121, as per error, at this time, but perhaps you can offer a better insight into the problem and/or a fix.

Thanks!

Jonas

m-jonas commented 6 months ago

Just to add some more insight from further experimentation: using arg -m keyboard after locking the screen works just fine, no errors. So must be something to do with mouse when Windows is locked.

carrot69 commented 6 months ago

Hey @m-jonas! I'm happy that you're enjoying this tool!

Unfortunately, I don't have Windows at the moment. However, I've just created a pull request that I believe addresses your issue. Would you be willing to give it a try?

Please keep me updated. If the pull request resolves your issue, I'll merge it into the master branch.

Thank you!

m-jonas commented 5 months ago

Hi @carrot69

Just tried, got the same error. Posted it in the PR discussion.

Regards

Jonas