from psychtoolbox import Screen
from psychtoolbox import PsychHID as HID
from psychtoolbox import WaitSecs
from timeit import default_timer as time

if __name__ == '__main__':
    screen = max(Screen('Screens'))

    w1, r1 = Screen('OpenWindow', screen, [80.0] * 4, [0., 0, 800, 800])
    w2, r2 = Screen('OpenWindow', screen, [50.0] * 4, [900., 0, 1700, 800])

    foo = Screen('GetWindowInfo', w1)
    print(foo)

    print(Screen('GetWindowInfo', w2))
    keys = [1] * 256
    HID('KbQueueCreate', [], [], [], [], [], 0)#), Screen('GetWindowInfo', w1)['SysWindowHandle'])
  
    HID('KbQueueStart')
    t0 = time()
    while time() < (t0 + 10):
        #pressed, first_press, first_release, last_press, last_release = HID('KbQueueCheck')

        Screen('Flip', w1)
        Screen('Flip', w2)

    HID('KbQueueRelease')
    Screen('Close', w2)
    Screen('Close', w1)
