Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Gaming Tutorial


  • Please log in to reply
13 replies to this topic
System Monitor
  • Members
  • 508 posts
  • Last active: Mar 26 2012 05:13 AM
  • Joined: 09 Mar 2007
I have decided to work on making a gaming tutorial, much like the Quick Start Tutorial. Any help/criticism will be greatly appreciated!

Gaming Tutorial
If any of your questions are not answered here go to
Quick-start Tutorial
Alphabetical Command List for AutoHotkey
Hotkey Labels for keys such as shift and control

You may wish to wait if the window that your game is in is open. It is very simple to do. WinWait will wait to the window is open and #IfWinActive will run if you are in the window. Then you type the title of the window.
#IfWinActive,CoD2

One of the most important functions is Random. It is very Simple to use.

Random,a,1,10
Msgbox,%a%
; Generates a random number 1-10 put your min and max numbers after Random, a is the varible
;a comment is started by ";"

Click is probably the most used, but you need to have a sleep command between Clicks that is preferably random so macro detection is less likely. Sleep time is measured in Milliseconds. You can also hold down the mouse button.We will now combine all of our skillz to make a simple Program that clicks in a random box.
Random, a ,500,520
Random, b, 700,720
Random,c ,1000,2000
Click down,left,%a%,%b% ; clicks and holds
sleep,%c%; will sleep for 1-2 seconds
Click up,left ; releases the mouse button
Click,left,%a%,%b%

Loop is a very simple function, it will repeat something multiple times. You state loop and then how many times you want to loop. If you wish for an infinite loop then just write loop, but if it is infinite you might want a hotkey to stop it. You may also want a hotkey to start the loop. You also can break the loop by adding a hotkey
F1::   ; pressing F1 will start the loop
loop, 150 ; will loop 150 times
{
Random, a ,500,520
Random, b, 700,720
Random,c ,1000,2000
Click,left,%a%,%b%
sleep,%c%; will sleep for 1-2 seconds
Click,left,%a%,%b%
F2::break ; will quit the loop once you press F2
}
ESC::Exitapp ; if you press escape it will close the application

PixelGetColor will get the color of a pixel.This can be useful when you want to click on something that is a certain color. To get the color of the pixel where your cursor is you need the command MouseGetPos. First you need to type MouseGetPos, Second you need to state the output variable for the x coordinate and the y coordinate, And the same for PixelGetColor.
F1:: ; Pressing f1 will find the color
MouseGetPos,x,y
PixelGetColor,%x%,%y% ; a %[i]varible[/i]% declares/uses a varible
MsgBox,The x color is %x% and the y is %y% ; Creates a message box and text

Now that you have the color, you can search for the color using PixelSearch. First you type PixelSearch(always declare the Command name) then the x and y coordinates that it was found at, and the x y coordinates of the top left part of the box to search and then the lower right coordinates( if you wish to search the whole screen 0,0 and use the built in variables %A_ScreenWidth%,%A_ScreenHeight%) and the color, finally add fast at the end to improve CPU usage.
F1::
PixelSearch, x, y, 0, 0, %A_ScreenWidth%,%A_ScreenHeight% , 0x0000, Fast
Click,%x%,%y%

Thats it.

NotLoggedIn-Conquer
  • Guests
  • Last active:
  • Joined: --
You should also cover how some games only accept certain send modes.

engunneer
  • Moderators
  • 9162 posts
  • Last active: Sep 12 2014 10:36 PM
  • Joined: 30 Aug 2005
and sometimes needs a sleep between the click down and click up.

I think the gaming tutorial should also be on the wiki, so others can add examples.

abcyourway
  • Guests
  • Last active:
  • Joined: --
Plus, you should mention that users have to check out game protection software.
If the games are running with GameGuard, Xtrap, hackshield, etc., No send method including controlsend, postmessage will work.
I should say "All possible method you coud use" is history with them.

System Monitor
  • Members
  • 508 posts
  • Last active: Mar 26 2012 05:13 AM
  • Joined: 09 Mar 2007
i will but i am "working"(at camp) a lot and may take time to develop.
Thank you! :p

Grumpy
  • Guests
  • Last active:
  • Joined: --
It needs also to reply to VFAQ:
- How do I loop on an action?
- How do I stop such a loop?
  Common sub-requests:
  . I want to start the loop when hitting a key, and stop when hitting another key
  . I want to start the loop when hitting a key, and stop when hitting it again
  . I want to run the loop when I depress a key and stop it when I release it
Giving a definitive answer to these requests in a place easy to point to would answer something like 90% of requests of newbies wanting to use AHK in a game...

System Monitor
  • Members
  • 508 posts
  • Last active: Mar 26 2012 05:13 AM
  • Joined: 09 Mar 2007
