ControlClick象这样用,点击中了却好象没点击一样,为什么?
本帖最后由 东风烈烈 于 2015-2-3 16:20 编辑问题解决了,正确的如下(主题在后面加了(已解决)却不显示,不知怎么弄):
WinActivate("国内期货")
;Sleep(1000)
WinWaitActive("国内期货")
If $LKBSA = "{F1}" Then
Select
Case $BSVOL2 > 1
For $I = 0 To $BSVOL2 - 1
$hwnd = ControlGetHandle("国内期货", "","")
$pos = ControlGetPos("国内期货","","")
$X = String(Hex(Int($pos/2), 4))
$Y = String(Hex(Int($pos/2), 4))
$lParm = "0x" & $Y & $X
_WinAPI_PostMessage($hwnd, 0x200, 0x0, $lParm)
_WinAPI_PostMessage($hwnd, 0x201, 0x1, $lParm)
_WinAPI_PostMessage($hwnd, 0x202, 0x0, $lParm)
;ControlFocus("国内期货","","Button2")
ControlClick("国内期货","","","left")
;Local $handle = ControlGetHandle("国内期货","","")
;_GUICtrlButton_Click($handle)
Sleep(200)
Next
Case$BSVOL2 = 1
$hwnd = ControlGetHandle("国内期货", "","")
$pos = ControlGetPos("国内期货","","")
$X = String(Hex(Int($pos/2), 4))
$Y = String(Hex(Int($pos/2), 4))
$lParm = "0x" & $Y & $X
_WinAPI_PostMessage($hwnd, 0x200, 0x0, $lParm)
_WinAPI_PostMessage($hwnd, 0x201, 0x1, $lParm)
_WinAPI_PostMessage($hwnd, 0x202, 0x0, $lParm)
;ControlFocus("国内期货","","Button2")
ControlClick("国内期货","","","left")
;Local $handle = ControlGetHandle("国内期货","","")
;_GUICtrlButton_Click($handle)
Sleep(200)
EndSelect
EndIf
上面为正确能执行的源码!原来不能执行是因为要把鼠标放在上面(这个现在我还是不明白)。下面的为不能执行的原来代码。再次谢谢帮忙解决问题的朋友。
代码如下,请高手指点一下,很急。先谢谢了!!!!
If $LKBSA = "{F3}" Then
Select
Case $BSVOL2 > 1
For $I = 0 To $BSVOL2 - 1
ControlFocus("国内期货","","Button2")
ControlClick("国内期货","","","left")
;Local $handle = ControlGetHandle("国内期货","","")
;_GUICtrlButton_Click($handle)
Sleep(200)
Next
Case$BSVOL2 = 1
ControlFocus("国内期货","","Button2")
ControlClick("国内期货","","","left")
;Local $handle = ControlGetHandle("国内期货","","")
;_GUICtrlButton_Click($handle)
Sleep(200)
EndSelect
EndIf
If $LKBSA = "{F2}"Then
Select
Case $BSVOL2 > 1
For $I = 0 To $BSVOL2 - 1
ControlFocus("国内期货","","Button2")
ControlClick("国内期货","","","left")
;Local $handle = ControlGetHandle("国内期货","","")
;_GUICtrlButton_Click($handle)
Sleep(200)
Next
Case$BSVOL2 = 1
ControlFocus("国内期货","","Button2")
ControlClick("国内期货","","","left")
;Local $handle = ControlGetHandle("国内期货","","")
;_GUICtrlButton_Click($handle)
Sleep(200)
EndSelect
EndIf
If $LKBSA = "{F4}" Then
Select
Case $BSVOL2 > 1
For $I = 0 To $BSVOL2 - 1
ControlFocus("国内期货","","Button2")
ControlClick("国内期货","","","left")
;Local $handle = ControlGetHandle("国内期货","","")
;_GUICtrlButton_Click($handle)
Sleep(200)
Next
Case$BSVOL2 = 1
ControlFocus("国内期货","","Button2")
ControlClick("国内期货","","","left")
;Local $handle = ControlGetHandle("国内期货","","")
;_GUICtrlButton_Click($handle)
Sleep(200)
EndSelect
WinActivate("国内期货")
WinWaitActive("国内期货")
If $LKBSA = "{F1}" And $BSVOL2 > 0 Then
For $i = 1 To $BSVOL2
_ControlClick("国内期货", "", "")
Sleep(200)
Next
EndIf
Func _ControlClick($iTitle, $iText, $iControl)
Local $hwnd = ControlGetHandle($iTitle, $iText, $iControl)
Local $pos = ControlGetPos($iTitle, $iText, $iControl)
Local $lParm = "0x" & String(Hex(Int($pos / 2), 4)) & String(Hex(Int($pos / 2), 4))
_WinAPI_PostMessage($hwnd, 0x200, 0x0, $lParm)
_WinAPI_PostMessage($hwnd, 0x201, 0x1, $lParm)
_WinAPI_PostMessage($hwnd, 0x202, 0x0, $lParm)
EndFunc ;==>_ControlClick 请DX现身,程序对象为文华的赢顺WH6,另外这赏的金钱怎么样付给解决问题的朋友呢? 怎样才可以将悬赏金钱加大到100块? 这个股票的貌似都没有那么简单 本帖最后由 东风烈烈 于 2015-1-28 15:07 编辑
是期货,朋友。
WH6实盘通用版的下载:http://db.wenhua.com.cn/rjxz/index.asp 试了下论坛上说的方法,都不行,差这一步卡在哪里,真苦恼啊!
Local $handle = ControlGetHandle("国内期货","","")
_GUICtrlButton_Click($handle)
不行!
$var=WinList()
For $i= 1 To $var
If $var[$i]=="国内期货" Then
;MsgBox(0,$var[$i],$i,2)
WinActivate($var[$i])
WinWaitActive("国内期货")
ControlFocus("国内期货", "", "Button2")
ControlClick("国内期货","","","left")
还是不行,错在哪里? 本帖最后由 东风烈烈 于 2015-1-29 10:22 编辑
WinActivate("瑞达期货")
BlockInput(1);屏蔽鼠标与键盘(输入)
ControlFocus("瑞达期货", "", "Edit1")
ControlClick("瑞达期货", "", "Edit1")
ControlSetText("瑞达期货", "", "Edit1", $CODE1)
Sleep(50)
ControlFocus("瑞达期货", "", "Edit1")
Send("{ENTER}")
Sleep(1000)
If $LKBSA = "{F1}" Then
Select
Case $BSVOL2 > 1
For $I = 0 To $BSVOL2 - 1
ControlFocus("瑞达期货", "", "Button2")
;ControlClick("瑞达期货", "", "Button2")
MouseClick("left",27,12)
Sleep(200)
Next
Case$BSVOL2 = 1
ControlFocus("瑞达期货", "", "Button2")
;ControlClick("瑞达期货", "", "Button2")
MouseClick("left",27,12)
Sleep(200)
EndSelect
EndIf
这个也不成!请懂的指教一下,不胜感激!
另外说一下我用的操作系统是WIN7,不知跟这个有没有关系? ControlClick("瑞达期货", "", "Button2")你确认这里没出错吗? 你看一下ControlGETText取得的文本是按钮上的文本,和autoit info取得的信息是一样 Sleep(10000)
ControlClick("国内期货","","")
就单单这句去运行试试,在发送点击前把鼠标移到按钮上,等待他去点击。有些软件会在响应里判断鼠标在不在上面。 回复 9# zhouhaijin
这个按钮的文本是行情数据来的,每秒不停在变,所以不可能相同。谢谢! 回复 11# 东风烈烈
不用相同,就你是能确定是那按钮控件没有错误就行。 发送点击前把鼠标移到按钮上试了没 本帖最后由 东风烈烈 于 2015-1-29 23:11 编辑
回复 10# zhouhaijin
Sleep(10000)
ControlClick("国内期货","","")
就单单这句去运行试试,在发送点击前把鼠标移到按钮上,等待他去点击。有些软件会在响应里判断鼠标在不在上面。
按你这个方法去做了.
1,鼠标没放在这个按钮上的时候,能看到有一个点击后的虚线框出现,就是没有别的反应。现在的问题就在这里,
直接手动用鼠标去点的话,会马上发出委托。用这语句如果鼠标没放在按钮上,只会出现被点击后的虚线框,没有执行本身
的委托功能。
2,在程序发送点击前把鼠标移动按钮上,等待它去点击,这时就能正常发出委托的命令。
现在问题真的是你说的那样,请问该怎样解决呢?
谢谢!!!