using ctypes I get the error: 'module' object has no attribute 'WinDLL'

Asked by GZ

Hi Everyone,

To check num lock state (and deactivate if necessary to overcome the shift key bug), I do the following in python:

import ctypest
ctypes.WinDLL("User32.dll").GetKeyState(0x90)

This works in python but in Sikuli I get the following error:
[error] AttributeError ( 'module' object has no attribute 'WinDLL' )

Is there a solution or alternative to this?

Thanks,
George

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
GZ
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

the ctypes module cannot be loaded in Jython environment.
Only modules that are completely written in Python language and do not have any native C/C++ libraries.

I do not have an easy solution for this.

You have to look out for a Jython or Java library that does what you want.
Other options are JNI and/or JNA.

I use the library bridj in SikuliX to issue a few Windows API calls for the system path handling.
(example: see org.sikuli.util.SysJNA.java)

Revision history for this message
GZ (g-zr) said :
#2

Ahh I see :(

I would use it to check the num-lock state and if it is 1, I would run type(Key.NUM_LOCK) to disable it and then I can use KEY_SHIFT (to overcome this bug where I can't use shift + combo if numlock is on).

Is there any good way of doing that then?

Revision history for this message
RaiMan (raimund-hocke) said :
#3
Revision history for this message
GZ (g-zr) said :
#4

Woow OK.

Sorry I didn't know that exists!

Thank you, that's great! I will have a good look at the commands on that page!

ps. You answered 2/2 of my questions today, both in less than an hour = awesome support!! Thanks a lot RaiMan! :)

Revision history for this message
RaiMan (raimund-hocke) said :
#5

thanks for feedback.

I have the time and SikuliX is my hobby ;-)