我仍然很新,我尝试使用vb.net项目制作有趣的东西,但遇到了问题
无法加载DLL'AutoHotkey.dll
System.DllNotFoundException HResult = 0x80131524消息=无法加载DLL'AutoHotkey.dll':找不到指定的模块。 (来自HRESULT的异常:0x8007007E)源= WindowsApp2 StackTrace:位于C:\ Users \ test \ source中的WindowsApp2.Form1.Button1_Click(对象发送方,EventArgs e)处的WindowsApp2.Form1.ahktextdll(字符串脚本,字符串选项,字符串参数) \ repos \ WindowsApp2 \ WindowsApp2 \ Form1.vb:System.Windows.Forms.Control.OnClick(EventArgs e)在System.Windows.Forms.Button.OnClick(EventArgs e)在System.Windows.Forms.Button的第19行。位于System.Windows.Forms.Control.WmMouseUp(Message&m,MouseButtons button,Int32 clicks)的OnMouseUp(MouseEventArgs mevent)位于System.Windows.Forms.ButtonBase.WndProc(在System.Windows.Forms.Button.WndProc(Message&m)在System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&m)在System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&m)在System.Windows.Forms.UnsafeNativeMethods.Dispa上的System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,Int32 msg,IntPtr wparam,IntPtr lparam) System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID,Int32原因,Int32 pvLoopData)在System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner( Int32原因,ApplicationContext上下文)在System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32原因,ApplicationContext上下文)在Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()在Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel() WindowsApp2.My.MyApplication.Main(String [] Args)中的Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String [] commandline)
我的代码:
Imports System.Runtime.InteropServices
Imports AutoHotkey.Interop
Imports AutoHotkey
Imports System.IO
Public Class Form1
' Dim ahk = New AutoHotkey
<DllImport("AutoHotkey.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Unicode)>
Private Shared Function ahktextdll(ByVal script As String, ByVal options As String, ByVal param As String) As Integer
End Function
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim n As Object = vbLf
Dim script As Object = ("SetTitleMatchMode, 2" & (n & ("Run, calc.exe" & (n & ("Sleep, 1000" & (n & ("WinGet, rid , ,Rechner, , , " & (n & ("WinActivate, ahk_id %rid%" & (n & ("IfWinExist, ahk_id %rid%" & (n & ("{" & (n & (vbTab & "WinMove, ahk_id %rid%,, 0, 0, , " & (n & ("}" & (n & ("MouseClick, left, 105, 184" & (n & ("Sleep, 100" & (vbCrLf & ("MouseClick, left, 147, 215" & (n & ("Sleep, 100" & (vbCrLf & ("MouseClick, left, 110, 185" & (n & ("Sleep, 100" & (vbCrLf & ("MouseClick, left, 178, 263" & (n & ("Sleep, 100" & (n & "msgbox, 81"))))))))))))))))))))))))))))))))))
ahktextdll(script, "", "")
MsgBox("ende")
End Sub
End Class