AutoHotkey Community

It is currently May 25th, 2012, 11:57 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Gaming Tutorial
PostPosted: July 19th, 2007, 10:52 pm 
Offline

Joined: March 9th, 2007, 2:47 am
Posts: 509
Location: Unknown
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.
Code:
#IfWinActive,CoD2


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

Code:
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.
Code:
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
Code:
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.
Code:
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.
Code:
F1::
PixelSearch, x, y, 0, 0, %A_ScreenWidth%,%A_ScreenHeight% , 0x0000, Fast
Click,%x%,%y%


Thats it.


Last edited by System Monitor on March 16th, 2008, 1:09 am, edited 18 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 20th, 2007, 8:52 pm 
You should also cover how some games only accept certain send modes.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 20th, 2007, 9:53 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8647
Location: Salem, MA
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.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 21st, 2007, 2:38 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 23rd, 2007, 4:41 am 
Offline

Joined: March 9th, 2007, 2:47 am
Posts: 509
Location: Unknown
i will but i am "working"(at camp) a lot and may take time to develop.
Thank you! :P


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 23rd, 2007, 11:12 am 
It needs also to reply to VFAQ:
Code:
- 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...


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 24th, 2007, 4:25 am 
Offline

Joined: March 9th, 2007, 2:47 am
Posts: 509
Location: Unknown
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject: ...
PostPosted: September 19th, 2007, 6:05 pm 
Offline

Joined: September 19th, 2007, 5:59 pm
Posts: 1
Location: nyc
abcyourway wrote:
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.. :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 22nd, 2007, 9:02 pm 
Offline

Joined: March 9th, 2007, 2:47 am
Posts: 509
Location: Unknown
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 22nd, 2007, 11:38 pm 
Offline

Joined: November 2nd, 2004, 2:43 pm
Posts: 1019
Location: London, UK
I saw a post that allows gameguard to be bypassed by renaming the excutable.

Try this.

http://www.autohotkey.com/forum/viewtopic.php?t=14332&start=0&postdays=0&postorder=asc&highlight=gameguard

_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: Gaming Tutorial
PostPosted: September 5th, 2009, 8:59 pm 
Offline

Joined: September 5th, 2009, 3:45 pm
Posts: 10
System Monitor wrote:
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.
Code:
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:
Code:
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:

System Monitor wrote:
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
Code:
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 6th, 2009, 3:50 pm 
Offline

Joined: August 26th, 2009, 11:15 pm
Posts: 38
Location: Canada
Why loop, for my quake live autofire I used While which is so much nicer

look at this

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 6th, 2009, 5:51 pm 
Offline

Joined: September 5th, 2009, 3:45 pm
Posts: 10
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 6th, 2009, 8:21 pm 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 7th, 2009, 3:33 pm 
Offline

Joined: September 5th, 2009, 3:45 pm
Posts: 10
That's a shame... I didn't notice that :/ Anyway if you're right, the old system of loop breaking was simple and awesome... And now I have problem with it and no one wants (or can) to help.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Morpheus and 5 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group