Writing a script

Ask gaming related questions (AHK v1.1 and older)
Pacifista
Posts: 46
Joined: 17 Jan 2022, 16:17

Writing a script

Post by Pacifista » 11 Aug 2022, 20:03

Hello

Tried

Code: Select all

MouseGetPos, xpos, ypos 
MsgBox, The cursor is at X%xpos% Y%ypos%.
Seems 2560x1440 resolution, the center is naturally 1280x720


Someone suggested this method
"Loop PixelGetColor and Click whenever ur If condition is satisfied"


Code: Select all

Loop PixelGetColor, 
{
    if (color, %MouseX%=1280, %MouseY%=720, fb4a23=true)
sendkey, LMbutton          
return
f
umm how do i write better? i keep asking and a cool senior dude is writing it for me here but i don't feel fine by being a freeloader.

User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: Writing a script

Post by mikeyww » 11 Aug 2022, 20:10

This is pseudocode at best; you will not be able to make up your own syntax with AHK. Perhaps you can explain what the script should do. The documentation is also helpful with syntax, detailed descriptions, and even examples, for every command and function. You might also consider firing the cool senior dude. :lol:

Code: Select all

x      := A_ScreenWidth  / 2
y      := A_ScreenHeight / 2
target := 0x234AFB ; Blue-green-red
CoordMode, Mouse
CoordMode, Pixel
MouseMove, x, y
Loop {
 Sleep, 100
 PixelGetColor, bgr, x, y
 ToolTip, %bgr%
 If (bgr != target)
  Continue
 Click
 SoundBeep, 1500
}
Esc::ExitApp
People on this forum write scripts, so when you post a subject for your thread, summarize the problem that you are having, instead of stating that you are writing a script. An example could be, "Click when target color is found". Another approach can be to search the forum, to see if someone else has already posted the script that you need. There are probably at least a hundred posted scripts like this one (maybe a thousand). :)

Code: Select all

x      := A_ScreenWidth  / 2
y      := A_ScreenHeight / 2
target := 0x234AFB ; Blue-green-red
CoordMode, Mouse
CoordMode, Pixel
MouseMove, x, y
Loop {
 Sleep, 100
 PixelGetColor, bgr, x, y
 ToolTip, %bgr%
 SoundBeep, 1900
} Until (bgr = target)
Click
ToolTip
MsgBox, 64, Done, Done!
Return
Esc::ExitApp

Pacifista
Posts: 46
Joined: 17 Jan 2022, 16:17

Re: Writing a script

Post by Pacifista » 12 Aug 2022, 06:53

Thank you sir. The purpose is to shoot when the reticle turns to red. The dot is in the center.

This script you've prepared is detecting the red dot at 1280-720 and shoots?

it only has to detect the red at the center.

there is only need to beep sound for the knowing if the script is enabled or not.

User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: Writing a script

Post by mikeyww » 12 Aug 2022, 07:10

It will click when the color is found at the coordinates. You can try it and adjust it as you wish.

Post Reply

Return to “Gaming Help (v1)”