# Path: directkeys.py
# def PressKey(hexKeyCode):
#     extra = ctypes.c_ulong(0)
#     ii_ = Input_I()
#     ii_.ki = KeyBdInput( 0, hexKeyCode, 0x0008, 0, ctypes.pointer(extra) )
#     x = Input( ctypes.c_ulong(1), ii_ )
#     ctypes.windll.user32.SendInput(1, ctypes.pointer(x), ctypes.sizeof(x))
# 
# W = 0x11
# 
# A = 0x1E
# 
# S = 0x1F
# 
# D = 0x20


import numpy as np
import cv2
import time
import pyautogui
from PIL import ImageGrab
from directkeys import PressKey, W, A, S, D

def process_img(image):
    original_image = image
    # convert to gray
    processed_img = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    # edge detection
    processed_img =  cv2.Canny(processed_img, threshold1 = 200, threshold2=300)
    return processed_img

def main():
    
    for i in list(range(4))[::-1]:
        print(i+1)
        time.sleep(1)

    last_time = time.time()
    while True:

# Path: directkeys.py
# def PressKey(hexKeyCode):
#     extra = ctypes.c_ulong(0)
#     ii_ = Input_I()
#     ii_.ki = KeyBdInput( 0, hexKeyCode, 0x0008, 0, ctypes.pointer(extra) )
#     x = Input( ctypes.c_ulong(1), ii_ )
#     ctypes.windll.user32.SendInput(1, ctypes.pointer(x), ctypes.sizeof(x))
# 
# W = 0x11
# 
# A = 0x1E
# 
# S = 0x1F
# 
# D = 0x20


# Path: Tutorial Codes/Part 1-7/part-2-and-3-keyboard-input-and-basic-OpenCV.py
import numpy as np
import cv2
import time
import pyautogui
from PIL import ImageGrab
from directkeys import PressKey, W, A, S, D


def process_img(image):
    original_image = image
    # convert to gray
    processed_img = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    # edge detection
    processed_img =  cv2.Canny(processed_img, threshold1 = 200, threshold2=300)
    return processed_img

def main():
    
    for i in list(range(4))[::-1]:
        print(i+1)
        time.sleep(1)

    last_time = time.time()
    while True:

        PressKey(W)