help with my color picker

Get help with using AutoHotkey and its commands and hotkeys
michelxd15
Posts: 130
Joined: 08 Aug 2019, 02:02

help with my color picker

12 Feb 2020, 07:43

Hi I'm using a program I learned to collect colors in certain coordinates but it only finds the coordinates of the window, and I needed it to capture the coordinates of the screen - I'll put an image below to help you understand
https://imgur.com/a/CAmcQk1


Yellow = window coordinate

red = screen coordinate

I would also like to use that key and capture that coordinate and color and transform it into a variable
and having a separate part below showing the complete coordinate and the front the color being saved there as Variable 1 and the front a selected key for Variable 1

in the case of need for 3 variables where the color coordinate and the chosen key are saved and showing to the user

example:
I put the mouse on the X = 1270 coordinate, Y = 146 color = 0xDB4F4F
and all of this could be turned into a variable in the case and we could save up to 3 variables
and in each variable I could choose a key to be pressed

example:
in the coordinate of variable 1 press the "A" key
in the coordinate of variable 2 press the "B" key
in Variable 3 coordinate press the "C" key
User avatar
Xtra
Posts: 1993
Joined: 02 Oct 2015, 12:15

Re: help with my color picker

13 Feb 2020, 14:24

Set: CoordMode to Screen.
Put at top of your script:

Code: Select all

CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
michelxd15
Posts: 130
Joined: 08 Aug 2019, 02:02

Re: help with my color picker

14 Feb 2020, 13:04

@Xtra
I would like to know if it has any function that by positioning the mouse in a given coordinate and pressing a key I would make that coordinate turn into a variable - in the case variable 1, 2, and 3 can I do this with any function?
User avatar
Xtra
Posts: 1993
Joined: 02 Oct 2015, 12:15

Re: help with my color picker

14 Feb 2020, 13:28

You need to create your own.
Example:

Code: Select all

c::
    CoordsPixel(X, Y, pColor)
    MsgBox % "x" . X . " y" . Y . " color " . pColor
return

CoordsPixel(ByRef X, ByRef Y, ByRef pColor) {
    CoordMode, Mouse, Screen
    CoordMode, Pixel, Screen
    MouseGetPos, X, Y
    PixelGetColor, pColor, X, Y
}
michelxd15
Posts: 130
Joined: 08 Aug 2019, 02:02

Re: help with my color picker

14 Feb 2020, 13:36

@Xtra
in the image below I selected 1 coordinate and I would like it to be saved as a variable after being selected

and that a specific key was executed when the coordinate and color is determined in the red bars I made in paint would show which coordinate was saved and what color is in that particular coordinate and in blue bars it would show the key that would be pressed when you get that particular coordinate and color

if there is no coordinate selected it would not execute the key that was stipulated

my code is like this at the moment I'm having difficulty because I don't know much about the functions of the auto hotkey and I'm looking for help to learn

image : https://imgur.com/a/F4lGUPw

Code: Select all

#SingleInstance, Force
CoordMode,Mouse Pixel, Screen
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen

List:="F1|F2|F3|F4|F5|F6|F7|F8|F9|F10|F11|F12|ctrl+F1|ctrl+F2|ctrl+F3|ctrl+F4|ctrl+F5|ctrl+F6|ctrl+F7|ctrl+F8|ctrl+F9|ctrl+F10|ctrl+F11|ctrl+F12|shift+F1|shift+F2|shift+F3|shift+F4|shift+F5|shift+F6|shift+F7|shift+F8|shift+F9|shift+F10|shift+F11|shift+F12|"

; Gui Layout
;--------------------
;---------------------------------

Gui, Add, Button, x10 y10 w280 h30 gGet_Color , Color Picker
Gui, Add, Edit, x10 w50 h15, Color =
Gui, Add, Edit, x+10 w100 h15 vThe_Color,
Gui, Add, Edit, x10 w50 h15, X = 
Gui, Add, Edit, x+10 w50 h15 vThe_X,
Gui, Add, Edit, x10 w50 h15,Y =
Gui, Add, Edit, x+10 w50 h15 vThe_Y,
Gui, Add, DropDownList,xm ym x170 y80 w105 r10 v1DLL g1key,% "Select Your Key ||" List
Gui, +AlwaysOnTop
Gui, Show, w600 h500, PixelGetColor


