易截截图软件、单文件、免安装、纯绿色、仅160KB

C#利用winapi定位控件位置算法

public struct RECT
{
      public int left;
      public int Top;
      public int Right;
      public int Bottom;
}
public static bool CenterMouseOn(int hwnd)
{
            int x=0;
            int y=0;
            int maxX=0;
            int maxY=0;
            RECT crect=new RECT();
            int gFound=0;
            GetDisplayResolution(ref maxX,ref maxY);
            gFound=GetWindowRect(hwnd,ref crect);
            x=crect.Left+((crect.Right-crect.Left)/2);
            y=crect.Top+((crect.Bottom-crect.Top)/2);
            if((x>=0&&x<=maxX)&&(y>=0&&y<=maxY))
            {
               MoveMouse(hwnd,x,y);
                return true;
            }
             return false;
}
public static void GetDisplayResolution(ref int pixelX,ref int pixelY)
{
   pixelX=GetSystemMetrics(SM_CXSCREEN);
   pixelY=GetSystemMetrics(SM_CYSCREEN);
}


相关文档:

C#调用 win32遍历win桌面控件的算法

private static int level=0
public static int FindGUILike(ref int hWndArray,int hWndStart,ref string windowText,ref string className,ref string parentText)
{
int hwnd=0;
int r=0;
StringBuilder sWindowText=new StringBuilder();
StringBuilder sClassname=new StringBuilder();
StringBuilder sParentT ......

c# using 关键字的用法


在net中有一个至关重要的关键字,那就是using
using一般有着以下几种用法:
1、直接引入命名空间
a、using System ,这个是最常用的,就是using+命名空间,这样就可以直接使用命名空间中的类型,而免去了使用详细的命名空间
b、使用全限定名
不用使用using System;直接在程序中调用System.Console.WriteLine("Hello ......

C# 事件与委托趣谈

事件与委托似乎很难以理解,这是因为它们的使用方式与常用的编码有很大的差别,例如通常编写的都是同步代码,调用一个类型的方法,会即刻出现方法执
行的结果,这是符合逻辑的。但在某些情况中,同步代码未必满足需求,拿公共汽车来打个比方,如果交通管制中心希望每一辆公车到达一个站点时都发送给自己一
个信号以便自己 ......

[笔记]C#实现动态编译

今天看了我的老师钟声的书《Java程序员上班那点儿事》,其中有一段关于Java实现动态编译的代码使我很受启发,决定在.NET中尝试一下。
引入下列命名空间:
using System.CodeDom;
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
C#代码:
     &n ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号