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);
}
相关文档:
这些天因为工作需要,要将一些html文件转换为chm文件,当然是需要和程序结合在一起。
后来找到NDoc,里头有一段代码是相关的,于是开始分析代码,写完之后,总结:主要是利用微软的hhc.exe来编译html文件,程序需要将具体的数据写入hhp和hhc文件。
主要代码如下:
复制C#代码保存代码public void CompileProject()
{ ......
先说python
python的random模块提供了多个伪随机数发生器,默认都是用当前时间戳为随机数种子。
下面是该模块几个最常用的函数
random() Return the next random floating point number in the range [0.0, 1.0).
randint(a,b) Return a random integer N such that a <=
N <= b
randrange([star ......
C#正则表达式编程(三):Match类和Group类用法 收藏 此文于2010-03-09被推荐到CSDN首页
如何被推荐?
前面两篇讲述了正则表达式的基础和一些简单的例子,这篇将稍微深入一点探讨一下正则表达式分组,在.NET中正则表达式分组是用Math类来代表的。
首先先看一段代码:
view plaincopy to clipboardprint?
/// &l ......
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 ......