求助 - 取得滑鼠 X,Y座標 填入edit1
本帖最后由 tcpuuu 于 2011-5-24 08:46 编辑取得滑鼠 X,Y座標 填入edit1
滑鼠移動數字跟著改變
按下鍵盤Enter停止數字改變
$xy = MouseGetPos()
ControlSetText ('取十進位','','Edit1',$xy)
這該如何編寫?求助大家GUICreate("取十進位",152,200,10,10)
GUICtrlCreateLabel("X座標",5,5,42,20,0x00800000,0x01)
$A1 = GUICtrlCreateInput("",5,25,60,22,0x00800000,0x00000200)
GUICtrlSetFont(-1, 12)
GUICtrlCreateLabel(",",70,35,12,12,0x01)
GUICtrlCreateLabel("Y座標",85,5,42,20,0x00800000,0x01)
$A2 = GUICtrlCreateInput("",85,25,60,22,0x00800000,0x00000200)
GUICtrlSetFont(-1, 12)
GUICtrlCreateLabel("十進位Dec:",5,60,68,20,0x00800000,0x01)
$A3 = GUICtrlCreateInput("0",5,80,100,22,0x00800000,0x00000200)
GUICtrlSetFont(-1, 12)
GUICtrlCreateLabel("Hex",5,110,28,20,0x00800000,0x01)
$A4 = GUICtrlCreateInput("0",5,130,100,22,0x00800000,0x00000200)
GUICtrlSetFont(-1, 12)
$1Button = GUICtrlCreateButton("取顏色碼" , 5,156,82,30,0x00800000,0x01)
GUISetState()
While 1
$msg = GUIGetMsg()
Switch $msg
Case -3
Exit
Case $1Button
$var1 = GUICtrlRead($A1)
$var2 = GUICtrlRead($A2)
$Pix = PixelGetColor($var1,$var2)
GUICtrlSetData($A3,$Pix)
GUICtrlSetData($A4,Hex($Pix,6))
EndSwitch
WEnd 本帖最后由 骗子 于 2011-5-24 10:17 编辑
Global $Paused
HotKeySet("{enter}", "TogglePause");把回车定义成快捷键
GUICreate("取十進位",152,200,10,10)
GUICtrlCreateLabel("X座標",5,5,42,20,0x00800000,0x01)
$A1 = GUICtrlCreateInput("",5,25,60,22,0x00800000,0x00000200)
GUICtrlSetFont(-1, 12)
GUICtrlCreateLabel(",",70,35,12,12,0x01)
GUICtrlCreateLabel("Y座標",85,5,42,20,0x00800000,0x01)
$A2 = GUICtrlCreateInput("",85,25,60,22,0x00800000,0x00000200)
GUICtrlSetFont(-1, 12)
GUICtrlCreateLabel("十進位Dec:",5,60,68,20,0x00800000,0x01)
$A3 = GUICtrlCreateInput("0",5,80,100,22,0x00800000,0x00000200)
GUICtrlSetFont(-1, 12)
GUICtrlCreateLabel("Hex",5,110,28,20,0x00800000,0x01)
$A4 = GUICtrlCreateInput("0",5,130,100,22,0x00800000,0x00000200)
GUICtrlSetFont(-1, 12)
$1Button = GUICtrlCreateButton("取顏色碼" , 5,156,82,30,0x00800000,0x01)
GUISetState()
While 1
$pos = MouseGetPos() ;读取当前鼠标坐标
GUICtrlSetData($A1,$pos ) ;设置输入框A1的数据为坐标的X
GUICtrlSetData($A2,$pos ) ;;设置输入框A1的数据为坐标的Y
$msg = GUIGetMsg()
Switch $msg
Case -3
Exit
Case $1Button
$var1 = GUICtrlRead($A1)
$var2 = GUICtrlRead($A2)
$Pix = PixelGetColor($var1,$var2)
GUICtrlSetData($A3,$Pix)
GUICtrlSetData($A4,Hex($Pix,6))
EndSwitch
WEnd
Func TogglePause()
$Paused = NOT $Paused
While $Paused
sleep(100)
ToolTip('选定的坐标为'&$pos&','&$pos) ;注意提示框的位置
WEnd
ToolTip("")
EndFunc
本帖最后由 tcpuuu 于 2011-5-24 10:47 编辑
嗯!謝謝
但是 按 Enter 定位取得坐標後
再去按 1Button(變沒回應)要取得座標點的顏色碼
且 按右上要關閉這個視窗 結束也 關不掉?
------------------------------------------------------
本來 手動 輸入座標 按 1Button 取得顏色碼
現在可 自動抓 自動輸入很方便
但是有以上問題 将1button的内容放到 第二个循环中 本帖最后由 tcpuuu 于 2011-5-25 02:51 编辑
GUISetState()
While 1
$pos = MouseGetPos() ;?取?前鼠?坐?
GUICtrlSetData($A1,$pos ) ;?置?入框A1的?据?坐?的X
GUICtrlSetData($A2,$pos ) ;;?置?入框A2的?据?坐?的Y
$msg = GUIGetMsg()
Switch $msg
Case -3
Exit
EndSwitch
WEnd
Func TogglePause()
$Paused = NOT $Paused
While $Paused
Select
Case $1Button
$var1 = GUICtrlRead($A1)
$var2 = GUICtrlRead($A2)
$Pix = PixelGetColor($var1,$var2)
GUICtrlSetData($A3,$Pix)
GUICtrlSetData($A4,Hex($Pix,6))
EndSelect
sleep(100)
ToolTip('?定的坐??'&$pos&','&$pos) ;注意提示框的位置
WEnd
ToolTip("")
EndFunc再把底下 這個 用鍵盤移動滑鼠 加進去 要放那裡?HotKeySet("{right}","right")
HotKeySet("{up}","up")
HotKeySet("{down}","down")
HotKeySet("{left}","left")
Sleep(10000000)
Func up()
$xy = MouseGetPos()
MouseMove($xy, $xy - 1)
EndFunc ;==>up
Func Down()
$xy = MouseGetPos()
MouseMove($xy, $xy + 1)
EndFunc ;==>Down
Func left()
$xy = MouseGetPos()
MouseMove($xy - 1, $xy)
EndFunc ;==>left
Func right()
$xy = MouseGetPos()
MouseMove($xy + 1, $xy)
EndFunc ;==>right
页:
[1]