forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Mouse Drag

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
dmonckton
Contributor
Contributor


Joined: 09 Aug 2002
Posts: 117
Location: Lewes, U.K.

PostPosted: Wed Sep 12, 2007 10:40 am    Post subject: Mouse Drag Reply with quote

Hi

Sorry if this has been done already.

I'm trying to find a way of automating the cropping of images in Paint.
I need to be able to send a sequence of:

LMouse Down --> Move mouse pointer --> LMouse Up

to the Paint window. Any body know how to do it?

Thanks

David...
Back to top
View user's profile Send private message
PGWARE
Web Host


Joined: 29 Dec 2001
Posts: 1565

PostPosted: Wed Sep 12, 2007 4:20 pm    Post subject: Reply with quote

If you are trying to crop bitmaps, jpegs you can use the vdsconv extension, it allows cropping and resizing of images.
Back to top
View user's profile Send private message
dmonckton
Contributor
Contributor


Joined: 09 Aug 2002
Posts: 117
Location: Lewes, U.K.

PostPosted: Thu Sep 13, 2007 11:26 am    Post subject: Reply with quote

OK I've done it! It took ages to find all the info on how to get
the API function to work. I've turned it all into a command.

Code:

rem MOUSEEVENTF_ABSOLUTE = 32768
rem MOUSEEVENTF_LEFTDOWN = 2
rem MOUSEEVENTF_LEFTUP = 4
rem MOUSEEVENTF_MIDDLEDOWN = 32
rem MOUSEEVENTF_MIDDLEUP = 64
rem MOUSEEVENTF_MOVE = 1
rem MOUSEEVENTF_RIGHTDOWN = 8
rem MOUSEEVENTF_RIGHTUP = 16
rem These values are logically OR'ed together to create a flag that is
rem passed to the API function. I have found that the mouse button
rem should be pressed first, mouse moved, then button released to
rem properly carry the drag operation

rem ***********************************************************
rem * COMMAND:
REM * mouseDrag [x],[y]
REM *
REM * DATE:
REM * 130907A
REM *
rem * DSCRPTN:
REM * Performs a left button mouse drag to absolute (x,y)
rem * screen coordinates. (0,0) is top-left.
rem *
rem ***********************************************************
:mouseDrag
    rem dll uses a screen surface of 65536 X 65536 ticks,top-left is (0,0)
    rem calculate the ticks per pixel
    %a = @div(65536,@sysinfo(screenwidth))
    %b = @div(65536,@sysinfo(screenheight))
    rem the absolute 'drag to' x,y co-ords are passed as %1,%2
    %x = @prod(%a,%1)
    %y = @prod(%b,%2)
    loadlib @windir(s)\user32.dll
    rem Left button down
    %h = @lib(user32.dll,mouse_event,NIL,INT:2,INT:%x,INT:%y,INT:0,INT:0)
    rem move mouse to absolute co-ordinates
    %h = @lib(user32.dll,mouse_event,NIL,INT:32769,INT:%x,INT:%y,INT:0,INT:0)
    rem Left mouse up
    %h = @lib(user32.dll,mouse_event,NIL,INT:4,INT:%x,INT:%y,INT:0,INT:0)
    freelib @windir(s)\user32.dll
    exit


I've playing around with it in paint and it works ok. I'm going to try
using it to drag a scrollbar to see if it can do that. You can use the
API to automate wheel movements but I don't need that yet.

Thanks

David
Back to top
View user's profile Send private message
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Thu Sep 13, 2007 1:11 pm    Post subject: Reply with quote

Wow you went to the low level API. Why didn't you just use the WM_MOUSEMOVE Message API?
_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
dmonckton
Contributor
Contributor


Joined: 09 Aug 2002
Posts: 117
Location: Lewes, U.K.

PostPosted: Fri Sep 14, 2007 3:15 pm    Post subject: Reply with quote

I'm on a bit of a API roll! Made this tiny utility to show where the mouse is for working out automation scripts.

Code:

Title Mouse Position
    DIALOG CREATE,MousePositon,-1,0,117,60,ONTOP,NOMIN,SMALLCAP
    DIALOG ADD,EDIT,EDIT1,22,11,40,19
    DIALOG ADD,EDIT,EDIT2,22,65,40,19
    DIALOG ADD,TEXT,TEXT1,26,55,5,13,@chr(44)
    DIALOG ADD,TEXT,TEXT2,8,29,,,X
    DIALOG ADD,TEXT,TEXT3,8,81,,,Y
    DIALOG SHOW

loadlib @windir(s)\user32.dll
%a = @binary(dword,0)@binary(dword,0)

:Evloop
    wait event,0.1
    goto @event()

:timer
    %b = @lib(user32.dll,GetCursorPos,BOOL,@addr("%a"))
    %c = @val(@substr(%a,1,4))
    %d = @val(@substr(%a,5,8))
    dialog set,edit1,%c
    dialog set,edit2,%d
    goto evloop

:Close
    freelib @windir(s)\user32.dll
    exit



BTW: I did look at WM_MOUSEMOVE but I found the mouse_event function easier to use, didn't know it was low level just found it using Google.

Cheers

David...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group