Jump to content
Sign in to follow this  
blckpythn

Clicking within a game.

Recommended Posts

blckpythn

Alright, so I'm having some trouble getting the following script to work within a game(single-player).

HotKeySet("{F4}", "Pixelchecker")
HotKeySet("{F5}", "On_Exit")

While 1
    Sleep(10)
WEnd

Func Pixelchecker()
    $pixelcheck = PixelChecksum(715, 455, 725, 445, Default, "[ACTIVE]")
    ConsoleWrite("Entering waiting loop" & @CRLF)
    While $pixelcheck = PixelChecksum(715, 455, 725, 445, Default, "[ACTIVE]")
        Sleep(25)
    WEnd
    MouseClick("primary", 720, 450, 1, 0)
    ConsoleWrite("Clicked" & @CRLF)
EndFunc   ;==>Pixelchecker

Func On_Exit()
    Exit
EndFunc   ;==>On_Exit

Would this be due to the game stealing the inputs from the script or what?

Edited by blckpythn

Share this post


Link to post
Share on other sites
Neno

Can you please tell exactly what it is you're trying to accomplish... within this singleplayer game? :idea:

Share this post


Link to post
Share on other sites
blckpythn

I'm trying to Snipe someone when they walk across my crosshairs. Difficult level

Share this post


Link to post
Share on other sites
Neno

I'm trying to Snipe someone when they walk across my crosshairs. Difficult level

Ah, k. That's easy. I don't know why you're doing a pixelchecksum though, why not a pixelsearch?

Also, you're using static definitions for your checksum, even if you just wanted the gun to fire. Here's a hand:

HotKeySet("{F4}", "Pixelchecker")
HotKeySet("{F5}", "On_Exit")
While 1
    Sleep(10)
WEnd
Func Pixelchecker()
    While 1
        $pos = MouseGetPos ()
        $pixelcheck = PixelChecksum($pos[0] - 5, $pos[1] - 5, $pos[0] + 5, $pos[1] + 5, Default, "[ACTIVE]")
        Sleep(25)
        If $pixelcheck <> 0 Then ExitLoop
    WEnd
    MouseClick("Left")
EndFunc   ;==>Pixelchecker
Func On_Exit()
    Exit
EndFunc   ;==>On_Exit

Now it will check 5 pixels in every direction directly over your mouse.

Share this post


Link to post
Share on other sites
blckpythn

The reason why it is in absolute values(middle of my screen)is because the game is fullscreen and takes mouse control. But it still doesn't seem to want to work.

Also your script doesn't seem to check the checksum for changes, only whether or not it is zero.

And the default mouse movement is too slow that's why I have MouseClick("primary", 720, 450, 1, 0)

Edited by blckpythn

Share this post


Link to post
Share on other sites
Neno

and your script doesn't seem to check the checksum for changes, only whether or not it is zero.

If $pixelcheck <> 0 is checking for changes. <> is Not Equal. Failure of a checksum returns zero (0)

I kind of also thought you were playing a flash game.... Full screen FPS's screw with mouse coords, and any kind of reliable coordinate mode is sort of unsupported in directx or opengl.

Share this post


Link to post
Share on other sites
blckpythn

Ok its not checking for changes, its only checking whether or not it was capable of making a checksum.

Share this post


Link to post
Share on other sites
Neno

Ok. I see what you're saying. Apologies, I don't ever use pixelchecksum. Basically you'll need to have to have to the checksum of what you're... well.. checking for to compare it with.

Func Pixelchecker()
    $pos = MouseGetPos ()
    while 1
        While $pixelcheck = PixelChecksum($pos[0] - 5, $pos[1] - 5, $pos[0] + 5, $pos[1] + 5, Default, "[ACTIVE]")
            Sleep(25)
        WEnd
        If $pixelcheck >= *your variable?* Then
            MouseClick("Left")
            ExitLoop
        EndIf
    WEnd

EndFunc   ;==>Pixelchecker
Edited by Neno

Share this post


Link to post
Share on other sites
blckpythn

No, the original checksum in my script is fine. That's not the issue. The issue is that it won't work with a fullscreen program for some reason.

Share this post


Link to post
Share on other sites
Neno

No, the original checksum in my script is fine. That's not the issue. The issue is that it won't work with a fullscreen program for some reason.

That's because the game designer is probably blocking pseudo key-clicks, which, coincidentally is probably a red flag not to do what you're trying to do.

Share this post


Link to post
Share on other sites
JohnOne

Your checksum will always be the same because you are not even giving it a proper rectangle.

Infact nothing much you are saying makes much sense at all, "Its checking if its capable of checking" etc.

What is the game, and what are you really trying to do ?

You might not get help if you tell the truth but you are wasting everybodies time with otherwise.

Also why try to use a window handle in full screen mode, surely you want absolute coordinates.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
blckpythn

That's because the game designer is probably blocking pseudo key-clicks, which, coincidentally is probably a red flag not to do what you're trying to do.

It doesn't break the ToS, its an open source game.

Your checksum will always be the same because you are not even giving it a proper rectangle.Infact nothing much you are saying makes much sense at all, "Its checking if its capable of checking" etc.What is the game, and what are you really trying to do ?You might not get help if you tell the truth but you are wasting everybodies time with otherwise. Also why try to use a window handle in full screen mode, surely you want absolute coordinates.

It is a proper rectangle, unless you can prove otherwise. Its checking whether it retrieves a checksum or fails. I'm trying pretty much any parameter to see if there is a difference.

Share this post


Link to post
Share on other sites
Neno

It doesn't break the ToS, its an open source game.

What game?

-------------

Also, I can tell you right now that in a FPS your script will always fail to do what you want. You really can't use absolute coords when the mouse is locked.

Share this post


Link to post
Share on other sites
blckpythn

What game?

-------------

Also, I can tell you right now that in a FPS your script will always fail to do what you want. You really can't use absolute coords when the mouse is locked.

http://www.alientrap.org/nexuiz/

Share this post


Link to post
Share on other sites
czardas

Telling someone how to automate a single player game is not much different from telling everyone, who reads this forum, how to automate a multiplayer game. I suggest you avoid asking questions like this.

Share this post


Link to post
Share on other sites
blckpythn

Telling someone how to automate a single player game is not much different from telling everyone, who reads this forum, how to automate a multiplayer game. I suggest you avoid asking questions like this.

Regardless of whether or not its for a game, what would stop it from continuing

Share this post


Link to post
Share on other sites
czardas

Regardless of whether or not its for a game, what would stop it from continuing

I only mentioned it for your benefit. The developers of AutoIt have made their position clear on the automation of games for a very simple reason. It gives AutoIt bad publicity, which also has other negative effects. While your intentions may be genuine, I am sure you will appreciate that others may wish to exploit AutoIt for uses other than those which it was intended. Therefore it is within everyones best interest to avoid discussing certain subjects: this being one of them.

Share this post


Link to post
Share on other sites
Neno

Regardless of whether or not its for a game, what would stop it from continuing

Didn't we both answer your question?

edit:

Let me be more frank. Most "fullscreen" games as you like to call it, and FPS's lock the mouse -- usually it's in the center, but some game devs love screwing with cheaters, and sometimes lock it off the screen or somewhere completely random.

Unless I know *what* it is you're trying to do, exactly, it's very unlikely I can help you.

Edited by Neno

Share this post


Link to post
Share on other sites
jebus495

What exactly do you want your script to do?

What pixelchecksum does is essentially add of the value of every pixel in a given rectangle.

You normally compare the sum of pixels in the same area to determine if something has changed. It will return with a change even if only 1 pixel changes.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×