Gui, Add, Button, x10 y140 w280 h30 g1Get_Color , Color Picker
Gui, Add, Edit, x10 w50 h15, Color =
Gui, Add, Edit, x+10 w100 h15 v1The_Color,
Gui, Add, Edit, x10 w50 h15, X = 
Gui, Add, Edit, x+10 w50 h15 v1The_X,
Gui, Add, Edit, x10 w50 h15,Y =
Gui, Add, Edit, x+10 w50 h15 v1The_Y,
Gui, Add, DropDownList,xm ym x170 y210 w105 r10 v2DLL g2key,% "Select Your Key ||" List
Gui, +AlwaysOnTop


Gui, Add, Button, x10 y280 w280 h30 g2Get_Color , Color Picker
Gui, Add, Edit, x10 w50 h15, Color =
Gui, Add, Edit, x+10 w100 h15 v2The_Color,
Gui, Add, Edit, x10 w50 h15, X = 
Gui, Add, Edit, x+10 w50 h15 v2The_X,
Gui, Add, Edit, x10 w50 h15,Y =
Gui, Add, Edit, x+10 w50 h15 v2The_Y,
Gui, Add, DropDownList,xm ym x170 y350 w105 r10 v3DLL g3key,% "Select Your Key ||" List
Gui, +AlwaysOnTop
Return
GuiClose:
    ExitApp
Get_Color:
    i := 0
    Loop
        {
          Left_Mouse := GetKeyState("LButton")
          Right_Mouse := GetKeyState("RButton")
          if(Left_Mouse==False&&i==0)
              i := 1
          else if(Left_Mouse==True&&i==1)
               {
                  MouseGetPos,X,Y
                  PixelGetColor,Our_Color,X,Y,RGB
                  Gui, Color, %Our_Color%
                  GuiControl,,The_Color,%Our_Color%
                  GuiControl,,The_X,%X% ;*[TESTE PARA MACRO DE HEALER]
                  GuiControl,,The_Y,%Y%
               }
          else if(Right_Mouse==True)
              break
}
return

1Get_Color:
    i := 0
    Loop
        {
          Left_Mouse := GetKeyState("LButton")
          Right_Mouse := GetKeyState("RButton")
          if(Left_Mouse==False&&i==0)
              i := 1
          else if(Left_Mouse==True&&i==1)
               {
                  MouseGetPos,X,Y
                  PixelGetColor,Our_Color,X,Y,RGB
                  Gui, Color, %Our_Color%
                  GuiControl,,1The_Color,%Our_Color%
                  GuiControl,,1The_X,%X% ;*[TESTE PARA MACRO DE HEALER]
                  GuiControl,,1The_Y,%Y%
               }
          else if(Right_Mouse==True)
              break
}
return

2Get_Color:
    i := 0
    Loop
        {
          Left_Mouse := GetKeyState("LButton")
          Right_Mouse := GetKeyState("RButton")
          if(Left_Mouse==False&&i==0)
              i := 1
          else if(Left_Mouse==True&&i==1)
               {
                  MouseGetPos,X,Y
                  PixelGetColor,Our_Color,X,Y,RGB
                  Gui, Color, %Our_Color%
                  GuiControl,,2The_Color,%Our_Color%
                  GuiControl,,2The_X,%X% ;*[TESTE PARA MACRO DE HEALER]
                  GuiControl,,2The_Y,%Y%
               }
          else if(Right_Mouse==True)
              break
}
return

1Key:
Gui, submit, nohide
send, %List%
Return

2Key:
Gui, submit, nohide
send, %List%
Return

3Key:
Gui, submit, nohide
send, %List%
Return
NumPad0::ExitApp
michelxd15
Posts: 130
Joined: 08 Aug 2019, 02:02

Re: help with my color picker

14 Feb 2020, 14:17

the image below shows how the GUI is doing, I need to put two buttons and to be able to arrange the coordinates and colors
every time the coordinate is saved in coordinates And Colors For Found on Screen Loudly is Sent the Key Selected in "Select Your Key"

code and image below :

https://imgur.com/a/twZWiWe

Code: Select all

#SingleInstance, Force
CoordMode,Mouse Pixel, Screen
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen

