0

C# 向最终幻想 14 窗口发送按键信息

 2 years ago
source link: https://violarulan.github.io/blog/send-key-press-to-ffxiv-window/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Programmer, Data Analyst and Gamer

C# 向最终幻想 14 窗口发送按键信息

Feb 18, 2017
已阅读了一分钟

最近在做钓鱼脚本。

class Send {
    #region Imports
    [DllImport("user32.dll")]
    static extern bool PostMessage(IntPtr hWnd, uint Msg, int wParam, uint lParam);
    [DllImport("user32.dll", SetLastError = true)]
    static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
    [DllImport("user32.dll", SetLastError = true)]
    static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
    #endregion
 
    public static void KeyPress(Keys key, int sleep = 100) {
        const int WM_KEYDOWN = 0x100;
        const int WM_KEYUP = 0x101;
 
        IntPtr ffxiv = FindWindow("ffxiv", null);
        IntPtr editx = FindWindowEx(ffxiv, IntPtr.Zero, "FFXIVGAME", null);
 
        PostMessage(editx, WM_KEYDOWN, (int)key, 0x001F0001);
        Thread.Sleep(sleep);
        PostMessage(editx, WM_KEYUP, (int)key, 0xC01F0001);
    }
}
private void button1_Click(object sender, EventArgs e) {   
    Send.KeyPress(Keys.W, 10000);
}

回到文章列表


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK