Jump to content

get coordinates and color of mouse


Recommended Posts

getting coords is working fine but getting the color gives me error

HotKeySet ("{esc}", "_Exit")

#include <Misc.au3>

$Coords = AskUser()
call ("Start")


Func AskUser()
    MsgBox(0, "User Input", "Please click mouse your screen" & @CRLF & "Press OK, and then move your mouse there and click")
    Do
        Sleep(50)
    Until _IsPressed(01)
    $Coords = MouseGetPos()
Local $Color = PixelGetColor($coords[0], $coords[1])
    
    MsgBox(0, "info", "Your coords and color have been stored for later use")
    Return $Coords
EndFunc 




Func Start()
While 1

if pixelgetcolor($coords[0],$coords[1]) = $Color  then
   sleep (200)
   ;run whole script

Else
   sleep (100)
   endif

wend
EndFunc



Func _Exit()
Exit
EndFunc

 

 

Edited by freyaharts
Link to comment
Share on other sites

  • Developers

Which value? It really would help to be much more specific.
You have an msgbox() in there ...  what is shown?
When I run it it works fine after fixing the syntax error in this line:

if pixelgetcolor ($Coords[0,  $Coords[1]) = 0x012549 then

It is missing a ] after the 0.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

sorry my objective is unclear .. heres what im trying to do

a message box will pop out and ask the user to click the mouse and set the pixelgetcolor and then run the loop

 

HotKeySet ("{home}", "SetBlueCoords")
HotKeySet ("{END}", "_Exit")

While 1
Sleep(200)
WEnd




func SetBlueCoords()

   MsgBox(0, "User Input", "Please click the screen on blue pixel bar" & @CRLF & "Press OK, and then move your mouse there and click")
    Do
      Sleep(50)
    Until _IsPressed(01)
    $Blue= MouseGetPos()

   $blueHex = & Hex($blueHex, 6))

call ("start")
EndFunc  



func start()

while 1

if pixelgetcolor ($blue[0], $[blue[1]) <> $blueHex  then

;run the whole script

endif

wend

endfunc



Func _Exit()
Exit
EndFunc

 

Link to comment
Share on other sites

  • Developers

Understood...  but it is still unclear what the issue is with the script. So what is your question or what isn't working?
Also define what program/process you are trying to automate so we understand.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

its for data entry job ... the user will click the position of progress bar on how many percent they wish before doing another task for copying anoter file.. 

w7hKsdy.png

 

when i run it i got this error message

 

$blueHex = & Hex($blueHex, 6))

$blueHex = & Hex($^ ERROR

Error: varriable used without being declared.

 

im kinda new to this automation.. i hope you help me 

 

Link to comment
Share on other sites

  • Developers

You get that error because you have nowhere define that variable $BlueHex. 
So simply add it with its appropriate value at the top of the script.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • 2 weeks later...
  • Developers
1 minute ago, freyaharts said:

can you make an example how to achieve that?

No ...  read again what I type and try to understand and play with that. 
You creted the posted script su I can only assume you created it and as such should understand it. ;)

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

hi im kinda new to this i want to get color and coordinates stored the data and use it for whole loop script

coordinates works pecfectly however color doesnt seem work 

 

any ideas?

 

 

HotKeySet ("{esc}", "_Exit")

#include <Misc.au3>

$Coords = AskUser()
call ("Start")


Func AskUser()
    MsgBox(0, "User Input", "Please click mouse your screen" & @CRLF & "Press OK, and then move your mouse there and click")
    Do
        Sleep(50)
    Until _IsPressed(01)
    $Coords = MouseGetPos()
Local $Color = PixelGetColor($coords[0], $coords[1])
    
    MsgBox(0, "info", "Your coords and color have been stored for later use")
    Return $Coords
EndFunc 




Func Start()
While 1

if pixelgetcolor($coords[0],$coords[1]) = $Color  then
   sleep (200)
   ;run whole script

Else
   sleep (100)
   endif

wend
EndFunc



Func _Exit()
Exit
EndFunc

 

Link to comment
Share on other sites

6 minutes ago, Jos said:

No ...  read again what I type and try to understand and play with that. 
You creted the posted script su I can only assume you created it and as such should understand it. ;)

Jos

its been actually a week still trying to figure it out  on my own.... i tried to slam my head on desk but still didnt get the idea .. im so hopeless :( 

Link to comment
Share on other sites

  • Moderators

freyaharts,

Stick to just the one thread please - merged.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Developers

So again, where in your script have you defined the variable $BlueHex ?  (Shouldn't be a real hard question..right?)

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Moderators

       freyaharts,

That variable is declared as Local to the AskUser function and so is invisible to the Start function.

The Variables - using Global, Local, Static and ByRef tutorial in the Wiki might be a useful read to help you understand more about scoping variables.

M23

 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

freyaharts,

Declare the variable as Global at the top of the script and then it can be seen by both functions - as long as you do not redeclare it as Local inside one of them.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...