List:="F1|F2|F3|F4|F5|F6|F7|F8|F9|F10|F11|F12|ctrl+F1|ctrl+F2|ctrl+F3|ctrl+F4|ctrl+F5|ctrl+F6|ctrl+F7|ctrl+F8|ctrl+F9|ctrl+F10|ctrl+F11|ctrl+F12|shift+F1|shift+F2|shift+F3|shift+F4|shift+F5|shift+F6|shift+F7|shift+F8|shift+F9|shift+F10|shift+F11|shift+F12|"

; Gui Layout
;--------------------
;---------------------------------

Gui, Add, Button, x10 y10 w280 h30 gGet_Color , Color Picker
Gui, Add, Edit, x10 w50 h15, Color =
Gui, Add, Edit, x+10 w100 h15 vThe_Color,
Gui, Add, Edit, x10 w50 h15, X = 
Gui, Add, Edit, x+10 w50 h15 vThe_X,
Gui, Add, Edit, x10 w50 h15,Y =
Gui, Add, Edit, x+10 w50 h15 vThe_Y,
Gui, Add, DropDownList,xm ym x170 y80 w105 r10 v1DLL g1key,% "Select Your Key ||" List
Gui, Add, Edit, x10 w280 h20, Cordenates And Color =
Gui, +AlwaysOnTop
Gui, Show, w600 h500, PixelGetColor


Gui, Add, Button, x10 y140 w280 h30 g1Get_Color , Color Picker
Gui, Add, Edit, x10 w50 h15, Color =
Gui, Add, Edit, x+10 w100 h15 v1The_Color,
Gui, Add, Edit, x10 w50 h15, X = 
Gui, Add, Edit, x+10 w50 h15 v1The_X,
Gui, Add, Edit, x10 w50 h15,Y =
Gui, Add, Edit, x+10 w50 h15 v1The_Y,
Gui, Add, DropDownList,xm ym x170 y210 w105 r10 v2DLL g2key,% "Select Your Key ||" List
Gui, Add, Edit, x10 w280 h20, Cordenates And Color =
Gui, +AlwaysOnTop


Gui, Add, Button, x10 y280 w280 h30 g2Get_Color , Color Picker
Gui, Add, Edit, x10 w50 h15, Color =
Gui, Add, Edit, x+10 w100 h15 v2The_Color,
Gui, Add, Edit, x10 w50 h15, X = 
Gui, Add, Edit, x+10 w50 h15 v2The_X,
Gui, Add, Edit, x10 w50 h15,Y =
Gui, Add, Edit, x+10 w50 h15 v2The_Y,
Gui, Add, DropDownList,xm ym x170 y350 w105 r10 v3DLL g3key,% "Select Your Key ||" List
Gui, Add, Edit, x10 w280 h20, Cordenates And Color =
Gui, +AlwaysOnTop
Return
GuiClose:
    ExitApp
Get_Color:
    i := 0
    Loop
        {
          Left_Mouse := GetKeyState("LButton")
          Right_Mouse := GetKeyState("RButton")
          if(Left_Mouse==False&&i==0)
              i := 1
          else if(Left_Mouse==True&&i==1)
               {
                  MouseGetPos,X,Y
                  PixelGetColor,Our_Color,X,Y,RGB
                  Gui, Color, %Our_Color%
                  GuiControl,,The_Color,%Our_Color%
                  GuiControl,,The_X,%X% ;*[TESTE PARA MACRO DE HEALER]
                  GuiControl,,The_Y,%Y%
               }
          else if(Right_Mouse==True)
              break
}
1::
    CoordsPixel(X, Y, pColor)
                  PixelGetColor,Our_Color,X,Y,RGB
                  Gui, Color, %Our_Color%
                  GuiControl,,The_Color,%Our_Color%
                  GuiControl,,The_X,%X% ;*[TESTE PARA MACRO DE HEALER]
                  GuiControl,,The_Y,%Y%
return

CoordsPixel(ByRef X, ByRef Y, ByRef pColor) {
    CoordMode, Mouse, Screen
    CoordMode, Pixel, Screen
    MouseGetPos, X, Y
    PixelGetColor, pColor, X, Y
}
return

