C# 使用winRIng0 填写阿里旺旺2015账号密码及自动登录


查找阿里旺旺的窗体并且在相应控件填充信息的操作如下:

 private void button1_Click(object sender, EventArgs e)
        {
            //this.Visible = false;
            IntPtr hWnd1 = FindWindow(null, "阿里旺旺");                         // 阿里旺旺 2015
            SetForegroundWindow(hWnd1);
            //MessageBox.Show(GetForegroundWindow().ToString("X"));

            IntPtr hWnd2 = FindWindowEx(hWnd1, IntPtr.Zero, null, "登录窗口");       // 登录窗口
            //MessageBox.Show(hWnd2.ToString("X"));

            IntPtr hWnd3 = FindWindowEx(hWnd2, IntPtr.Zero, "StandardWindow", null);       //账号,密码框


            IntPtr hWnd31 = FindWindowEx(hWnd3, IntPtr.Zero, "EditComponent", null); // 用户名
            //MessageBox.Show(hWnd31.ToString("X"));
            //IntPtr hWnd32 = FindWindowEx(hWnd2, hWnd31, "EditComponent", null);      // 会员名
            //MessageBox.Show(hWnd32.ToString("X"));

            IntPtr hWnd3A = FindWindowEx(hWnd3, IntPtr.Zero, "AliEdit", null);        // 密  码
            IntPtr hWnd3B = FindWindowEx(hWnd3A, IntPtr.Zero, null, null);  // 这里都用null的话,就直接获取到了第一个窗体吗?
            IntPtr hWnd3C = FindWindowEx(hWnd3B, IntPtr.Zero, "ATL:Edit", null);      // 
            //MessageBox.Show(hWnd33.ToString("X"));


            SendMessage(hWnd31, WM_SETTEXT, (IntPtr)0, "userName");

            //获取焦点,再释放焦点
            SendMessage(hWnd31, WM_SETFOCUS, (IntPtr)0, "");
            SendMessage(hWnd31, WM_KILLFOCUS, (IntPtr)0, "");
            
            //获取密码框的焦点
            SendMessage(hWnd3C, WM_SETFOCUS, (IntPtr)0, "");
            //输入密码
            password();
            //释放密码框的焦点
            SendMessage(hWnd3C, WM_KILLFOCUS, (IntPtr)0, "");

            IntPtr hWnd4 = FindWindowEx(hWnd2, IntPtr.Zero, null, "登 录"); // 淘宝网
            //点击登录按钮
            SendMessage(hWnd4, WM_CLICK, (IntPtr)0, "");
            SetForegroundWindow(hWnd1);
        }
        
         private void password()
        {

            String pwd = "passWord";
        
            foreach (char chr in pwd)
            {
                Boolean result = WinRing.init();
                WinRing.KeyDown(chr);
                Thread.Sleep(100);
                WinRing.KeyUp(chr);
            }
            Thread.CurrentThread.Join(100);
        }


demo的地址:

http://www.oschina.net/code/snippet_2290420_55311


参考资料:里面有winRing0的相关信息。

http://www.csdn123.com/html/topnews201408/46/14546.htm

以及:第26楼

http://bbs.csdn.net/topics/320168111



转载于:https://my.oschina.net/aslanjia/blog/655833

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值