Nikromizera Posted February 16, 2016 Share Posted February 16, 2016 The purpose of this script is to locate a game window and click inside this specific game window as a specific location. I was having difficulties with just using the crosshairs because even though SCAR would move to the specified coordinates, it would click on the desktop window instead (as though game client is transparent) even when the game client is selected. Anyways, this is my script and I'm having an error I cant seem to fix. program Autoclicker; var x, y : Integer; Int : Integer; NewClient: TSCARWindowClient; begin NewClient := TSCARWindowClient.Create(FindWindowsEx(GetDesktopWindow, 'Game Window', '', False, False, True)); SetClient(NewClient).Free(); NewClient.Activate(); Int := 0; MoveMouseEx (637, 396, 15); Wait (500 + Random (500)); repeat begin ClickMouseEx(637, 396, mbLeft, 70 + Random(20)); Wait (10 + Random (100)); ClickMouseEx(637, 396, mbLeft, 70 + Random(20)); Wait (2500 + Random (500)); WriteLn('Command run ' + IntToStr(Int) + 'time(s)'); Inc(Int); end; until Int = 900; end. I get error on line 9 with Type Mismatch. Quote Link to comment Share on other sites More sharing options...
Wanted Posted February 17, 2016 Share Posted February 17, 2016 (edited) It's because FindWindowsEx out puts an array while TSCARWindowClient.Create wants just 1 of those values THWNDA: THWNDArray; begin THWNDA := FindWindowsEx(GetDesktopWindow, 'Game Window', '', False, False, True); if (Length(THWNDA) > 0) then NewClient := TSCARWindowClient.Create(THWNDA[0]); If you look at the code hints and or use CTRL+space you'll see one is asking for TSCARWindowClient type while the other is outputting a THWNDArray another way to predict this is to notice it's a plural and or Ex function FindWindow(s)(Ex) Edited February 17, 2016 by Wanted Quote Link to comment Share on other sites More sharing options...