Drag and Drop without using pointer.

Ask gaming related questions
Halibucza
Posts: 4
Joined: 23 Jan 2021, 07:38

Drag and Drop without using pointer.

Post by Halibucza » 23 Jan 2021, 07:54

Hello.
I have made useful script that helps me picking up items - thing is, it also takes control over my mouse. So I'd like to ask, if it possible to execute "mousedrag" from specified coords to another specified coords without using my mouse pointer. I have read about ControlClick but couldn't get it as dragging and have been reading about PostMessage to execute mouse move, but actually I am newbie and couldn't understand it all.

Here is my actual script that looks terrible but works as intented except that it takes my mouse - while cliking F10 it does find specified pixel in restricted area then moves mouse to that spot, drags it and hover over my equipment to place it there:

Code: Select all

#ifwinactive

F10::
PixelSearch, ItemX, ItemY, 1800, 600, 1700, 500, 0xFFE047, 1 , RGB FAST
if ErrorLevel = 0
Mousemove, ItemX, ItemY, 0
Send, {lbutton down}
sleep, 20
Send, {lctrl down}
Random x, 1600, 1700
Random y, 590, 655
Mousemove, x, y, 0
Send, {lbutton up}
Send, {lctrl up}
return
User avatar
mikeyww
Posts: 5360
Joined: 09 Sep 2014, 18:38

Re: Drag and Drop without using pointer.

Post by mikeyww » 23 Jan 2021, 08:17

Halibucza
Posts: 4
Joined: 23 Jan 2021, 07:38

Re: Drag and Drop without using pointer.

Post by Halibucza » 23 Jan 2021, 08:22

But this will move my mouse cursor which I don't want.
User avatar
mikeyww
Posts: 5360
Joined: 09 Sep 2014, 18:38

Re: Drag and Drop without using pointer.

Post by mikeyww » 23 Jan 2021, 08:27

I see. If it's a control, you could use ControlMove. That's about where my knowledge ends! Others can chime in with additional options. Window Spy can identify the control name.
Halibucza
Posts: 4
Joined: 23 Jan 2021, 07:38

Re: Drag and Drop without using pointer.

Post by Halibucza » 23 Jan 2021, 13:41

I've been trying to do something myself with Post/SendMessage - but all I achieved is that script is not looking for specified pixel but just execute "SendMessage" when Pixel of that colour is in restricted area(1800, 600, 1700, 500) - that means it grabs items under my CURSOR and still uses CURSOR position to do this. Simplify - I hover over item, click f10, then if specified pixelcolor is in area it performs "Lbutton down>hold>Lbutton up".

Code: Select all

#ifwinactive

CoordMode, Pixel, Screen
CoordMode, Mouse, Screen

lParam = ItemX ItemY
lParam2 = x y
Random x, 1600, 1700
Random y, 590, 655
F10::
PixelSearch, ItemX, ItemY, 1800, 600, 1700, 500, 0xFFE047, 1 , RGB FAST
if ErrorLevel = 0
	SendMessage, 0x201, 0x0001, %lParam%, , ahk_exe something.exe         ;WM_LBUTTONDOWN
	sleep, 100
	SendMessage, 0x0200, 0, %lParam2%, , ahk_exe something.exe 		;WM_MOUSEMOVE
	sleep, 100
	SendMessage, 0x202 , 0, %lParam2%, , ahk_exe something.exe                ;WM_LBUTTONUP
return
So, still looking for solution to move things without using my mouse cursor.

EDIT
After a few hours of lurking I have found something like this: https://www.autohotkey.com/boards/viewtopic.php?t=34943 I've coppied and edited most of the code which I don't really understand (I assume it's writing coordinates into memory and then loads) and got SCRIPT that MOVES things under my CURSOR when PIXELSEARCH found pixel to specified x,y points but I want to be items found by PIXELSEARCH to be moved, still not perfect but close to! Any ideas? This is the code:

Code: Select all

#ifwinactive


F10::
PixelSearch, ItemX, ItemY, 1800, 600, 1700, 500, 0xFFE047, 255, RGB FAST
CoordMode, Pixel, Screen
if !hWnd := DllCall("WindowFromPoint", Int,ItemX, Int,ItemY, Ptr)
if !hWnd := DllCall("WindowFromPoint", UInt64,(ItemX&0xFFE047)|(ItemY<<32), Ptr)
if !hWnd := DllCall("WindowFromPoint", UInt64, x|(y << 32), Ptr)
	return
VarSetCapacity(POINT, 8, 0)
NumPut(ItemX, POINT, 0, "Int"), NumPut(ItemY, POINT, 4, "Int")
DllCall("user32\ScreenToClient", Ptr,hWnd, Ptr,&POINT)
ItemX := NumGet(POINT, 0, "Int"), ItemY := NumGet(POINT, 4, "Int")
;ToolTip, % ItemX " " ItemY
x := 1650
y := 620
if ErrorLevel
PostMessage, 0x0200, 0, ItemX&0xFFE047|ItemY<<16,, % "ahk_id " hWnd 		;WM_MOUSEMOVE
sleep, 5
PostMessage, 0x0201, 0, ItemX&0xFFE047|ItemY<<16,, % "ahk_id " hWnd         ;WM_LBUTTONDOWN
sleep, 5
PostMessage, 0x0200, 0, x|y<<16,, % "ahk_id " hWnd			;WM_MOUSEMOVE
sleep, 5
PostMessage, 0x0202, 0, x|y<<16,, % "ahk_id " hWnd               ;WM_LBUTTONUP
sleep, 5
return
Halibucza
Posts: 4
Joined: 23 Jan 2021, 07:38

Re: Drag and Drop without using pointer.

Post by Halibucza » 26 Jan 2021, 06:05

Hello, I am still trying to make this script, right now it looks like it:

Code: Select all

#ifwinactive

CoordMode, Pixel , Screen

x := 1650
y := 620
lparam := pX | (pY << 16)
lparam2 := x | (y << 16)

f10::
PixelSearch, pX, pY, 1900, 1000, 1750, 500, 0xFFE047, 1, Fast 
if Errorlevel
{
PostMessage, 0x0200, 0, %lparam%,, ahk_exe something.exe 		;WM_MOUSEMOVE
sleep, 10
PostMessage, 0x0201, 0x0001, %lparam%,, ahk_exe something.exe          ;WM_LBUTTONDOWN
sleep, 10
PostMessage, 0x0200, 0x0001, %lparam2%,, ahk_exe something.exe 		;WM_MOUSEMOVE
sleep, 10
PostMessage, 0x0202, 0, %lparam2%,, ahk_exe something.exe                ;WM_LBUTTONUP
}
return
Problem is - it would pick things under my cursor aka execute post messages whenever I hover over thing and move to "x,y". Script completly ignores PixelSearch and command to execute left mouse click + hold on "pX and pY" coordinates then move. Maybe there is something with scructure of this code?
Post Reply

Return to “Gaming”