How to freak out someone

james.lu.75491856 -4 Tallied Votes 358 Views Share

THIS IS DANGEROOUS CODE, if it fails, it may prevent yu frome editing it.
also, you can use the functions to do crazy stuff. Look at this refrence and change the 0x12 to what you want.
(This one hold alt, so typing r will actibvate the menu that starts with 'r')

import os
SendInput = ctypes.windll.user32.SendInput

# 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 HoldKey(hexKeyCode):

    extra = ctypes.c_ulong(0)
    ii_ = Input_I()
    ii_.ki = KeyBdInput( hexKeyCode, 0x48, 0, 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( hexKeyCode, 0x48, 0x0002, 0, ctypes.pointer(extra) )
    x = Input( ctypes.c_ulong(1), ii_ )
    ctypes.windll.user32.SendInput(1, ctypes.pointer(x), ctypes.sizeof(x))
HoldKey(0x12)
james.lu.75491856 0 Junior Poster

0x15 makes you type japenese

james.lu.75491856 0 Junior Poster

tomap={' ':'0x20','1': '0x31', '0': '0x30', '3': '0x33', '2': '0x32', '5': '0x35', '4': '0x34', '7': '0x37', '6': '0x36', '9': '0x39', '8': '0x38', 'A': '0x41', 'C': '0x43', 'B': '0x42', 'E': '0x45', 'D': '0x44', 'G': '0x47', 'F': '0x46', 'I': '0x49', 'H': '0x48', 'K': '0x4B', 'J': '0x4A', 'M': '0x4D', 'L': '0x4C', 'O': '0x4F', 'N': '0x4E', 'Q': '0x51', 'P': '0x50', 'S': '0x53', 'R': '0x52', 'U': '0x55', 'T': '0x54', 'W': '0x57', 'V': '0x56', 'Y': '0x59', 'X': '0x58', 'Z': '0x5A'}

import time
print "go into a text editor in 5 secs"
time.sleep(5)
for i in 'YOU ARE GOOD':
    PressKey(int(tomap[i],0))
time.sleep(.5)
for i in range(4):
    PressKey(0x08) #backspace
for i in 'GREAT':
    PressKey(int(tomap[i],0))

The ghost program.

james.lu.75491856 0 Junior Poster

0x15 makes you type japenese
I was wrong, it doesn't work.

Nils_1 0 Newbie Poster

You get a downvote just because you enjoy to freak out people.

sneekula 969 Nearly a Posting Maven

This code snippet is pretty stupid.
If I could down vote it from my iPad, I would!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.