Search the Community
Showing results for tags 'client'.
-
I have written a script that works with one client window and I was trying to branch it out to handle more than one. Here is a sample of what I am doing... Simplified... I get runtime errors when calling a procedure with a different client (ColorSomething in this example). Hope this makes sense.... program new; var Wnds: THwndArray; Client1,Client2 : TSCARWindowClient; // 2 clients Client1Width, Client1Height : Integer; Client2Width, Client2Height : Integer; RatioX1,RatioX2,RatioY1,RatioY2 : Single; const ColorTol : 2; Color : 123456; // used to create a tbox that focuses on a certain area of a windows and adjusts for size. function CreateTBox(X,Y : Integer; RX1,RY1,RX2,RY2 : Single) : TBox; var tb : TBox; X1,X2,Y1,Y2 : Integer; begin X1 := Floor(X * RX1); X2 := Floor(X * RX2); Y1 := Floor(Y * RY1); Y2 := Floor(Y * RY2); tb := Box(X1,Y1,X2,Y2); Result := tb; end; // sample procedure to look for a color and do something procedure ColorSomething(Client : TSCARWindowClient; tb : TBox) : Boolean; var X,Y : Integer; begin Client.Activate; Client.ClientArea := True; FindColorTol(X,Y,Color,tb.X1,tb.Y1,tb.X2,tb.Y2,ColorTol); MoveMouse(X,Y); // Do Some Stuff end; procedure SetupClient1; begin Wnds := FindWindowsPreg(GetDesktopWindow,Client1Title,'', False); Client1 := TSCARWindowClient.Create(Wnds[0]); SetClient(Client1).Free(); Client1.Activate; Client1.ClientArea := True; Client1Width := Client1.ImageArea.X2 + 1; Client1Height := Client1.ImageArea.Y2 + 1; end; procedure SetupClient2; begin Wnds := FindWindowsPreg(GetDesktopWindow,Client2Title,'', False); Client2 := TSCARWindowClient.Create(Wnds[0]); SetClient(Client2).Free(); Client2.Activate; Client2.ClientArea := True; Client2Width := Client2.ImageArea.X2 + 1; Client2Height := Client2.ImageArea.Y2 + 1; end; procedure SetupBoxes; begin Client1TB := CreateTBox(Client1Width,Client1Height,RatioX1,RatioY1,RatioX2,RatioY2); Client2TB := CreateTBox(Client2Width,Client2Height,RatioX1,RatioY1,RatioX2,RatioY2); end; begin RatioX1 := 0.2; RatioY1 := 0.2; RatioX2 := 0.8; RatioY2 := 0.8; SetupClient1; SetupClient2; SetupRatios; SetupBoxes; ColorSomething(Client1,Client1TB); ColorSomething(Client2,Client2TB); ColorSomething(Client1,Client1TB); end.