VBA调用autohotkey脚本

下面是在VBA里的代码:

Public Const MahkScriptsLoc = """F:/快盘/ahk/" 'starts w/a quote 注意开始的是3个双引号,结尾是一个双引号 路径结尾要有/ Public Const MahkPgmLoc = "D:/liuykDropbox/My Dropbox/MyGTD/AutoHotKey懒人包/AutoHotkey/AutoHotkey.exe" Sub callAHK() Dim clipbd As New DataObject 'set Reference to Microsoft Forms 2.0 Object Library 需要引用c:/WINDOWS/system32/FM20.DLL Dim retVal As Long, ahkParam As String clipbd.SetText "Some Text to put in Clipboard", 1 '用DataObject对象转存数据,以方便弄到剪贴板 clipbd.PutInClipboard '从DataObject写入剪贴板 ahkParam = "text to set AHK %1 with" '这个数据可以从剪贴板等地方获得 MsgBox ahkParam retVal = Shell(MahkPgmLoc & " " & MahkScriptsLoc & "可获取参数的脚本.ahk"" " & ahkParam) 'ahkParam is optional; scriptname ends w/a quote End Sub   

» 下面是:  可获取参数的脚本.ahk

; process command line parameters -- DEBUG: optional (see above)
getParams:
  If 0 > 0
  {
     Loop, %0% ; for each parameter
     {
        param := %A_Index%
MsgBox %param%
        ; check for switches
        StringLeft, paramType, param, 1
        If paramType = - ; switch indicator
        {
           ; determine type of switch
           StringMid, switch, param, 2, 1
           ; switch
           If switch = x ; DEBUG: template (replace "x")
           {
              ; access value (= next parameter)
              param = % A_Index + 1
              var_x := %param% ; DEBUG: template (replace "var_x")
           }
        }
     }
  }
Return

你可能感兴趣的:(Microsoft,脚本,Parameters,VBA,reference,Forms)