随笔分类 -  软件开发:Delphi

上一页 1 2 3 4 5 6 7 8 9 10 ··· 12 下一页
摘要:AutoHotkey的源码,模糊找图和精确找图思路一样,也是用笨方法。原来的C代码比较难看懂,这里的delphi代码,很容易弄明白。以下是模糊的找图。如果需要,可以再做优化处理。注意我这里去掉了透明处理,需要的自己加上吧。因为用到了iif函数,别忘了uses IdGlobal;// 模糊判断,在大图里的(x,y)位置上是不是小图?// 其中nV是R,G,B的偏差值,0..255function BmpCmpEx(bmpBig,bmp:TBitmap;x,y:integer;nV:byte):boolean;var i,j:integer; row1, row2:pRGBTripArray; p 阅读全文
posted @ 2013-05-29 16:47 Max Woods 阅读(477) 评论(0) 推荐(0)
摘要:以前一直以为找图比较难,后来看了AutoHotkey的源码,原来也就是笨方法。以下是精确的找图。因为已经很快,没再做优化处理。注意我这里去掉了透明处理,需要的自己加上吧。//精确判断,在大图里的(x,y)位置上是不是小图?function BmpCmp(bmpBig,bmp:TBitmap;x,y:integer):boolean;var i,j:integer; row1, row2:pRGBTripArray; p1,p2:TRGBTriple;begin result:=true; for j:=0 to bmp.Height-1 do begin row1:=bmpBig.ScanLi 阅读全文
posted @ 2013-05-29 16:46 Max Woods 阅读(820) 评论(0) 推荐(0)
摘要:找色和色块,是模拟的重要基础。有时候,需要确定某点是否出现某种颜色,有时候需要判断色块是否出现在某位置有时候,需要看范围内是否出现色块。function IsColor(bmp:TBitmap; x,y:integer; c:TColor):boolean;var row:pRGBTripArray; p:TRGBTriple;begin row:=bmp.ScanLine[y]; p:=row[x]; result:=(p.rgbtBlue=GetBValue(c)) and (p.rgbtGreen=GetGValue(c)) and (p.rgbtRed=GetRValue(c));en 阅读全文
posted @ 2013-05-29 16:44 Max Woods 阅读(392) 评论(0) 推荐(1)
摘要:模拟需要找色,找图等等功能,我们先要熟悉有关的知识。我们的目的是为了找色和找图,所以只用考虑只需要处理24B颜色(PF24BIT)。TColor值是以十六进制进行存储的,低三位分别表示红、绿、蓝三种基色的饱和度。var C:Tcolor R,G,B:Byte;TColor转换成RGB的值 R:=GetRValue(C); G:=GetGValue(C); B::=GetBValue(C);或 R:=C and $FF; G:=(C and $FF00) shr 8; B:=(C and $FF0000) shr 16;RGB转换成TColor的值 C:=StrToInt(IntToHex(B, 阅读全文
posted @ 2013-05-29 16:43 Max Woods 阅读(233) 评论(0) 推荐(0)
摘要:查找游戏窗口procedure FindGameWindow;var h:THandle; buf:array[0..255] of char;begin FillChar(buf,sizeof(buf),0); h := GetForegroundWindow(); while (h<>0) do begin GetWindowText(h, buf, 255); if (AnsiContainsStr(buf, '游戏标题名称')) then begin // 找到一个游戏窗口句柄,做记录或其他处理 end; h:=GetNextWindow(h,2); end 阅读全文
posted @ 2013-05-29 16:42 Max Woods 阅读(343) 评论(0) 推荐(0)
摘要:网上有很多的关于模拟按键的例子,经过实验,我选如下一组函数procedure SendShift(H: HWnd; Down: Boolean);var vKey, ScanCode: Word; lParam: longint;begin vKey:= $10; ScanCode:= MapVirtualKey(vKey, 0); lParam:= longint(ScanCode) shl 16 or 1; if not(Down) then lParam:= lParam or $C0000000; SendMessage(H,WM_KEYDOWN, vKey, lParam);end; 阅读全文
posted @ 2013-05-29 16:40 Max Woods 阅读(889) 评论(0) 推荐(0)
摘要:以下的抓图,来源于网上。function dlGetDesktopRect(nLeft,nTop,nWidth,nHeight:integer;pixel:TPixelFormat):TBitmap;var dcDesk:hdc; bmp:TBitmap;begin bmp:=TBitmap.Create; bmp.PixelFormat := pixel; bmp.Width:=nWidth; bmp.Height:=nHeigth; dcDesk:=GetDC(GetDesktopWindow); BitBlt(bmp.Canvas.Handle,0,0,nWidth,nHeigth,dc 阅读全文
posted @ 2013-05-29 16:39 Max Woods 阅读(521) 评论(0) 推荐(0)
摘要:在《强大的DELPHI RTTI--兼谈需要了解多种开发语言》一文中,我说了一下我用DELPHI的RTTI实现了数据集的简单对象化。本文将详细介绍一下我的实现方法。首先从一个简单的例子说起:假设有一个ADODataSet控件,连接罗斯文数据库,SQL为:select * from Employee现在要把它的内容中EmployeeID, FirstName, LastName,BirthDate四个字段显示到ListView里。传统的代码如下://先要设置AdoDataSet的CommandText属性With ADODataSet1 DoBeginOpen;While Not Eof DoB 阅读全文
posted @ 2013-05-14 16:16 Max Woods 阅读(435) 评论(0) 推荐(0)
摘要:⊙RTTI简介⊙类(class)和VMT的关系⊙类(class)、类的类(classofclass)、类变量(classvariable)的关系⊙TObject.ClassType和TObject.ClassInfo⊙is和as运算符的原理⊙TTypeInfo–RTTI信息的结构⊙获取类(class)的属性(property)信息⊙获取方法(method)的类型信息⊙获取有序类型(ordinal)、集合(set)类型的RTTI信息⊙获取其它数据类型的RTTI信息=================================================================== 阅读全文
posted @ 2013-05-14 15:58 Max Woods 阅读(294) 评论(0) 推荐(0)
摘要:unit WindowsSysVersion;interfaceuses windows ;{$IFDEF CONDITIONALEXPRESSIONS}{$IF Defined(TOSVersionInfoEx)}{$DEFINE TOSVERSIONINFOEX_DEFINED}{$IFEND}{$ENDIF}{$IFNDEF TOSVERSIONINFOEX_DEFINED}type POSVersionInfoEx = ^TOSVersionInfoEx; TOSVersionInfoEx = packed record dwOSVersionInfoSize: DWORD; dwMa 阅读全文
posted @ 2013-05-06 23:12 Max Woods 阅读(569) 评论(0) 推荐(0)
摘要:delayed是Delphi2010中一种新的声明方式,使用它将可以在不适当的环境下绕过不存在的API函数,并且对该API的调用进行“跳过”的处理来看以下例子:function GetTouchInputInfo(hTouchInput: THandle; cInputs: UINT;pInputs: PTouchInput; cbSize: Integer): BOOL; stdcall;external user32 name 'GetTouchInputInfo' delayed;这是定义于keyboard单元内的API函数,用于实现Windows 7下触摸屏的消息获取, 阅读全文
posted @ 2013-05-01 10:31 Max Woods 阅读(417) 评论(0) 推荐(0)
摘要:今天帮别人解决一个关于 Base64 编解码的问题,竟然发现 Delphi 自带了 Base64 编解码的单元,叫 EncdDecd,这名字很拗口而且不直观,估计这是一直很少人关注和知道的原因。这个单元提供两套四个公开函数:对流的编解码:procedure EncodeStream(Input, Output: TStream); // 编码procedure DecodeStream(Input, Output: TStream); // 解码// 对字符串的编解码:function EncodeString(const Input: string): string; // 编码functi 阅读全文
posted @ 2013-04-23 09:58 Max Woods 阅读(356) 评论(0) 推荐(0)
摘要:什么是管道?参考《WIN32汇编编程》是这样描述的 Windows 引入了多进程和多线程机制。同时也提供了多个进程之间的通信手段,包括剪贴板、DDE、OLE、管道等,和其他通信手段相比,管道有它自己的限制和特点,管道实际上是一段共享内存区,进程把共享消息放在那里。并通过一些 API 提供信息交换。管道是两个头的东西,每个头各连接一个进程或者同一个进程的不同代码,按照管道的类别分有两种管道,匿名的和命名的;按照管道的传输方向分也可以分成两种,单向的双向的。根据管道的特点,命名管道通常用在网络环境下不同计算机上运行的进程之间的通信(当然也可以用在同一台机的不同进程中)它可以是单向或双向的;而... 阅读全文
posted @ 2013-04-17 10:06 Max Woods 阅读(1886) 评论(0) 推荐(0)
摘要:procedure pinghost(ip:string;var info:string);ip:目标IP地址;info:ping了以后产生的信息(1)或(2);(1)成功信息 ip 发送测试的字符数 返回时间(2)出错信息 Can not find host!使用uses ping;procedure TForm1.Button1Click(Sender: TObject);varstr:string;ping:Tping;beginping:=Tping.create ;//一定要初试化哦ping.pinghost('127.0.0.1',str);memo1.Lines. 阅读全文
posted @ 2013-04-17 09:40 Max Woods 阅读(439) 评论(0) 推荐(0)
摘要:这个功能好难找。在 dxSkinController 控件的事件中设置。procedure TMainForm.dxSkinController1SkinForm(Sender: TObject; AForm: TCustomForm; var ASkinName: string; var UseSkin: Boolean); begin UseSkin := false; end; 阅读全文
posted @ 2013-04-07 22:19 Max Woods 阅读(682) 评论(0) 推荐(0)
摘要:Locate('Company;Contact;Phone', VarArrayOf(['Sight Diver', 'P']),[loPartialKey]); 阅读全文
posted @ 2013-04-06 10:08 Max Woods 阅读(178) 评论(0) 推荐(0)
摘要:VarArrayOf的主要功能是构造一个Variant数组,通过VarArrayCreate实现:[delphi]view plaincopyfunctionVarArrayOf(constValues:arrayofVariant):Variant;varI:Integer;beginResult:=VarArrayCreate([0,High(Values)],varVariant);forI:=0toHigh(Values)doResult[I]:=Values[I];end;下面是一个使用实例:[c-sharp]view plaincopytypeTStrArr=arrayofstri 阅读全文
posted @ 2013-04-06 10:05 Max Woods 阅读(1489) 评论(0) 推荐(0)
摘要:需求:返回用分钟表示的主计算机上的时间和全球标准时间 (UTC) 之间的时间差,如:2010-01-10 09:07:54,与UTC之间的时间差应为:1263085674.调用方法: getTimezoneOffset(StrToDateTime('2010-01-10 09:07:54'));实现代码://功能:获取本机时间区function getTimeZone:integer; var m_timezone:TIME_ZONE_INFORMATION; i:integer; dTimezone:double; iTimezone:integer; begin GetTi 阅读全文
posted @ 2013-01-31 10:02 Max Woods 阅读(322) 评论(0) 推荐(0)
摘要:There are a number of warnings available in Delphi XE2 that are not very well documented. While you can control them in the Project options dialog, and you can turn them on using {$WARN} directives or in command line compiler options, the documentation for the warning identifiers is currently pret.. 阅读全文
posted @ 2012-11-04 20:07 Max Woods 阅读(1201) 评论(0) 推荐(0)
摘要:首先去7z官网下载代码 7z的源代码或者lzma都可以,但是推荐下7z的源代码,里面东西比较全7z.dll 通过 COM 接口工作。但是它并没有使用标准的 COM 接口 。如果有com基础的话 看他的代码会比较容易。比较简单的例子是 /cpp/7zip/ui/client7z 里面有简单的 压缩 解压缩 和查看压缩包文件。 7z.dll的源代码在 bundles/7zformatf 里面其中 clinet7z和 file manager的代码看起来比较好理解,可以自己一步一步跟着走。 // 晚上再更新7z.dll采用com接口工作,但是它并没有使用标准的COM接口。对文件的解压主要靠下面两个回 阅读全文
posted @ 2012-11-04 17:49 Max Woods 阅读(1490) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 7 8 9 10 ··· 12 下一页