吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 4175|回复: 5
收起左侧

[其他原创] 【原创源码】[C#] 延时输入

[复制链接]
os51 发表于 2016-7-30 14:15
本帖最后由 os51 于 2016-7-30 16:06 编辑

[C#] 纯文本查看 复制代码
namespace SendKeyWait{
    using System;
    using System.Windows.Forms;

    public class Program
    {
            [STAThread]
        private static void Main(string[] args)
        {
            int timeout = 0;
            try
            {
                x = Convert.ToInt32(args[0]);
                System.Threading.Thread.Sleep(x);
                for (int i = 1; i < args.Length; i++) {SendKeys.SendWait(args[i].Replace("\r\n", "{ENTER}"));}
            }
            catch
            {
                Environment.Exit(-1);
            }
        }
    }
}

用法: SendKeyWait 300 abcdef
300为延时,单位毫秒

骂人方法:
批处理:for /f "tokens=* eol=; delims=" %%i in (text.txt) do SendKeyWait 500  %%i &SendKeyWait 500  {ENTER}
命令行直接输入:for /f "tokens=* eol=; delims=" %i in (text.txt) do SendKeyWait 500  %i &SendKeyWait 500  {ENTER}
text.txt为内容,一行一个

编译:"C:\Windows\Microsoft.NET\Framework\v2.0.50727\csc.exe" SendKeyWait .cs

本帖被以下淘专辑推荐:

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

工藤新二QVQ 发表于 2016-7-30 14:49
谢谢楼主
samjun 发表于 2016-7-31 11:42
葬礼昨天 发表于 2016-9-16 10:01
能问一下 [STAThread]这个特性有什么用没吗,一直不是很明白,谢谢
 楼主| os51 发表于 2016-9-16 14:20
葬礼昨天 发表于 2016-9-16 10:01
能问一下 [STAThread]这个特性有什么用没吗,一直不是很明白,谢谢

The STAThreadAttribute is essentially a requirement for the Windows message pump to communicate with COM components. Although core Windows Forms does not use COM, many components of the OS such as system dialogs do use this technology.

MSDN explains the reason in slightly more detail:

STAThreadAttribute indicates that the COM threading model for the application is single-threaded apartment. This attribute must be present on the entry point of any application that uses Windows Forms; if it is omitted, the Windows components might not work correctly. If the attribute is not present, the application uses the multithreaded apartment model, which is not supported for Windows Forms.
This blog post (Why is STAThread required?) also explains the requirement quite well. If you want a more in-depth view as to how the threading model works at the CLR level, see this MSDN Magazine article from June 2004 (Archived, Apr. 2009).
http://stackoverflow.com/questions/1361033/what-does-stathread-do
葬礼昨天 发表于 2016-9-16 15:15
os51 发表于 2016-9-16 14:20
The STAThreadAttribute is essentially a requirement for the Windows message pump to communicate wi ...

多谢。。。。。。。。。。。。
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-15 15:39

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表