Jump to content
Sign in to follow this  

PostMessage to Drag files/text

Recommended Posts

Hi, this is my first post, I been reading a lot of post related with this subject, but I still cant find the appropiate way to solve the problem.
Im trying to Drag to select text on a minimized control (firefox flash).

But before trying that, Im setting a code to Drag a file within a window (like if using real mouse to click at x1,y1 move to x2,y2 release at x2,y2), if it work, I expect to see the file swap his position with other. I obtain the coordinates with "Autoit v3 Window Info" on the "Control" section.

At first, I thought PostMessage only worked with window's handles but tested a double click on the file position using the control handle and it works (maximized or minized). That helped me too to make sure the PostMessage-MouseInputNotifications work and the coordinates were correct.

My code is:

$winHan = WinGetHandle("[TITLE:ExampleFolder; Class:CabinetWClass]")
$conHan = controlgethandle($winHan,"","[CLASS:SysListView32; INSTANCE:1]")

$MK_LBUTTON = 0x0001
$WM_MOUSEMOVE   = 0x0200
$WM_LBUTTONUP   = 0x0202

$dll = DllOpen("User32.dll")
DllCall($dll, "bool", "PostMessage", "hwnd", $conHan, "int", $WM_LBUTTONDOWN,   "int", 0,       "long", _MakeLong(250,200))   ;Left Button Down at position 1
DllCall($dll, "bool", "PostMessage", "hwnd", $conHan, "int", $WM_MOUSEMOVE, "int", $MK_LBUTTON, "long", _MakeLong(700,450))   ;Move to position 2
DllCall($dll, "bool", "PostMessage", "hwnd", $conHan, "int", $WM_LBUTTONUP, "int", 0,       "long", _MakeLong(700,450))   ;Left Button Up at position 2

Func _MakeLong($iLo, $iHi)
   Return BitOR(BitShift($iHi, -16), BitAND($iLo, 0xFFFF))

So i have the .au3 file on my desktop and the ExampleFolder is open.

I tried to do a WinSetState($winHan,"",@SW_MAXIMIZE) and/or a ControlFocus ($winHan,"",$conHan) before the DllCall.

I tried to have the .au3 file inside the ExampleFolder.

I tried to use $MK_LBUTTON as the Wparam  for the $WM_LBUTTONDOWN message (Im not sure if it should be Null or $MK_LBUTTON).

I tried to do a $WM_LBUTTONDOWN at x1,y,1 and $WM_LBUTTONUP at x1,y,1 before those 3 messages on my code.

Something weird is, it works "very few times", after minimizing/closing/maximizing/open the folder..

The folder is in a subpath of my desktop (DesktopAutoitToolsExampleFolder) and I open it with a serie of double clicks so I think is allways a CabinetWClass (Not sure).

You see any error on the code?

The ClickDown-Move-ClickUp is equivalent to a drag operation?

What should be the Wparam for the $WM_LBUTTONDOWN message?

You know whats the recomendable way to set the sleep() values?

It could be some issue with the operative system (Im using xp)?

If Im not clear with something, please tell me :)

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...