Skip to content

drmbt/bgKeysMouse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bgKeysState_simple

This technique is based on a forum post with contributions from Harvey Moon and Idzard that can be found here:

The bgKeyboardMouse component brings to DAT/CHOP space the state of the keyboard and mouse when another program is in focus and TouchDesigner is in the background

These components work by leveraging the ctypes library and windll.User32.GetKeyState functions to access keyboard and mouse information when TouchDesigner is in the background;
by default if TD is not the in focus app the mousein and keyboardinDAT/CHOP don't run.

We do this by importing the ctypes library and cooking the query every frame with an execute dat, which is something i like to turn off if I'm not using it by toggling of the relevant Active flag.

Since we are querying the state of every key every frame, an editable query table allows us to define the order and scope of the desired keys we're polling for.

the GetAsyncKeyState() function requires the virtual key unicode value as defined here: and here:.

For ease of use this _simple component converts user defined characters from the table to CHOP/DAT land with the windll.User32.VkKeyScanW(ord(c)) char2key function.

This is fine for getting a few letters and numbers, but doesn't give us access to characters like 'spacebar', 'enter' etc. that aren't represented by a single character. A more advanced compoent that parses the codes from the above links will be required to get at these keys, but special characters, punctuation etc. could be added to the table to access those characters

About

python keyboard and mouse input state while TD is not in focus

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published