Paradoxium Posted May 23, 2012 Share Posted May 23, 2012 So I am making a script for an mmorpg called crossfire. Before I could not get the client to recognize clicks but ActivateClient solved that. Now I can click but keystrokes are not recognized...Any advice? I've tried Keydown and Sendkeys... Thanks [sCAR]program Main; var X,Y: Integer; function FindReadys:Boolean; begin Result := FindColorTolerance(X, Y,15137340, 1215, 411, 1235, 435, 20) {and FindColorTolerance( X, Y,16120397, 763, 176, 787, 202,20)}; end; function WaitUntilGameLoads: Boolean; begin Result:= FindColorTolerance(X, Y,5411129, 0, 844, 250, 1049, 20) end; function EndedGame:Boolean; begin Result:= FindColorTolerance(X, Y,14922593,735,241,838,271, 20) end; function Tired:Boolean; begin result:=FindColorTolerance(X, Y,16120397, 1215, 411, 1235, 435, 20) end; procedure GetintoWindow; begin ClickMouse(671,1018,true); //clicks back into client Wait(500); end; procedure Logintogame; begin ActivateClient; GetClientWindowHandle; repeat Wait(500); Writeln('Waiting for others to be ready'); //(waits until other cows are ready) until(FindReadys); MoveMouseSmooth(1203,675); Sendkeys('www'); //ClickMouse(1203,675,true); //clicks start once Writeln('Started Game'); { repeat Wait(500); Writeln('Loading Game...'); //(waits until game loads) until(WaitUntilGameLoads); } end; procedure WalkOver; begin Wait(10000); //ActivateClient; Writeln('Walking over'); //insert keydowns instead of sendarrow waits //ClickMouse(400,400,true); Sendkeys('www'); //walks over to arena side Writeln('Getting into Position'); MoveMouseSmooth(846,502); //sets up postion end; procedure Swinging; begin repeat HoldMouse(846,502,false); Wait(5000 + Random(1000)); until(EndedGame) ; end; begin GetintoWindow; repeat Logintogame; WalkOver; Swinging; until (Tired); end. [/sCAR] Quote Link to comment Share on other sites More sharing options...
Velvet Glam Posted May 23, 2012 Share Posted May 23, 2012 you tried? KeyDown(Key); Wait(35 + Random(40)); KeyUp(Key); maybe u are losing focus every so often? Quote Link to comment Share on other sites More sharing options...
Paradoxium Posted May 23, 2012 Author Share Posted May 23, 2012 you tried? KeyDown(Key); Wait(35 + Random(40)); KeyUp(Key); maybe u are losing focus every so often? yeah I tried that...What do you mean by losing focus? Quote Link to comment Share on other sites More sharing options...
LordJashin Posted May 23, 2012 Share Posted May 23, 2012 So I am making a script for an mmorpg called crossfire. Before I could not get the client to recognize clicks but ActivateClient solved that. Now I can click but keystrokes are not recognized...Any advice? I've tried Keydown and Sendkeys... Thanks [sCAR]program Main; var X,Y: Integer; function FindReadys:Boolean; begin Result := FindColorTolerance(X, Y,15137340, 1215, 411, 1235, 435, 20) {and FindColorTolerance( X, Y,16120397, 763, 176, 787, 202,20)}; end; function WaitUntilGameLoads: Boolean; begin Result:= FindColorTolerance(X, Y,5411129, 0, 844, 250, 1049, 20) end; function EndedGame:Boolean; begin Result:= FindColorTolerance(X, Y,14922593,735,241,838,271, 20) end; function Tired:Boolean; begin result:=FindColorTolerance(X, Y,16120397, 1215, 411, 1235, 435, 20) end; procedure GetintoWindow; begin ClickMouse(671,1018,true); //clicks back into client Wait(500); end; procedure Logintogame; begin ActivateClient; GetClientWindowHandle; repeat Wait(500); Writeln('Waiting for others to be ready'); //(waits until other cows are ready) until(FindReadys); MoveMouseSmooth(1203,675); Sendkeys('www'); //ClickMouse(1203,675,true); //clicks start once Writeln('Started Game'); { repeat Wait(500); Writeln('Loading Game...'); //(waits until game loads) until(WaitUntilGameLoads); } end; procedure WalkOver; begin Wait(10000); //ActivateClient; Writeln('Walking over'); //insert keydowns instead of sendarrow waits //ClickMouse(400,400,true); Sendkeys('www'); //walks over to arena side Writeln('Getting into Position'); MoveMouseSmooth(846,502); //sets up postion end; procedure Swinging; begin repeat HoldMouse(846,502,false); Wait(5000 + Random(1000)); until(EndedGame) ; end; begin GetintoWindow; repeat Logintogame; WalkOver; Swinging; until (Tired); end. [/sCAR] I've encountered this problem before. The losing focus means the window isn't active for the entire time. So you could do MouseClick then SendKeys once somewhere and have it work fine, then later because of focus crap it might not work. I believe it is specific to Windows 7 because that's the only Windows I've encountered it on. For my Windows XP the windows never lose focus and everything works great. One thing you can do, is do ActivateClient before every list of SCAR statements ( commands ). Try using SetDesktopAsClient; that may work because there is no client selected, and no focus issues maybe. Quote Link to comment Share on other sites More sharing options...
Paradoxium Posted May 24, 2012 Author Share Posted May 24, 2012 hmm okay (btw I recognize you from SRL!) anyways yeah nothing working, the client blocks Sendkeys so I'm going to have to stick with mouse movements lol Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted May 24, 2012 Share Posted May 24, 2012 Tried this with the full windows client (not the .jar client) and I was able to send arrow keys and mouse clicks to client. Of course this was after logging in manually. Can't see it behaving differently doing the loigin?? Never tried the .jar as I was never able to successfully login using it. Quote Link to comment Share on other sites More sharing options...
Janilabo Posted May 24, 2012 Share Posted May 24, 2012 Yeah, definitely could be some software blocking SCAR.. (GameGuard for example) See this discussion: http://forums.scar-divi.com/showthread.php?208-ClickMouse-does-not-convince-the-game We can only hope, that Freddy will someday have enough time to add some kernel mode drivers for SCAR, so SCAR would/could work with nearly every game. Quote Link to comment Share on other sites More sharing options...
Paradoxium Posted May 24, 2012 Author Share Posted May 24, 2012 (edited) Tried this with the full windows client (not the .jar client) and I was able to send arrow keys and mouse clicks to client. Of course this was after logging in manually. Can't see it behaving differently doing the loigin?? Never tried the .jar as I was never able to successfully login using it. wait you tried this in ingame crossfire and it worked for you? EDIT: if only kernal worked 0_0 hehe that would be crazy! this BEM sounds interesting too I might take a look at that... Edited May 24, 2012 by Paradoxium Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted May 24, 2012 Share Posted May 24, 2012 wait you tried this in ingame crossfire and it worked for you?Yes. Now let me qualify that. At first I tried using the .JAR client. Unfortunately account creation is buggy as hell using the .JAR and I could not create a character. Next I downloaded the latest CrossFire Windows GTK client. I connected to the crossciv.no-ip.org server and selected the Tutorial as my starting map. Quickly wrote a script that did little more than push a few arrow keys and click on the map. It worked. And that was that. Did not pursue if further. I assume we are talking about the same CrossFire? http://crossfire.real-time.com/ Quote Link to comment Share on other sites More sharing options...
LordJashin Posted May 24, 2012 Share Posted May 24, 2012 (edited) Interesting [1] BEM, definitely something to look at if you ever want to implement silent input or virtual mouse. I remember talking to BenLand about some things. 1. Can you fake mouse events to look like they are coming from your mouse? 2. If you could put your own window around a game with C++ or w/e would mouse events to that window work on the game? I think this is called encapsulation or something? Edit: Crossfire was interesting Edited May 24, 2012 by LordJashin Quote Link to comment Share on other sites More sharing options...
Paradoxium Posted May 24, 2012 Author Share Posted May 24, 2012 Interesting [1] BEM, definitely something to look at if you ever want to implement silent input or virtual mouse. I remember talking to BenLand about some things. 1. Can you fake mouse events to look like they are coming from your mouse? 2. If you could put your own window around a game with C++ or w/e would mouse events to that window work on the game? I think this is called encapsulation or something? Edit: Crossfire was interesting lol i was about to say...yeah no crossfire.z8games.com.. i tried BEM today and x-trap sees it in a flash, yeah so BEM is detected BUT if there was a way to take their virtual keyboard and mouse drivers, implement that to scar.... magic! Quote Link to comment Share on other sites More sharing options...
jhoncito123 Posted June 24, 2013 Share Posted June 24, 2013 compiler error line 160 unknown identifer SetDesktopAsClient ? Quote Link to comment Share on other sites More sharing options...
LordJashin Posted June 24, 2013 Share Posted June 24, 2013 compiler error line 160 unknown identifer SetDesktopAsClient ? You bumped a Year old thread. And now SCAR Divi is much different then when this script was posted. To set the Desktop as the client, now you have to do this: [scar] SetClient(TSCARWindowClient.Create(GetDesktopWindow)); [/scar] Quote Link to comment Share on other sites More sharing options...