About the keyboard input simulation of WinIO.DLL

Source: Internet
Author: User

About the keyboard input simulation of WinIO.DLL


Recently in the way of looking for keyboard simulation, finally found on the Internet a WinIO.DLL IO keyboard simulation button. But there's a problem with that method.  I built a global hook to monitor the keyboard information, and found that it was just keydown and keypress messages, KeyUp the information is up a zoom key. After 2 days of having finally found the right way, here is the code (use requires Winio.dll,winio.vxd,winio.sys):public class Winiolab
{
Private Const int kbc_key_cmd = 0x64;
Private Const int kbc_key_data = 0x60;
[DllImport ("Winio.dll")]
private static extern bool Initializewinio ();
[DllImport ("Winio.dll")]
private static extern bool Getportval (INTPTR wportaddr, out int pdwportval, byte bsize);
[DllImport ("Winio.dll")]
private static extern bool Setportval (UINT wportaddr, IntPtr dwportval, byte bsize);
[DllImport ("Winio.dll")]
private static extern byte Mapphystolin (byte pbphysaddr, uint dwphyssize, IntPtr physicalmemoryhandle);
[DllImport ("Winio.dll")]
private static extern bool Unmapphysicalmemory (IntPtr physicalmemoryhandle, byte pblinaddr);
[DllImport ("Winio.dll")]
private static extern bool Getphyslong (IntPtr pbphysaddr, byte pdwphysval);
[DllImport ("Winio.dll")]
private static extern bool Setphyslong (IntPtr pbphysaddr, byte dwphysval);
[DllImport ("Winio.dll")]
private static extern void Shutdownwinio ();
[DllImport ("User32.dll")]
private static extern int Mapvirtualkey (UINT Ucode, uint umaptype);


Private Winiolab ()
{
Isinitialize = true;
}
public static void Initialize ()
{
if (Initializewinio ())
{
Kbcwait4ibe ();
Isinitialize = true;
}
}
public static void Shutdown ()
{
if (isinitialize)
Shutdownwinio ();
Isinitialize = false;
}

private static bool Isinitialize{get; set;}

Wait for the keyboard buffer to be empty
private static void Kbcwait4ibe ()
{
int dwval = 0;
Do
{
BOOL flag = Getportval ((IntPtr) 0x64, out dwval, 1);
}
while ((Dwval & 0x2) > 0);
}
Analog Keyboard Label Press
public static void KeyDown (Keys vkeycoad)
{
if (! Isinitialize) return;

int btscancode = 0;
Btscancode = Mapvirtualkey (UINT) vkeycoad, 0);
Kbcwait4ibe ();
Setportval (Kbc_key_cmd, (INTPTR) 0xd2, 1);
Kbcwait4ibe ();
Setportval (Kbc_key_data, (INTPTR) 0x60, 1);
Kbcwait4ibe ();
Setportval (Kbc_key_cmd, (INTPTR) 0xd2, 1);
Kbcwait4ibe ();
Setportval (Kbc_key_data, (INTPTR) Btscancode, 1);
}
Analog Keyboard Popup
public static void KeyUp (Keys vkeycoad)
{
if (! Isinitialize) return;

int btscancode = 0;
Btscancode = Mapvirtualkey (UINT) vkeycoad, 0);
Kbcwait4ibe ();
Setportval (Kbc_key_cmd, (INTPTR) 0xd2, 1);
Kbcwait4ibe ();
Setportval (Kbc_key_data, (INTPTR) 0x60, 1);
Kbcwait4ibe ();
Setportval (Kbc_key_cmd, (INTPTR) 0xd2, 1);
Kbcwait4ibe ();
Setportval (Kbc_key_data, (INTPTR) (Btscancode | 0x80), 1);
}
}

KeyDown and KeyUp information are 0x60, and KeyUp is a key plus or 0x80 .

But the use of WinIO.dll method in the Win7 64x can not be used, the basic registration can not drive, I do not know if anyone study to arrive at a solution. Some words please contact me: [email protected], thank you.

About the keyboard input simulation of WinIO.DLL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.