Program Malovani; // pý¡klad pou§it¡ extern¡ch funkc¡ ze syst. knihoven Windows const uroven = 99; opakovani = 130; penwidth = 50; klik_str = "Klikni nebo stiskni kl vesu..."; final_str = "Konec makra"; type POINT = record x, y : integer end; type PPOINT = ^POINT; type Hwnd = integer; type Hdc = integer; type Handle = integer; type str100 = string[100]; function SetWindowPos(h_wnd, h_wnAfter: Hwnd; x, y, cx, cy, flags: integer): boolean; external 'USER32.DLL' name 'SetWindowPos'; function ShowWindow(h_wnd: Hwnd; cmd: integer): boolean; external 'USER32.DLL' name 'ShowWindow'; function GetCurrentTime: integer; external 'USER32.DLL' name 'GetCurrentTime'; function GetInputState: boolean; external 'USER32.DLL' name 'GetInputState'; function GetActiveWindow: Hwnd; external 'USER32.DLL' name 'GetActiveWindow'; function GetWindowDC(h_wnd: Hwnd): integer; external 'USER32.DLL' name 'GetWindowDC'; function ReleaseDC(h_wnd: Hwnd; dc: Hdc): integer; external 'USER32.DLL' name 'ReleaseDC'; function TextOut(h_dc: Hdc; x, y: integer; var s: const str100; len: integer): boolean; external 'GDI32.DLL' name 'TextOutA'; function CreatePen(penStyle, width, crColor: integer): integer; external 'GDI32.DLL' name 'CreatePen'; function DeleteObject(hObject: Handle): boolean; external 'GDI32.DLL' name 'DeleteObject'; function SelectObject(dc: Hdc; hGdiObj: Handle): integer; external 'GDI32.DLL' name 'SelectObject'; function MoveToEx(dc: Hdc; x, y: integer; lppoint: PPOINT): boolean; external 'GDI32.DLL' name 'MoveToEx'; function LineTo(dc: Hdc; x, y: integer): boolean; external 'GDI32.DLL' name 'LineTo'; var i, j, is, js, k, l: integer; seed: integer; str: str100; d_start: date; t_start: time; wnd: Hwnd; dc: Hdc; hpen, hpenOld: Handle; function Random(mez: short): short; const c1 = 13849; c2 = 27181; c3 = 65536; var pom: integer; begin seed:= (c1 + (c2 * seed)) mod c3; pom:= Round(seed / (65536 / mez)); if pom = 0 then pom:= 1; Random:= pom; end; function RGB(r,g,b: short): integer; begin RGB:= (b*256 + g)*256 + r; end; function konec: boolean; const Miliseconds = 3000; var dt: date; tm: time; limit: boolean; begin dt:= Today; tm:= Now; limit:= Day(dt) <> Day(d_start); if not limit then limit:= tm - t_start > Miliseconds; konec:= limit and GetInputState; end; begin d_start:= Today; t_start:= Now; seed:= Seconds(t_start); wnd:= GetActiveWindow; dc:= GetWindowDC(wnd); hpen:= CreatePen(0, Random(penwidth), RGB(Random(255), Random(255), Random(255))); hpenOld:= SelectObject(dc, hpen); k:= 0; i:= 10; j:= 10; is:= Random(uroven); js:= Random(uroven); repeat if (i + is > 640) or (i + is < 0) then begin SelectObject(dc, hpenOld); DeleteObject(hpen); hpen:= CreatePen(0, Random(penwidth), RGB(Random(255), Random(255), Random(255))); hpenOld:= SelectObject(dc, hpen); if is > 0 then is:= -Random(uroven) else is:= Random(uroven); end; if (j + js > 480) or (j + js < 0) then begin SelectObject(dc, hpenOld); DeleteObject(hpen); hpen:= CreatePen(0, Random(penwidth), RGB(Random(255), Random(255), Random(255))); hpenOld:= SelectObject(dc, hpen); if js > 0 then js:= -Random(uroven) else js:= Random(uroven); end; MoveToEx( dc, i, j, NIL); inc(i, is); inc(j, js); LineTo( dc, i, j); inc(k); if (k mod opakovani = 0) and not GetInputState then begin str := klik_str; TextOut(dc, Random(600), Random(400), str, Strlength(str)); end; until konec; SelectObject(dc, hpenOld); DeleteObject(hpen); ReleaseDC(wnd, dc); /* SetWindowPos(wnd, 1,0,0,0,0, 1 or 2); SetWindowPos(wnd, 0,0,0,0,0, 1 or 2 or 64);*/ ShowWindow(wnd, 2); ShowWindow(wnd, 3); Info_box("", final_str); end.