1Get_Color:
    i := 0
    Loop
        {
          Left_Mouse := GetKeyState("LButton")
          Right_Mouse := GetKeyState("RButton")
          if(Left_Mouse==False&&i==0)
              i := 1
          else if(Left_Mouse==True&&i==1)
               {
                  MouseGetPos,X,Y
                  PixelGetColor,Our_Color,X,Y,RGB
                  Gui, Color, %Our_Color%
                  GuiControl,,1The_Color,%Our_Color%
                  GuiControl,,1The_X,%X% ;*[TESTE PARA MACRO DE HEALER]
                  GuiControl,,1The_Y,%Y%
               }
          else if(Right_Mouse==True)
              break
}
return

2Get_Color:
    i := 0
    Loop
        {
          Left_Mouse := GetKeyState("LButton")
          Right_Mouse := GetKeyState("RButton")
          if(Left_Mouse==False&&i==0)
              i := 1
          else if(Left_Mouse==True&&i==1)
               {
                  MouseGetPos,X,Y
                  PixelGetColor,Our_Color,X,Y,RGB
                  Gui, Color, %Our_Color%
                  GuiControl,,2The_Color,%Our_Color%
                  GuiControl,,2The_X,%X% ;*[TESTE PARA MACRO DE HEALER]
                  GuiControl,,2The_Y,%Y%
               }
          else if(Right_Mouse==True)
              break
}
return

1Key:
Gui, submit, nohide
send, %List%
Return

2Key:
Gui, submit, nohide
send, %List%
Return

3Key:
Gui, submit, nohide
send, %List%
Return
NumPad0::ExitApp
michelxd15
Posts: 130
Joined: 08 Aug 2019, 02:02

Re: help with my color picker

14 Feb 2020, 14:50

I put the buttons but I don't know how to work with the IniWrite function
IniRead
IniDelete

my code is now like this, if possible you can run it to see the problems I describe because I am learning to deal with GUI and learning many functions since I am new to Autohotkey and learning to deal with a lot of new things, thank you for your attention!

image And code below:

https://imgur.com/a/cQaV0E7

Code: Select all

#SingleInstance, Force
CoordMode,Mouse Pixel, Screen
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen

List:="F1|F2|F3|F4|F5|F6|F7|F8|F9|F10|F11|F12|ctrl+F1|ctrl+F2|ctrl+F3|ctrl+F4|ctrl+F5|ctrl+F6|ctrl+F7|ctrl+F8|ctrl+F9|ctrl+F10|ctrl+F11|ctrl+F12|shift+F1|shift+F2|shift+F3|shift+F4|shift+F5|shift+F6|shift+F7|shift+F8|shift+F9|shift+F10|shift+F11|shift+F12|"

; Gui Layout
;--------------------
;---------------------------------

Gui, Add, Button, x10 y10 w280 h30 gGet_Color , Color Picker
Gui, Add, Edit, x10 w50 h15, Color =
Gui, Add, Edit, x+10 w100 h15 vThe_Color,
Gui, Add, Edit, x10 w50 h15, X = 
Gui, Add, Edit, x+10 w50 h15 vThe_X,
Gui, Add, Edit, x10 w50 h15,Y =
Gui, Add, Edit, x+10 w50 h15 vThe_Y,
Gui, Add, DropDownList,xm ym x170 y80 w105 r10 v1DLL g1key,% "Select Your Key ||" List
Gui, Add, Edit, x10 w280 h20, Cordenates And Color =
Gui, +AlwaysOnTop
Gui, Show, w350 h500, PixelGetColor


Gui, Add, Button, x10 y140 w280 h30 g1Get_Color , Color Picker
Gui, Add, Edit, x10 w50 h15, Color =
Gui, Add, Edit, x+10 w100 h15 v1The_Color,
Gui, Add, Edit, x10 w50 h15, X = 
Gui, Add, Edit, x+10 w50 h15 v1The_X,
Gui, Add, Edit, x10 w50 h15,Y =
Gui, Add, Edit, x+10 w50 h15 v1The_Y,
Gui, Add, DropDownList,xm ym x170 y210 w105 r10 v2DLL g2key,% "Select Your Key ||" List
Gui, Add, Edit, x10 w280 h20, Cordenates And Color =
Gui, +AlwaysOnTop


