I'm trying to 'Drop' an image file at the current mouse location, FileType Image (BMP,JPG,PNG).
i've written code to grab an image from the clipboard and save it. But now i want to grab this image and drop it at mousepos when a hotkey is pressed.
The hotkey is working without my app having the focus ( as intended ) but now im stuck at actually dropping this file when the hotkey is pressed.
My form:
Module:Code:Option Explicit Private Sub Command1_Click() Dim ImageName$ Picture1.Picture = Clipboard.GetData Clipboard.Clear ImageName$ = InputBox("Provide filename") FileName$ = ImageName$ Text1.Text = FileName$ End Sub Sub On_Event_CtrlShiftV(FileName$) Dim FilePath$, MouseX&, MouseY& FilePath$ = "c:\AnyLocation\" SavePicture Picture1.Image, FilePath$ & FileName$ & ".png" Call GetCursorPos(Mpos) MouseX = Mpos.x MouseY = Mpos.y 'drop the saved image at cursorposition as if it was dragged and dropped. End Sub Private Sub Timer1_Timer() If Picture1.Picture Then If GetAsyncKeyState(vbKeyF9) Then 'Hotkey pressed,do dragdrop at mousepos Call On_Event_CtrlShiftV(Text1.Text) End If End If End Sub
Im just not sure how to begin the dropping of the file that is created.Code:Option Explicit Public Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer Public Const VK_RSHIFT = &HA1 Public Const VK_RCONTROL = &HA3 Public Type POINTAPI x As Long y As Long End Type Public Mpos As POINTAPI Public FileName$




Reply With Quote
