Jump to content

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

Find Colour and Coordinates at Mouse


  • Please log in to reply
17 replies to this topic
Sanctus
  • Members
  • 283 posts
  • Last active: Dec 06 2014 04:05 PM
  • Joined: 30 Nov 2012

Version: 1.03 (Last Updated: 31.4.2014)

 

I decided to share a script I made to help me with making my Gaming Scripts,

I tweaked it a little bit to make it a lot more user friendly wink.png.

 

You can find All my "Released" Scripts here (will be updated soon)

 

Here's the Position Script Revisioned:

#SingleInstance force
menu, tray, add 
menu, tray, add, Made By Sanctus, MadeBy
Menu, Tray, Tip, PositionInfo v1.03`nMade by Sanctus
return

!x::
MouseGetPos, PosX, PosY
PixelGetColor, cRGB , %PosX%, %PosY%,RGB
PixelGetColor, cBGR , %PosX%, %PosY%
WinGetPos,,, w, h, A
gui, new
gui, Default
gui, +LastFound +LabelMyGui
gui, add, groupbox, w205 h330, Info found at Mouse Position
gui, font, s12, Arial
gui, add, text, xm12 ym20 section, MousePos X: 
gui, add, text, xp+110 yp, %PosX%
gui, add, text, xp-110 yp+15, MousePos Y: 
gui, add, text, xp+110 yp, %PosY%
gui, add, text, xp-110 yp+15, BGR Colour: 
gui, add, text, xp+110 yp, %cBGR%
gui, add, text, xp-110 yp+15, RGB Colour: 
gui, add, text, xp+110 yp, %cRGB%
gui, font, s8, Arial
gui, add, button, xp-70 yp+17.5 w100 h20 gClip, Copy X and Y
gui, add, button, xp yp+20.5 w100 h20 gClipColor, Copy Colour
gui, font, s12, Arial
gui, add, button, xp+30 yp+25 gDone, OK
gui, add, Progress, xp-7.5 yp+35 w50 h50 c%cRGB%,100
gui, font, s10, Verdana
gui, add, text, yp+40 xp-65, Version: 1.03 (31.03.2014)
gui, add, text, xp+10 yp+20.5, Window Size: %w% x %h%
gui, add, button, xp-10 yp+20.5 w180 h20 gWS, Copy Window Size
gui, add, button, xp yp+20.5 w180 h20 gARF, Copy ARFormula
gui, add, button, xp yp+20.5 w180 h40 gARFB, Copy ARFormula with Border Calculations
gui, show,, Position/Colour of X&Y
return
Done:
{
gui,submit,nohide
gui, destroy
return
}
Clip:
{
clipboard = %PosX% %PosY%
return
}
ClipColor:
{
clipboard = %cBGR%
return
}
WS:
{
clipboard = %w% %h%
return
}
ARF:
{
clipboard = % "% Round(" . PosX . " / (" . w . " / w)) % Round(" . PosY . " / (" . h . " / h))"
return	
}
ARFB:
{
clipboard = % "% Round(" . PosX . " / (" . w . " / (w - i))) + l % Round(" . PosY . " / (" . h . " / (h - j))) + k"
return	
}
return

MadeBy:
Run http://tus.web1337.net/
return

F7::Reload
F8::ExitApp

How it works:

  • Position your mouse cursor inside a game/program or just on the desktop.
  • Press Alt + x to get a pop-up displaying the Coordinates and BGR/RGB colour of that location.
  • You can redo that as many times as you want (do not need to close the window).
  • Press Esc to Close all active windows of the application.
  • Press F8 to Exit the Application (Closes all the Windows)
  • Always use the BGR colour by default, ahk doesn't use RGB innately.

Any Resolution Solution:

  • Make sure that anytime your running code with anyres formula to also run 
    WinGetPos,,, w, h, A
  • To get the active window width and height
  • Check if the application will always run fullscreen borderless or if it will always run without borders (league of legends for example)
  • If that is the case then use the Simple ARFormula heres an example
  • MouseClick, Left, % Round(538 / (1280 / w)), % Round(447 / (800 / h))
  • If the user has the option to run it fullscreen borderless or windowed (has borders)
  • You might want to add precations and use the Advanced ARFormula heres an example
  • IniRead, i, borderonoff.ini, border, i
    IniRead, j, borderonoff.ini, border, j
    IniRead, k, borderonoff.ini, border, k
    IniRead, l, borderonoff.ini, border, l
    
    F1::
    WinGetPos,,, w, h, A
    MouseClick, Left, % Round(962 / (1920 / (w - i))) + l, % Round(432 / (1080 / (h - j))) + k, Fast
    return
    
    Border:
    ;For Windowed (with Borders)
    i = 16
    j = 38
    l = 8
    k = 30
    IniWrite, %i%, borderonoff.ini, border, i
    IniWrite, %j%, borderonoff.ini, border, j
    IniWrite, %l%, borderonoff.ini, border, l
    IniWrite, %k%, borderonoff.ini, border, k
    return
    
    Borderless:
    ;For Fullscreen Borderless
    i = 0
    j = 0
    l = 0
    k = 0
    IniWrite, %i%, borderonoff.ini, border, i
    IniWrite, %j%, borderonoff.ini, border, j
    IniWrite, %l%, borderonoff.ini, border, l
    IniWrite, %k%, borderonoff.ini, border, k
    return
    
    F5::
    goto, Border
    return
    
    F6::
    goto, Borderless
    return
  • In Windows7 the border values are 8 each side, 30 top and 8 bottom border. Other Operating Systems may vary
  • The Window Border needs to be taken away from the "new" width of the application and then only one side added at the very end of the formula.

​Hopefully this will be of use to someone wink.png

 

Edit: Below in this topic shadowless is complaining about not being able to get the colour from fullscreen games.

The fix I implement now instead of often changing into windowmode (which doesnt always work) is this:

 

Take a screenshot of the game and its interface.

Save it to your computer/desktop.

Open it using Windows Photo Viewer (default photo viewing program in windows)

Press F11 to make it fullscreen

Right Click and Click on Pause (so it doesnt slide to the next image)

Now you have all the time to position your mouse to where you want and capture all locations in one go.

 

The ARFormula has been tested in 3 games so far and no issues have been detected so far in any resolution.

 

Good Luck and Enjoy.


Check out ALL My Scripts  ;)


shadowless
  • Members
  • 58 posts
  • Last active: May 29 2013 11:55 PM
  • Joined: 08 Mar 2013

so I tried but it is doing the exact same thing as the other pixel search programs, it is taking the color behind the game window that I am trying to search on, it's like ignoring the game's window all together. the thing is it all works fine on windowed mode but once it gets to full screen it just won't work for me.



Sanctus
  • Members
  • 283 posts
  • Last active: Dec 06 2014 04:05 PM
  • Joined: 30 Nov 2012

so I tried but it is doing the exact same thing as the other pixel search programs, it is taking the color behind the game window that I am trying to search on, it's like ignoring the game's window all together. the thing is it all works fine on windowed mode but once it gets to full screen it just won't work for me.

AHK isn't designed for full screen games (some work, most dont) try putting the game in window mode while checking the color or do print screen and paste the image into paint and get the color value from paint. 

Windowed Fullscreen is Best Option if available.

edit: which game is it anyway?

 

Try this option for your game:

http://pcgamingwiki....owed#AutoHotKey


Check out ALL My Scripts  ;)


shadowless
  • Members
  • 58 posts
  • Last active: May 29 2013 11:55 PM
  • Joined: 08 Mar 2013

yeah it works perfectly in windowed mode my only problem was I made my script on coordinates that were specifically for full screen mode. but everything is ok now I just found out about the CoordMode, Mouse, Screen <--change to Windowed thing so now everything is good now even the pixel search. Just a new feeling using windowed mode for the first time. but I guess it doesn't matter since I won't be at the computer watching the bot run anyways lol. cheers, I will keep this script in my tools folder though for future use, thank you.



Sanctus
  • Members
  • 283 posts
  • Last active: Dec 06 2014 04:05 PM
  • Joined: 30 Nov 2012

yeah it works perfectly in windowed mode my only problem was I made my script on coordinates that were specifically for full screen mode. but everything is ok now I just found out about the CoordMode, Mouse, Screen <--change to Windowed thing so now everything is good now even the pixel search. Just a new feeling using windowed mode for the first time. but I guess it doesn't matter since I won't be at the computer watching the bot run anyways lol. cheers, I will keep this script in my tools folder though for future use, thank you.

Good that its now working for you ;) Fullscreen is always a bitch to work around for AHK so keep that in mind when scripting for games :)


Check out ALL My Scripts  ;)


shadowless
  • Members
  • 58 posts
  • Last active: May 29 2013 11:55 PM
  • Joined: 08 Mar 2013

Good that its now working for you wink.png Fullscreen is always a bitch to work around for AHK so keep that in mind when scripting for games happy.png

yeah, but I wonder what stops it from reading the colors though. just curious. btw if I had a really long loop do you know of any way to force a break with a hotkey at the loops current state? most of the things I found are for short loops, and I cant seem to get the things I found to work I just want to break the loop so it stops whatever its doing but not exiting ahk

if getKeyState("F1")
break

won't work for me



Sanctus
  • Members
  • 283 posts
  • Last active: Dec 06 2014 04:05 PM
  • Joined: 30 Nov 2012

yeah, but I wonder what stops it from reading the colors though. just curious. btw if I had a really long loop do you know of any way to force a break with a hotkey at the loops current state? most of the things I found are for short loops, and I cant seem to get the things I found to work I just want to break the loop so it stops whatever its doing but not exiting ahk

if getKeyState("F1")
break

won't work for me

I always add

F7::Suspend

and

F8::ExitApp

to my scripts to pause/unpause and crash my scripts, maybe it will work for you


Check out ALL My Scripts  ;)


shadowless
  • Members
  • 58 posts
  • Last active: May 29 2013 11:55 PM
  • Joined: 08 Mar 2013

yeah, I have a pause hotkey, but I was looking for something that just force exits the main loop, I don't like exiting it though I have it hotkey'ed for when im finished, I want the break out of loop thing so whenever my bot makes a mistake I can just have it stop what its doing then I can set a new variable then start it again with my start hotkey



Sanctus
  • Members
  • 283 posts
  • Last active: Dec 06 2014 04:05 PM
  • Joined: 30 Nov 2012

Check this link out http://www.autohotke...rrupt-ahk-loop/

 

Btw just updated my script so It now displays the RGB colour but also gives you the BGR/RGB values.


Check out ALL My Scripts  ;)


shadowless
  • Members
  • 58 posts
  • Last active: May 29 2013 11:55 PM
  • Joined: 08 Mar 2013

Check this link out http://www.autohotke...rrupt-ahk-loop/

 

Btw just updated my script so It now displays the RGB colour but also gives you the BGR/RGB values.

Yeah, I've been there and tried that, as I said it will play through the entire cycle of the loop before stopping even if you hit the stop button early, and my script is 1 really really long loop that involves multiple inside loops for pixel searching so that code just wont work for me.

 

ohh, I never really use rgb but nice addition :D, one thing I could really use with this kind of program is a pixel search that doesn't activate a buttons hover function (buttons that change color/shape when you put the cursor on it). its really a pain having to screen shot then get the pixel of the screen shot which doesn't always work



Sanctus
  • Members
  • 283 posts
  • Last active: Dec 06 2014 04:05 PM
  • Joined: 30 Nov 2012

Yeah, I've been there and tried that, as I said it will play through the entire cycle of the loop before stopping even if you hit the stop button early, and my script is 1 really really long loop that involves multiple inside loops for pixel searching so that code just wont work for me.

 

ohh, I never really use rgb but nice addition grin.png, one thing I could really use with this kind of program is a pixel search that doesn't activate a buttons hover function (buttons that change color/shape when you put the cursor on it). its really a pain having to screen shot then get the pixel of the screen shot which doesn't always work

You can always send the mouse to a neutral spot until you want it to click the mouse, just use MouseMove, X, Y

Also if you arent sure you are getting the exact color you need you can also print screen and paste into paint and use the script on the picture :)


Check out ALL My Scripts  ;)


dylanlekinh
  • Members
  • 11 posts
  • Last active: Jul 17 2013 11:20 PM
  • Joined: 27 May 2013

Are u married if u are not DO U WANNA MARRIED ME !!!! I stop joke ^^ u save my life !!!



Sanctus
  • Members
  • 283 posts
  • Last active: Dec 06 2014 04:05 PM
  • Joined: 30 Nov 2012

Just updated the script.

Changes:

2 Buttons, 1st for Positions, 2nd for Color

Fixed the gui.


Check out ALL My Scripts  ;)


Sanctus
  • Members
  • 283 posts
  • Last active: Dec 06 2014 04:05 PM
  • Joined: 30 Nov 2012

Updated the Script:

Changes:

  • 3 Buttons added:
    • Copy Window Size
    • Copy Any Resolution Formula
    • Copy Advanced Any Resolution Formula
  • 2 Formulas added
    • Any Resolution borderless
    • Any Resolution border/borderless
  • There are detailed instructions on how to use the new functions in the Original Post
  • Good Luck, Enjoy

Check out ALL My Scripts  ;)


UrKungFuNoGood
  • Members
  • 6 posts
  • Last active: Aug 07 2014 02:00 AM
  • Joined: 31 Jul 2014

Error: Parameter #1 invalid

 

Specifically: new

 

     Line#

     004: Menu, Tray, Tip,PositionINfo v1.03

Made by Sanctus

        005: Return

        007: Return

        008: MouseGetPos,PosX,PosY

        009: PixelGetColor,cRGB,%PosX%,PosY%,RGB

        010: PixelGetColor,cBGR,%PosX%,PosY%

        011: WinGetPos,,,w,h,A

--->  012: Gui,new

 

The program will exit.