我正在使用函数send(),我想知道是否有任何方法可以确认它与预期采取的行动不同。
下面是代码,说明我如何利用函数send发送数组中保存的指令。
Switch $ch
Case "A"
MsgBox (0, "SWITCH STATEMENT", $userconfigasarray[1])
;$myvar = $userconfigasarray[1]
Send("{"& $userconfigasarray[1] &"}")
MsgBox (0, "SEND STATUS", "SEND HAS BEEN CALLED")
;Exit
Case "B"
MsgBox (0, "SWITCH STATEMENT", $userconfigasarray[2])
$myvar = $userconfigasarray[2]
;send("{LEFT}")
send("{"& $myvar &"}")
Case "C"
MsgBox (0, "SWITCH STATEMENT", $userconfigasarray[3])
$myvar = $userconfigasarray[3]
send("{"& $myvar &"}")
Case "D"
MsgBox (0, "SWITCH STATEMENT", $userconfigasarray[4])
$myvar = $userconfigasarray[4]
send("{"& $myvar &"}")
Case "E"
MsgBox (0, "SWITCH STATEMENT", $userconfigasarray[5])
$myvar = $userconfigasarray[5]
send("{"& $myvar &"}")
Case "F"
MsgBox (0, "SWITCH STATEMENT", $userconfigasarray[6])
$myvar = $userconfigasarray[6]
send("{"& $myvar &"}")
;loggit("SEND STATUS - SEND HAS BEEN CALLED")
Case "G"
MsgBox (0, "SWITCH STATEMENT", $userconfigasarray[7])
$myvar = $userconfigasarray[7]
send("{"& $myvar &"}")
Case "H"
MsgBox (0, "SWITCH STATEMENT", $userconfigasarray[8])
$myvar = $userconfigasarray[8]
send("{"& $myvar &"}")
Case "1"
MsgBox (0, "SWITCH STATEMENT", $userconfigasarray[9])
$myvar = $userconfigasarray[9]
send("{"& $myvar &"}")
Case "2"
MsgBox (0, "SWITCH STATEMENT", $userconfigasarray[10])
$myvar = $userconfigasarray[10]
send("{"& $myvar &"}")
Case "3"
MsgBox (0, "SWITCH STATEMENT", $userconfigasarray[11])
$myvar = $userconfigasarray[11]
send("{"& $myvar &"}")
Case "4"
MsgBox (0, "SWITCH STATEMENT", $userconfigasarray[12])
$myvar = $userconfigasarray[12]
send("{"& $myvar &"}")
Case "5"
MsgBox (0, "SWITCH STATEMENT", $userconfigasarray[13])
$myvar = $userconfigasarray[13]
Send("{"& $myvar &"}")
Case "6"
MsgBox (0, "SWITCH STATEMENT", $userconfigasarray[14])
$myvar = $userconfigasarray[14]
send("{"& $myvar &"}")
Case "7"
MsgBox (0, "SWITCH STATEMENT", $userconfigasarray[15])
$myvar = $userconfigasarray[15]
send("{"& $myvar &"}")
Case "8"
MsgBox (0, "SWITCH STATEMENT", $userconfigasarray[16])
$myvar = $userconfigasarray[16]
send("{"& $myvar &"}")
Case "9"
MsgBox (0, "SWITCH STATEMENT", $userconfigasarray[17])
$myvar = $userconfigasarray[17]
send("{"& $myvar &"}")
Case Else
MsgBox (0, "SWITCH STATEMENT", "Can't handle '" & $ch & "' <0x" & Hex(Asc($ch), 2) & ">")
;loggit("Can't handle '" & $ch & "' <0x" & Hex(Asc($ch), 2) & ">")
EndSwitch
我可以确认指令的正确语法是否已准备好通过函数send()发送,即
感谢。
答案 0 :(得分:1)
据我所知,发送功能没有失败的情况。如果它适用于你的设置发送密钥到记事本窗口,它将适用于其他一切。
这并不是说失败是不可能的。这只是一个边缘情况,并不是真的有必要。如果您确实认为Send
函数本身失败了,您可以尝试查看是否设置了winapi上一条错误消息(请参阅_WinAPI_GetLastErrorMessage
函数,确保使用_WinAPI_SetLastError
进行设置预先归零)。
窗口更有可能不接收击键,或忽略它们。为了测试您之后可以阅读窗口。
Send
功能应该是最后的手段。 ControlSend
函数要好得多,因为它不需要窗口激活(甚至可见)才能工作。