Register for your free account! | Forgot your password?

Go Back   elitepvpers > Popular Games > Metin2
You last visited: Today at 15:38

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Simple python to simulate keyboard

Discussion on Simple python to simulate keyboard within the Metin2 forum part of the Popular Games category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Apr 2020
Posts: 1
Received Thanks: 0
Question Simple python to simulate keyboard

Hi everyone,

I would like to try just a simple thing, to begin, use a python script to simulate the keyboard input.

The goal to achieve is to pick up yangs/items coupled to the metin2 built-in system "hunt".

I saw a lot of thing on the forum, but i feel like everyone use python injector or other things.

So, I tried to only write few lines in python, and execute by itself, but doesn't work. If the active window is something line notepad, text will be write just as I typed on my keyboard, but on metin2 nothing happens :/

Tried "ctypes" library, one quick example:


Code:
import ctypes
import time

SendInput = ctypes.windll.user32.SendInput

W = 0x11
A = 0x1E
S = 0x1F
D = 0x20

NP_2 = 0x50
NP_4 = 0x4B
NP_6 = 0x4D
NP_8 = 0x48

# C struct redefinitions 
PUL = ctypes.POINTER(ctypes.c_ulong)
class KeyBdInput(ctypes.Structure):
    _fields_ = [("wVk", ctypes.c_ushort),
                ("wScan", ctypes.c_ushort),
                ("dwFlags", ctypes.c_ulong),
                ("time", ctypes.c_ulong),
                ("dwExtraInfo", PUL)]

class HardwareInput(ctypes.Structure):
    _fields_ = [("uMsg", ctypes.c_ulong),
                ("wParamL", ctypes.c_short),
                ("wParamH", ctypes.c_ushort)]

class MouseInput(ctypes.Structure):
    _fields_ = [("dx", ctypes.c_long),
                ("dy", ctypes.c_long),
                ("mouseData", ctypes.c_ulong),
                ("dwFlags", ctypes.c_ulong),
                ("time",ctypes.c_ulong),
                ("dwExtraInfo", PUL)]

class Input_I(ctypes.Union):
    _fields_ = [("ki", KeyBdInput),
                 ("mi", MouseInput),
                 ("hi", HardwareInput)]

class Input(ctypes.Structure):
    _fields_ = [("type", ctypes.c_ulong),
                ("ii", Input_I)]

# Actuals Functions

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))

def ReleaseKey(hexKeyCode):
    extra = ctypes.c_ulong(0)
    ii_ = Input_I()
    ii_.ki = KeyBdInput( 0, hexKeyCode, 0x0008 | 0x0002, 0, ctypes.pointer(extra) )
    x = Input( ctypes.c_ulong(1), ii_ )
    ctypes.windll.user32.SendInput(1, ctypes.pointer(x), ctypes.sizeof(x))

if __name__ == '__main__':
	while True:
		isActivate = True
		if isActivate == True:
			PressKey(0x72)
			time.sleep(1)
			ReleaseKey(0x72)
			time.sleep(5)
'test' is offline  
Reply

Tags
ctypes, python, script


Similar Threads Similar Threads
WTT: Keyboard with Cherry MX Red switches to keyboard with Cherry MX Blue switches
08/16/2014 - Trading - 2 Replies
As the title already says, i am looking to trade my Qpad MK50 keyboard with Cherry MX Red switches to some other mechanical keyboard with Blue switches. I may also give a bit of money, if your keyboard is more expensive.
[question] simulate keypress
08/21/2012 - Cabal Online - 3 Replies
can anyone help me with coding a c++ dll that presses a single keyboard key for cabal im creating one but no luck... quite a noob in c++ :)
Simulate click in Npc
08/06/2012 - General Coding - 0 Replies
(sorry for my bad english) =( Hi, there is a way for simulate the clicking on a npc? I need to Know if there and ¿how?. Is for the game Zero online, I want to do is "simulate" a click on an npc in specific, to open a window from anywhere, which normally can not. I am willing to learn what it takes, I would like to make an executable that simulates the "click". I thought about making the post in the section for Zero, but I had my doubts, thank you and sorry if you move. Thanks and hope...
Simulate Keyboard input - Tastatureingaben auf unterster Ebene simulieren.
07/18/2012 - .NET Languages - 5 Replies
Hi! Is there any way to simulate keyboard input in Visual Basic 2005 or higher, so that a Div-X Application receives them? Hallo! Gibt es eine Möglichkeit in Visual Basic 2005 oder höher um Tastatureingaben so zu simulieren, dass ein Div-X Spiel diese empfängt? Thank's FlixLix100
[C++] Get and save whole Keyboard (Text) Input without Keyboard Hook
03/24/2012 - Coding Tutorials - 1 Replies
Credits: me (silentchris) Alright, this shit will work with ALL Keyboards :) And you wont need to use a Keyboard Hook, which is, btw., gettin detected by some Anticheats ;) // Gets the current pressed key by looping thru all fkin vKey Codes DWORD FetchKeyCode( ) { DWORD i = 0x00; DWORD ret = 0x00;



All times are GMT +1. The time now is 15:39.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.