Jump to content
Paradoxium

ActivateClient allows me to click but not type Ingame

Recommended Posts

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]

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by Paradoxium
Link to comment
Share on other sites

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/

Link to comment
Share on other sites

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 by LordJashin
Link to comment
Share on other sites

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.... :D magic!

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...