Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.68 KB | None | 0 0
  1. unit dodo;
  2.  
  3. interface
  4.  
  5. uses
  6. Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  7. Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls, sButton;
  8.  
  9. type
  10. TForm13 = class(TForm)
  11. Edit1: TEdit;
  12. Edit3: TEdit;
  13. Edit4: TEdit;
  14. Edit5: TEdit;
  15. Timer1: TTimer;
  16. Panel1: TPanel;
  17. Button1: TButton;
  18. Memo1: TMemo;
  19. sButton1: TsButton;
  20. Timer2: TTimer;
  21. Timer3: TTimer;
  22. procedure Timer1Timer(Sender: TObject);
  23. procedure Button1Click(Sender: TObject);
  24. procedure FormCreate(Sender: TObject);
  25. procedure sButton1Click(Sender: TObject);
  26. procedure Timer2Timer(Sender: TObject);
  27. procedure Timer3Timer(Sender: TObject);
  28. private
  29. { Private declarations }
  30. public
  31. { Public declarations }
  32. end;
  33.  
  34. type
  35. TMatrix = array of array of string;
  36.  
  37.  
  38.  
  39. var
  40. Form13: TForm13;
  41. dat,dat2:TMatrix;
  42. implementation
  43.  
  44. {$R *.dfm}
  45.  
  46. function chek(dat:TMatrix):integer;
  47. var sum,x,y:integer; last:string;
  48. begin
  49. result:=0;
  50. sum:=0;
  51.  
  52. for y := 1 to 6 do begin
  53. sum:=0; last:='qqqqq';
  54. for x := 3 to 6 do
  55. if (dat[x,y]<>dat[x-1,y]) or (dat[x,y]<>dat[x-2,y]) then sum:=0 else begin result:=x*10+y; break; end;
  56. end;
  57.  
  58. for x := 1 to 6 do begin
  59. sum:=0; last:='qqqqq';
  60. for y := 3 to 6 do
  61. if (dat[x,y]<>dat[x,y-1]) or (dat[x,y]<>dat[x,y-2]) then sum:=0 else begin result:=x*10+y; break; end;
  62. end;
  63.  
  64. end;
  65.  
  66. procedure TForm13.Button1Click(Sender: TObject);
  67. var m,n,x,y:integer; buf:string; k1,k2:integer; need1,need2,need3,need4:integer;
  68. DC: HDC;
  69. item:string;
  70. color1:integer;
  71. bmp:TBitmap;
  72. begin
  73. m:=780;
  74. n:=350;
  75. DC:= GetWindowDC(0);
  76. bmp:=TBitmap.Create;
  77. bmp.Height:=Screen.Height;
  78. bmp.Width:=Screen.Width;
  79. DC:=GetDC(0);
  80. bitblt(bmp.Canvas.Handle, 0, 0, Screen.Width, Screen.Height,DC, 0, 0, SRCCOPY);
  81.  
  82.  
  83. for y:=0 to 5 do begin
  84. for x:=0 to 5 do begin
  85. //SetCursorPos(786+x*100, 350+y*100);
  86. //sleep(500);
  87. color1:=GetRValue(Bmp.Canvas.Pixels[m+x*100, n+y*100])*1000+GetGValue(Bmp.Canvas.Pixels[m+x*100, n+y*100])*100
  88. +GetBValue(Bmp.Canvas.Pixels[m+x*100, n+y*100]);
  89. item:=IntToStr(color1);
  90. case color1 of
  91. 34420:item:='носки';
  92. 274300:item:='дезик';
  93. 40434:item:='бритва';
  94. 253129:item:='шорты';
  95. 47533:item:='тапки';
  96. 263139:item:='шампунь';
  97. end;
  98.  
  99.  
  100. Memo1.Lines.Add(IntToStr(x+1)+' '+IntToStr(y+1)+' '+item);
  101. dat[x+1,y+1]:=item;
  102. end;
  103. end;
  104.  
  105.  
  106. for y := 1 to 6 do for x := 1 to 5 do begin
  107. for k1 := 1 to 6 do for k2 := 1 to 6 do dat2[k1,k2]:=dat[k1,k2];
  108. buf:=dat[x+1,y]; dat2[x,y]:=buf;
  109. buf:=dat[x,y]; dat2[x+1,y]:=buf;
  110. if (chek(dat2)<>0) then begin need1:=x; need2:=y; need3:=x+1; need4:=y; end;
  111. end;
  112.  
  113. for y := 1 to 6 do for x := 2 to 6 do begin
  114. for k1 := 1 to 6 do for k2 := 1 to 6 do dat2[k1,k2]:=dat[k1,k2];
  115. buf:=dat[x-1,y]; dat2[x,y]:=buf;
  116. buf:=dat[x,y]; dat2[x-1,y]:=buf;
  117. if (chek(dat2)<>0) then begin need1:=x; need2:=y; need3:=x-1; need4:=y; end;
  118. end;
  119.  
  120. for y := 2 to 6 do for x := 1 to 6 do begin
  121. for k1 := 1 to 6 do for k2 := 1 to 6 do dat2[k1,k2]:=dat[k1,k2];
  122. buf:=dat[x,y-1]; dat2[x,y]:=buf;
  123. buf:=dat[x,y]; dat2[x,y-1]:=buf;
  124. if (chek(dat2)<>0) then begin need1:=x; need2:=y; need3:=x; need4:=y-1; end;
  125. end;
  126.  
  127. for y := 1 to 5 do for x := 1 to 6 do begin
  128. for k1 := 1 to 6 do for k2 := 1 to 6 do dat2[k1,k2]:=dat[k1,k2];
  129. buf:=dat[x,y+1]; dat2[x,y]:=buf;
  130. buf:=dat[x,y]; dat2[x,y+1]:=buf;
  131. if (chek(dat2)<>0) then begin need1:=x; need2:=y; need3:=x; need4:=y+1; end;
  132. end;
  133.  
  134. SetCursorPos(786+(need1-1)*100, 350+(need2-1)*100); sleep(10);
  135. mouse_event(MOUSEEVENTF_LEFTDOWN,X,Y,0,0); sleep(10); mouse_event(MOUSEEVENTF_LEFTUP,X,Y,0,0);
  136. SetCursorPos(786+(need3-1)*100, 350+(need4-1)*100); sleep(10);
  137. mouse_event(MOUSEEVENTF_LEFTDOWN,X,Y,0,0); sleep(10); mouse_event(MOUSEEVENTF_LEFTUP,X,Y,0,0);
  138.  
  139. //dat[3,3]:='aaa'; dat[3,4]:='aaa'; dat[3,5]:='aaa';
  140. //Memo1.Lines.Add(IntToStr(chek(dat)));
  141.  
  142.  
  143.  
  144. end;
  145.  
  146. procedure TForm13.FormCreate(Sender: TObject);
  147. begin
  148. setlength(dat,8,8);
  149. setlength(dat2,8,8);
  150. end;
  151.  
  152. procedure TForm13.sButton1Click(Sender: TObject);
  153. begin
  154. Timer2.Enabled:=true;
  155. end;
  156.  
  157. procedure TForm13.Timer1Timer(Sender: TObject);
  158. var p: TPoint;
  159. DC: HDC;
  160. begin
  161. GetCursorPos(p);
  162. Edit1.Text:=Format('%d - %d', [p.X, p.Y]);
  163.  
  164. DC:= GetWindowDC(0);
  165. Panel1.Color:= GetPixel(DC, p.X, p.Y);
  166. Edit3.Text:=IntToStr(GetRValue(GetPixel(DC, p.X, p.Y)));
  167. Edit4.Text:=IntToStr(GetGValue(GetPixel(DC, p.X, p.Y)));
  168. Edit5.Text:=IntToStr(GetBValue(GetPixel(DC, p.X, p.Y)));
  169. end;
  170.  
  171. procedure TForm13.Timer2Timer(Sender: TObject);
  172. begin
  173. Button1.Click();
  174. end;
  175.  
  176. procedure TForm13.Timer3Timer(Sender: TObject);
  177. begin
  178. Close();
  179. end;
  180.  
  181. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement