-1

我正在使用函数 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() 发送,即

  • $userconfigasarray[1] 持有 ESCAPE
  • $userconfigasarray[2] 持有 APPSKEY 等

谢谢。

4

1 回答 1

1

据我所知,发送功能没有失败的情况。如果它适用于您的设置,将密钥发送到记事本窗口,则它适用于其他一切。

这并不是说失败是不可能的。这只是一个边缘案例,实际上没有必要对其进行解释。如果您确实认为Send函数本身失败,您可以尝试查看是否设置了 winapi last 错误消息(查看_WinAPI_GetLastErrorMessage函数,确保您使用_WinAPI_SetLastError之前将其设置为零)。

窗口更有可能没有接收到击键,或者忽略它们。为了测试你可以在之后阅读窗口。

Send功能应该是最后的手段。该ControlSend功能要好得多,因为它不需要窗口处于活动状态(甚至可见)即可工作。

于 2013-07-02T15:24:43.463 回答