AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Gaming Tutorial
Goto page 1, 2  Next
 
Reply to topic    AutoHotkey Community Forum Index -> General Chat
View previous topic :: View next topic  
Author Message
System Monitor



Joined: 09 Mar 2007
Posts: 509
Location: Unknown

PostPosted: Thu Jul 19, 2007 9:52 pm    Post subject: Gaming Tutorial Reply with quote

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 Sun Mar 16, 2008 12:09 am; edited 18 times in total
Back to top
View user's profile Send private message Visit poster's website
NotLoggedIn-Conquer
Guest





PostPosted: Fri Jul 20, 2007 7:52 pm    Post subject: Reply with quote

You should also cover how some games only accept certain send modes.
Back to top
engunneer



Joined: 30 Aug 2005
Posts: 8255
Location: Maywood, IL

PostPosted: Fri Jul 20, 2007 8:53 pm    Post subject: Reply with quote

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.
_________________

(Common Answers)
Back to top
View user's profile Send private message Visit poster's website
abcyourway
Guest





PostPosted: Sat Jul 21, 2007 1:38 pm    Post subject: Reply with quote

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.
Back to top
System Monitor



Joined: 09 Mar 2007
Posts: 509
Location: Unknown

PostPosted: Mon Jul 23, 2007 3:41 am    Post subject: Reply with quote

i will but i am "working"(at camp) a lot and may take time to develop.
Thank you! Razz
Back to top
View user's profile Send private message Visit poster's website
Grumpy
Guest





PostPosted: Mon Jul 23, 2007 10:12 am    Post subject: Reply with quote

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...
Back to top
System Monitor



Joined: 09 Mar 2007
Posts: 509
Location: Unknown

PostPosted: Tue Jul 24, 2007 3:25 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
joeldg



Joined: 19 Sep 2007
Posts: 1
Location: nyc

PostPosted: Wed Sep 19, 2007 5:05 pm    Post subject: ... Reply with quote

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.. Smile
Back to top
View user's profile Send private message
System Monitor



Joined: 09 Mar 2007
Posts: 509
Location: Unknown

PostPosted: Sat Sep 22, 2007 8:02 pm    Post subject: Reply with quote

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!
Back to top
View user's profile Send private message Visit poster's website
Superfraggle



Joined: 02 Nov 2004
Posts: 1019
Location: London, UK

PostPosted: Sat Sep 22, 2007 10:38 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message MSN Messenger
dwinar



Joined: 05 Sep 2009
Posts: 10

PostPosted: Sat Sep 05, 2009 7:59 pm    Post subject: Re: Gaming Tutorial Reply with quote

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.
Back to top
View user's profile Send private message
R3TR0



Joined: 26 Aug 2009
Posts: 38
Location: Canada

PostPosted: Sun Sep 06, 2009 2:50 pm    Post subject: Reply with quote

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}
}
Back to top
View user's profile Send private message
dwinar



Joined: 05 Sep 2009
Posts: 10

PostPosted: Sun Sep 06, 2009 4:51 pm    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
jaco0646



Joined: 07 Oct 2006
Posts: 3113
Location: MN, USA

PostPosted: Sun Sep 06, 2009 7:21 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Visit poster's website
dwinar



Joined: 05 Sep 2009
Posts: 10

PostPosted: Mon Sep 07, 2009 2:33 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> General Chat All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group