i am not very familiar with wiki so if someone could please do that it would be nice. I added the "code" at the top

joeldg
  • Members
  • 1 posts
  • Last active: Sep 19 2007 09:29 PM
  • Joined: 19 Sep 2007

Plus, you should mention that users have to check out game protection software.
If the games are running with GameGuard, Xtrap, hackshield, etc., No send method including controlsend, postmessage will work.
I should say "All possible method you coud use" is history with them.


(first off, sorry for necro-posting)

this is not entirely true..
I have found with x-trap that it will accept input from ahk scripts for about one second.. if you compile the script, then you only have one second, ever but using right-click->run script the scripts will run..

so, you can build an app that runs ahk scripts (not compiled) from a directory and each script just sends one thing..

I have not torn apart the executables (yet) but am guessing that x-trap has a set of defined "allowed" programs it runs and needs to take a sec to determine if a program is doing something funny. ahk scripts as far as I know are compiled in a temporary directory each time (unless pre-compiled) which would explain this behavior.

This is a crappy workaround and you will not have 100% success with it.
perhaps 60%-70% success but for what I am doing that is mostly acceptable.

* just using this in an x-trap game to pick up dropped loot while I am at work.. :)

System Monitor
  • Members
  • 508 posts
  • Last active: Mar 26 2012 05:13 AM
  • Joined: 09 Mar 2007
Cool!
If i knew how to take apart .exe i would look in to it, but i am not sure, if anyone knows how please say, i would like to learn!

Superfraggle
  • Members
  • 1019 posts
  • Last active: Sep 25 2011 01:06 AM
  • Joined: 02 Nov 2004
I saw a post that allows gameguard to be bypassed by renaming the excutable.

Try this.

http://www.autohotke...light=gameguard
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle

dwinar
  • Members
  • 10 posts
  • Last active: Sep 17 2009 09:28 AM
  • Joined: 05 Sep 2009

PixelGetColor will get the color of a pixel.This can be useful when you want to click on something that is a certain color. To get the color of the pixel where your cursor is you need the command MouseGetPos. First you need to type MouseGetPos, Second you need to state the output variable for the x coordinate and the y coordinate, And the same for PixelGetColor.

F1:: ; Pressing f1 will find the color
MouseGetPos,x,y
PixelGetColor,%x%,%y% ; a %[i]varible[/i]% declares/uses a varible
MsgBox,The x color is %x% and the y is %y% ; Creates a message box and text


Why no one posted that's not working and returns error: "PixelGetColor requires at least 3 parameters"?

It should be something like this:
F1::
MouseGetPos, MouseX, MouseY
PixelGetColor, color, %MouseX%, %MouseY%
MsgBox The color at the current cursor position is %color%. ; and the color is determined by this "third" parameter not by x and y which are *coordinates*not color
return




EDIT:

Loop is a very simple function, it will repeat something multiple times. You state loop and then how many times you want to loop. If you wish for an infinite loop then just write loop, but if it is infinite you might want a hotkey to stop it. You may also want a hotkey to start the loop. You also can break the loop by adding a hotkey

F1::   ; pressing F1 will start the loop
loop, 150 ; will loop 150 times
{
Random, a ,500,520
Random, b, 700,720
Random,c ,1000,2000
Click,left,%a%,%b%
sleep,%c%; will sleep for 1-2 seconds
Click,left,%a%,%b%
F2::break ; will quit the loop once you press F2
}
ESC::Exitapp ; if you press escape it will close the application


I am not an uber-pro-autohotkey-mastah, but even I see that something is wrong here... I tried this "loop" and it doesn't work as a loop. It moves cursor ONE time and then it automatically EXITs. "F2::break" isn't a good idea I think. Can someone explain how to make it properly? I really would like to know how to make *working* loop.

R3TR0
  • Members
  • 39 posts
  • Last active: Sep 05 2016 07:02 PM
  • Joined: 26 Aug 2009
Why loop, for my quake live autofire I used While which is so much nicer

look at this

setkeydelay, 0
~Mbutton::
While GetKeyState("MButton")
{
mousegetpos, mx, my
pixelgetcolor, ggaf, %mx%, %my%
IF (ggaf=0xFFFFFF)
send {Lbutton}
}


dwinar
  • Members
  • 10 posts
  • Last active: Sep 17 2009 09:28 AM
  • Joined: 05 Sep 2009
That's look really cool but the autofire isn't what I'm looking for. I'm just sad that someone is making tutorial full of bugs. How newbies can learn if something what got on Wiki isn't working?

jaco0646
  • Moderators
  • 3165 posts
  • Last active: Apr 01 2014 01:46 AM
  • Joined: 07 Oct 2006
I haven't looked at any of the code here, but please note that this topic is over 2 years old. AutoHotkey has had many updates in that time.