【问题标题】:PixelGetColor (called with wrong number of args)PixelGetColor(使用错误数量的参数调用)
【发布时间】:2022-09-10 20:43:16
【问题描述】:

我正在尝试创建一个简单的脚本,用于从输入框给出的变量中获取屏幕上某个位置的十六进制颜色值。

由于该错误,脚本没有启动,我真的不明白为什么它不能以这种方式工作,如果有人能向我解释这一点,我将不胜感激。

#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))

【问题讨论】:

    标签: autoit


    【解决方案1】:

    您的 $position 只是一个参数(包含逗号的单个字符串),而不是用逗号分隔的两个参数。你需要拆分它:

    #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))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-19
      • 2021-07-15
      相关资源
      最近更新 更多