3

I created a script for AHK using ControlClick rather than regular mouse events so that I can keep using my mouse to do other tasks while I run the script. However, I need to simulate a mouse click and drag event. Is it possible to do this using the ControlClick event?

I tried using:

ControlClick, x365 y560, SM N910V,,,,D
ControlClick, x365 y770, SM N910V,,,,U

but with no luck.

Efie
  • 1,430
  • 2
  • 14
  • 34
  • Just covering some basics: Have you tried to implement [ControlClick's reliability recommendations](https://autohotkey.com/docs/commands/ControlClick.htm#Reliability)? Does the orthodox way (e.g. `MouseClickDrag` or regular clicks/MouseMove) work in that window? I'm assuming you're using some type of phone emulator. Does your code work in other windows like Windows Explorer? – MCL Jan 23 '17 at 09:49
  • doesnt `controlsend` `{lbutton down}` work? – phil294 Jan 31 '17 at 22:05

1 Answers1

1

Unfortunately this functionality is not available out of the box due to how ControlClick works. It can be accomplished with a COM call (if you are click & dragging a files to a window for example). I can't remember where I found this online, but pretty sure it was on the AHK forum.

;window = target window, standard AHK window syntax works eg: ahk_id hwnd or just WinTitle
;files = list of files to be dropped
DropFiles(window, files*)
{
  for k,v in files
    memRequired+=StrLen(v)+1
  hGlobal := DllCall("GlobalAlloc", "uint", 0x42, "ptr", memRequired+21)
  dropfiles := DllCall("GlobalLock", "ptr", hGlobal)
  NumPut(offset := 20, dropfiles+0, 0, "uint")
  for k,v in files
    StrPut(v, dropfiles+offset, "utf-8"), offset+=StrLen(v)+1
  DllCall("GlobalUnlock", "ptr", hGlobal)
  PostMessage, 0x233, hGlobal, 0,, %window%
  if ErrorLevel
    DllCall("GlobalFree", "ptr", hGlobal)
}

If you give specifics of what you are clicking and dragging, I could probably give you a much easier work-around.

nelsontruran
  • 514
  • 4
  • 18