Convert VBA code to code that can run in ilogic

Convert VBA code to code that can run in ilogic

lzs013
Advocate Advocate
952 Views
2 Replies
Message 1 of 3

Convert VBA code to code that can run in ilogic

lzs013
Advocate
Advocate

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

 

 

0 Likes
Accepted solutions (1)
953 Views
2 Replies
Replies (2)
Message 2 of 3

clutsa
Collaborator
Collaborator
Accepted solution

You have to put it in a class

Class ThisRule
Declare Function SetCursorPos Lib "user32.dll"(ByVal X As Integer, ByVal Y As Integer) As Integer
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)
Declare Function GetCursorPos Lib "user32" (ByRef lpPoint As POINTAPI) As Integer
Public Structure POINTAPI
Dim X As Integer
Dim Y As Integer
End Structure

Const MOUSEEVENTF_LEFTDOWN = &H2
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
End Class
If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes
Message 3 of 3

lzs013
Advocate
Advocate

Thank you very much!

0 Likes