I made a Python program, and when I run it, the console window pops up and the results come out when I enter some data.
By the way, all the data you enter is in Korean, so I'd like you to enter it in Korean right away without switching to Korean by pressing the Korean-English conversion key on the keyboard, but is it possible to set the console window to Korean?
python console korean
import ctypes
import time
from ctypes import wintypes
wintypes.ULONG_PTR = wintypes.WPARAM
hllDll = ctypes.WinDLL ("User32.dll", use_last_error=True)
VK_HANGUEL = 0x15
class MOUSEINPUT(ctypes.Structure):
_fields_ = (("dx", wintypes.LONG),
("dy", wintypes.LONG),
("mouseData", wintypes.DWORD),
("dwFlags", wintypes.DWORD),
("time", wintypes.DWORD),
("dwExtraInfo", wintypes.ULONG_PTR))
class HARDWAREINPUT(ctypes.Structure):
_fields_ = (("uMsg", wintypes.DWORD),
("wParamL", wintypes.WORD),
("wParamH", wintypes.WORD))
class KEYBDINPUT(ctypes.Structure):
_fields_ = (("wVk", wintypes.WORD),
("wScan", wintypes.WORD),
("dwFlags", wintypes.DWORD),
("time", wintypes.DWORD),
("dwExtraInfo", wintypes.ULONG_PTR))
class INPUT(ctypes.Structure):
class _INPUT(ctypes.Union):
_fields_ = (("ki", KEYBDINPUT),
("mi", MOUSEINPUT),
("hi", HARDWAREINPUT))
_anonymous_ = ("_input",)
_fields_ = (("type", wintypes.DWORD),
("_input", _INPUT))
def get_hanguel_state():
return hllDll.GetKeyState(VK_HANGUEL)
def change_state():
x = INPUT(type=1 ,ki=KEYBDINPUT(wVk=VK_HANGUEL))
y = INPUT(type=1, ki=KEYBDINPUT(wVk=VK_HANGUEL,dwFlags=2))
hllDll.SendInput(1, ctypes.byref(x), ctypes.sizeof(x))
time.sleep(0.05)
hllDll.SendInput(1, ctypes.byref(y), ctypes.sizeof(y))
#Han > Young
If get_hanguel_state() == 1: #1, vk_key : 0x15 (Korean key) is enabled
change_state() #Press the Korean key (key_press), release
test = raw_input()
#Young > Han
If get_hanguel_state() == 0: #0, vk_key : 0x15 (Korean key) is disabled
change_state() #Press the Korean key (key_press), release
test = raw_input()
#getkeystate : https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getkeystate
#sendinput : https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendinput
#code : https://gist.github.com/Aniruddha-Tapas/1627257344780e5429b10bc92eb2f52a
After checking the status of the keyboard using win32api. Depending on the conditions... How to set it up.
Please refer to the link
It's working fine after running it. Thank you. ^
^
© 2024 OneMinuteCode. All rights reserved.