PixelGetColor (called with wrong number of args)

Viewed 30

I'm trying to create a simple script for getting the hex color value of a position on the screen from a variable given by an input box.

The script is not starting because of that error, I don't really understand why it's not working this way, would really appreciate if anyone can explain this to me.

#include <MsgBoxConstants.au3>
$position = InputBox("", "position:", "", "", 200, 150,  @DesktopWidth / 2-125, @DesktopHeight / 2-100, 0)
$color = PixelGetColor($position)
MsgBox($MB_SYSTEMMODAL,"","Hex Color: " & Hex($color, 6))
1 Answers

Your $position is just one parameter (a single string containing a comma), not two parameters delimited with a comma. You need to split it:

#include <MsgBoxConstants.au3>
$aPosition = StringSplit(InputBox("", "position:", "", "", 200, 150, @DesktopWidth / 2 - 125, @DesktopHeight / 2 - 100, 0), ",")
$color = PixelGetColor($aPosition[1], $aPosition[2])
MsgBox($MB_SYSTEMMODAL, "", "Hex Color: " & Hex($color, 6))
Related