zoukankan      html  css  js  c++  java
  • 自动按键 http://www.appinn.com/201312306traintickets/

    对应的C#代码at 12:00 shutdown -s12:00

    http://www.cnblogs.com/luckdv/articles/1728088.html?login=1

    [StructLayout(LayoutKind.Explicit)]        

    public struct Input
     {
                 [FieldOffset(0)]public Int32 type;
                 [FieldOffset(4)]public MouseInput mi;
                 [FieldOffset(4)]public tagKEYBDINPUT    ki;
                 [FieldOffset(4)]public tagHARDWAREINPUT hi;     
     }

    C#中对应代码:

            [StructLayout(LayoutKind.Sequential)]
            public struct MouseInput
            {
                public Int32 dx;
                public Int32 dy;
                public Int32 Mousedata;
                public Int32 dwFlag;
                public Int32 time;
                public IntPtr dwExtraInfo;
            }

            [StructLayout(LayoutKind.Sequential)] 
            public struct tagKEYBDINPUT 
            {
               Int16      wVk;
               Int16     wScan;
               Int32     dwFlags;
               Int32     time;
               IntPtr   dwExtraInfo;
            }

            [StructLayout(LayoutKind.Sequential)]
            public struct tagHARDWAREINPUT
            {
                Int32 uMsg;
                Int16 wParamL;
                Int16 wParamH;
            }

    我主要是模拟鼠标,所以只需定义鼠标的flag值:

            const int MouseEvent_Absolute = 0x8000;
            const int MouserEvent_Hwheel = 0x01000;
            const int MouseEvent_Move = 0x0001;
            const int MouseEvent_Move_noCoalesce = 0x2000;
            const int MouseEvent_LeftDown = 0x0002;
            const int MouseEvent_LeftUp = 0x0004;
            const int MouseEvent_MiddleDown = 0x0020;
            const int MouseEvent_MiddleUp = 0x0040;
            const int MouseEvent_RightDown = 0x0008;
            const int MouseEvent_RightUp = 0x0010;
            const int MouseEvent_Wheel = 0x0800;
            const int MousseEvent_XUp = 0x0100;
            const int MousseEvent_XDown = 0x0080;

    c#中模拟鼠标操作的代码:

            for (i = X; i <= X+width; i += 450)  

                   //X为Flash窗口的左上角的x轴绝对坐标值。屏幕左上角坐标是(0,0)。width是Flash窗口宽度。
            {

                    for (j = Y; j <= Y +height; j+=150) //Y为Flash窗口的左上角的y轴绝对坐标值。height是Flash窗口高度。
                    {

                        MouseInput myMinput = new MouseInput();
                        myMinput.dx = i;
                        myMinput.dy = j;
                        myMinput.Mousedata = 0;
                        myMinput.dwFlag = MouseEvent_Absolute | MouseEvent_Move | MouseEvent_LeftDown | MouseEvent_LeftUp;

                        myMinput.time = 0;
                        Input[] myInput = new Input[1];
                        myInput[0] = new Input();
                        myInput[0].type = 0;
                        myInput[0].mi = myMinput;

                        UInt32 result = SendInput((uint)myInput.Length, myInput, Marshal.SizeOf(myInput[0].GetType()));
                        if (result == 0)
                        {
                            MessageBox.Show("fail");
                        }
                    }
                }

    知识点:将像素坐标转化为绝对坐标:

    API中MouseInput结构中的dx,dy含义是绝对坐标,是相对屏幕的而言的,屏幕左上角的坐标为(0,0),右下角的坐标为 (65535,65535)。而我们在C#中获得的对象(Frame,button,flash等)的坐标都是像素坐标,是跟你当前屏幕的分辨率相关的。 假如你的显示器分辨率是1024*768,那么屏幕左上角的像素坐标是(0,0),右下角坐标为(1024,768)。转换函数如下:

    dx = x * (65335/ScreenWidth) //x,y为像素坐标。
    dy = y * (65335/ScreenHeight)//ScreenWidth和ScreenHeight,其实是当前显示器的分辨率,获得方法是ScreenWidth=Screen.PrimaryScreen.WorkingArea.Width;

    ScreenHeight=Screen.PrimaryScreen.WorkingArea.Height;http://91sp.vido.ws/index.php

    string temp_Path = @"C:\Users\muye\Desktop\iecss3\temp.xml";
                XDocument xd =  XDocument.Load(temp_Path);
                //var query = from book in xd.Descendants("Root")
                //            select new
                //            {
                //                age = book.Element("age").Value,
                //                Time = book.Element("name").Value,
                //               // tempName=book.Element("FirstName").Value
                //            };
                //foreach (var item in query)
                //{
                //    Console.WriteLine(item.age);
                //    //Console.WriteLine(item.tempName);
                //    Console.ReadLine();
                //}

                var query1 = from a in xd.Elements("Root").Elements("Employees").Elements("Employee")
                
                             select new
                             {
                                 tempName = a.Element("HireDate").Value
                             };     
                          
               
                foreach (var item in query1)
                {
                    Console.WriteLine("hello");
                    Console.WriteLine(item.tempName);
                    Console.ReadLine();
                }

    XElement XEle = new XElement("UserInfos");
                for (int i = 0; i < nodeUserName.Length; i++)
                {
                    XEle.Add(
                        new XElement("UserInfo",
                            new XAttribute("TableKey", (i + 1).ToString()),
                            new XAttribute("UserName", nodeUserName.ToString()),
                            new XAttribute("PassWord", nodePassword.ToString())
                        )
                    );
                }

    <?xml version="1.0" encoding="utf-8"?>
    <root>
     <FTPSites>
       <FTPSite>
         <IP>10.85.11.11</IP>
         <Port>8080</Port>
       </FTPSite>
       <FTPSite>
         <IP>10.85.11.12</IP>
         <Port>8080</Port>
       </FTPSite>
       <FTPSite>
         <IP>10.85.11.13</IP>
         <Port>8080</Port>
       </FTPSite>
     </FTPSites>
    </root>

  • 相关阅读:
    discuz常用变量
    Discuz!X/模板标签说明
    Discuz x 默认模板文件目录说明
    apache禁止访问文件或目录执行权限、禁止运行脚本PHP文件的设置方法
    基于Java的数据采集(三)
    基于Java的数据采集(二)
    基于Java的数据采集(一)
    使用Spring JDBCTemplate简化JDBC的操作
    基于原生PHP交叉会员权限控制
    PHP上传压缩包并自解压方法
  • 原文地址:https://www.cnblogs.com/standy225/p/2817327.html
Copyright © 2011-2022 走看看