Gui, Add, Button, x10 y270 w280 h30 g2Get_Color , Color Picker
Gui, Add, Edit, x10 w50 h15, Color =
Gui, Add, Edit, x+10 w100 h15 v2The_Color,
Gui, Add, Edit, x10 w50 h15, X = 
Gui, Add, Edit, x+10 w50 h15 v2The_X,
Gui, Add, Edit, x10 w50 h15,Y =
Gui, Add, Edit, x+10 w50 h15 v2The_Y,
Gui, Add, DropDownList,xm ym x170 y350 w105 r10 v3DLL g3key,% "Select Your Key ||" List
Gui, Add, Edit, x10 w280 h20, Cordenates And Color =
Gui, +AlwaysOnTop

Gui, Add, Button, x10 y450 w100 h25 gbuttonsave , save configs
Gui, Add, Button, x+10 w100 h25  gbuttonload , load configs
Gui, Add, Button, x+10 w100 h25 gbuttonreset , reset configs
Return
GuiClose:
    ExitApp
Get_Color:
    i := 0
    Loop
        {
          Left_Mouse := GetKeyState("LButton")
          Right_Mouse := GetKeyState("RButton")
          if(Left_Mouse==False&&i==0)
              i := 1
          else if(Left_Mouse==True&&i==1)
               {
                  MouseGetPos,X,Y
                  PixelGetColor,Our_Color,X,Y,RGB
                  Gui, Color, %Our_Color%
                  GuiControl,,The_Color,%Our_Color%
                  GuiControl,,The_X,%X% ;*[TESTE PARA MACRO DE HEALER]
                  GuiControl,,The_Y,%Y%
               }
          else if(Right_Mouse==True)
              break
}
1::
    CoordsPixel(X, Y, pColor)
                  PixelGetColor,Our_Color,X,Y,RGB
                  Gui, Color, %Our_Color%
                  GuiControl,,The_Color,%Our_Color%
                  GuiControl,,The_X,%X% ;*[TESTE PARA MACRO DE HEALER]
                  GuiControl,,The_Y,%Y%
return

CoordsPixel(ByRef X, ByRef Y, ByRef pColor) {
    CoordMode, Mouse, Screen
    CoordMode, Pixel, Screen
    MouseGetPos, X, Y
    PixelGetColor, pColor, X, Y
}
return

1Get_Color:
    i := 0
    Loop
        {
          Left_Mouse := GetKeyState("LButton")
          Right_Mouse := GetKeyState("RButton")
          if(Left_Mouse==False&&i==0)
              i := 1
          else if(Left_Mouse==True&&i==1)
               {
                  MouseGetPos,X,Y
                  PixelGetColor,Our_Color,X,Y,RGB
                  Gui, Color, %Our_Color%
                  GuiControl,,1The_Color,%Our_Color%
                  GuiControl,,1The_X,%X% ;*[TESTE PARA MACRO DE HEALER]
                  GuiControl,,1The_Y,%Y%
               }
          else if(Right_Mouse==True)
              break
}
return

2Get_Color:
    i := 0
    Loop
        {
          Left_Mouse := GetKeyState("LButton")
          Right_Mouse := GetKeyState("RButton")
          if(Left_Mouse==False&&i==0)
              i := 1
          else if(Left_Mouse==True&&i==1)
               {
                  MouseGetPos,X,Y
                  PixelGetColor,Our_Color,X,Y,RGB
                  Gui, Color, %Our_Color%
                  GuiControl,,2The_Color,%Our_Color%
                  GuiControl,,2The_X,%X% ;*[TESTE PARA MACRO DE HEALER]
                  GuiControl,,2The_Y,%Y%
               }
          else if(Right_Mouse==True)
              break
}
return

1Key:
Gui, submit, nohide
send, %List%
Return

2Key:
Gui, submit, nohide
send, %List%
Return

3Key:
Gui, submit, nohide
send, %List%
Return

buttonsave:
Gui, Submit, NoHide
IniWrite, %1DLL%, settings.ini, Settings, dropdownlist

buttonload:
Gui, Submit, NoHide
IniWrite, %1DLL%, settings.ini, Settings, dropdownlist

buttonreset:
Gui, Submit, NoHide
IniWrite, %1DLL%, settings.ini, Settings, dropdownlist
NumPad0::ExitApp

Return to “Ask For Help”

Who is online

Users browsing this forum: ArkuS, Bing [Bot], mikeyww, Renegaduh, Xtra and 39 guests