Double click to open SAP Icon on Desktop

%3CLINGO-SUB%20id%3D%22lingo-sub-312328%22%20slang%3D%22en-US%22%3EDouble%20click%20to%20open%20SAP%20Icon%20on%20Desktop%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-312328%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20All%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20trying%20to%20Open%20SAP%20using%20Macro.%20I%20am%20trying%20to%20use%20Mouse%20control%20to%20double%20click%20on%20the%20SAP%26nbsp%3B%3C%2FP%3E%3CP%3EI%20tried%20below%20code%20but%20still%20its%20not%20working.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETask%20is%20i%20need%20to%20double%20click%20on%20SAP%20Icon%20or%20any%20icon%20on%20the%20desktop.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPublic%20Declare%20Function%20SetCursorPos%20Lib%20%22user32%22%20(ByVal%20x%20As%20Long%2C%20ByVal%20y%20As%20Long)%20As%20Long%3CBR%20%2F%3EPublic%20Declare%20Sub%20mouse_event%20Lib%20%22user32%22%20(ByVal%20dwFlags%20As%20Long%2C%20ByVal%20dx%20As%20Long%2C%20ByVal%20dy%20As%20Long%2C%20ByVal%20cButtons%20As%20Long%2C%20ByVal%20dwExtraInfo%20As%20Long)%3CBR%20%2F%3EPublic%20Const%20MOUSEEVENTF_LEFTDOWN%20%3D%20%26amp%3BH2%3CBR%20%2F%3EPublic%20Const%20MOUSEEVENTF_LEFTUP%20%3D%20%26amp%3BH4%3CBR%20%2F%3EPublic%20Const%20MOUSEEVENTF_RIGHTDOWN%20As%20Long%20%3D%20%26amp%3BH8%3CBR%20%2F%3EPublic%20Const%20MOUSEEVENTF_RIGHTUP%20As%20Long%20%3D%20%26amp%3BH10%3C%2FP%3E%3CP%3EPrivate%20Sub%20RightClick()%3CBR%20%2F%3ESetCursorPos%20200%2C%20185%3CBR%20%2F%3Emouse_event%20MOUSEEVENTF_RIGHTDOWN%2C%200%2C%200%2C%200%2C%200%3CBR%20%2F%3Emouse_event%20MOUSEEVENTF_RIGHTUP%2C%200%2C%200%2C%200%2C%200%3CBR%20%2F%3ESetCursorPos%20230%2C%20195%3CBR%20%2F%3Emouse_event%20MOUSEEVENTF_RIGHTDOWN%2C%200%2C%200%2C%200%2C%200%3CBR%20%2F%3Emouse_event%20MOUSEEVENTF_RIGHTUP%2C%200%2C%200%2C%200%2C%200%3CBR%20%2F%3E%3CBR%20%2F%3EEnd%20Sub%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%2C%3C%2FP%3E%3CP%3EChandrakanth.K%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-312328%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Highlighted
Contributor

Hello All,

 

I am trying to Open SAP using Macro. I am trying to use Mouse control to double click on the SAP 

I tried below code but still its not working. 

 

Task is i need to double click on SAP Icon or any icon on the desktop.

 

Public Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Public Declare 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)
Public Const MOUSEEVENTF_LEFTDOWN = &H2
Public Const MOUSEEVENTF_LEFTUP = &H4
Public Const MOUSEEVENTF_RIGHTDOWN As Long = &H8
Public Const MOUSEEVENTF_RIGHTUP As Long = &H10

Private Sub RightClick()
SetCursorPos 200, 185
mouse_event MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0
SetCursorPos 230, 195
mouse_event MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0

End Sub

 

Regards,

Chandrakanth.K

0 Replies