- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
This macro works perfectly, but I failed to convert it into code that can run in ilogic. Who can help me?
VBA code:
Private Declare PtrSafe Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private Declare PtrSafe Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Private Declare PtrSafe Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
X As Long
Y As Long
End Type
Public Const MOUSEEVENTF_LEFTDOWN = &H2
Public Const MOUSEEVENTF_LEFTUP = &H4
Sub main()
Dim P As POINTAPI
GetCursorPos P
SetCursorPos 300, 500
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
SetCursorPos P.X, P.Y
End Sub
iLogic code:
Public Declare Function SetCursorPos Lib "user32.dll"(ByVal X As Integer, ByVal Y As Integer) As Integer
Public Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Integer, ByVal dwExtraInfo As Integer)
Public Declare Function GetCursorPos Lib "user32" (ByRef lpPoint As POINTAPI) As Integer
Public Structure POINTAPI
Dim X As Integer
Dim Y As Integer
End Structure
Public Const MOUSEEVENTF_LEFTDOWN = &H2
Public Const MOUSEEVENTF_LEFTUP = &H4
Private Sub Main()
Dim P As POINTAPI
GetCursorPos(P)
SetCursorPos(300, 500)
mouse_event(MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
SetCursorPos(P.X, P.Y)
End Sub
Solved! Go to Solution.