Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Moving And Image W/ The Mouse.


Hi, I am working on a simple board game. When the player moves a piece, an image box appears (that moves with the mouse), the picturebox containting the board is redrawn wihout that piece, and it is moved to the new spot and the "dummy" piece dissapears and the board is redraw again with the new move. My only problem is: the pieces are round, and the image box that moves is square. When you move the piece, you can see the square border. What can I do about this?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Moving Image W/ Mouse
I wanted to have an image move according to the mouse cursor. I've managed to do that with a mousemove procedure on the form. However, the image moves fine on the right side of the screen, but the image doesn't move so smooth on the left side. I'm not sure why there would be a difference, and I cannot change the effect.

Moving An Image With The Mouse
hey all, just wondering if anyone could point me in the direction of moving an image by clicking on it, and while holding the mouse button down and moving it in any direction, how to change the properties of the image(in this case, the .left, or .top properties)
Thanks in advance.

Moving An Image With The Mouse.
Hi. I am creating a Vscroll OCX and i have everything finished excpet for moving the slider bar with the mouse when it is clicked on. Currently i am using GetCursorPos to try and move it.. Which it does move but depending on where the form ison the screen it moves differently.


What is the best way togo about something like this?

THe code i have so far is

VB Code:
Public Declare Function GetCursorPos Lib "user32.dll" (lpPoint As POINT_TYPE) As Long Type POINT_TYPE  X As Long  Y As LongEnd Type Private Sub imgSLIDER_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 ThenGetCursorPos COORD    imgSLIDER.Top = COORD.Y * Screen.TwipsPerPixelY - 2200   End If End Sub



The -2200is just and arbitrary number. IT has no meaning. i'm just trying to figure this out.


I have attached a pic of the control to give you an idea of what it looks like.

Thanks alot for any help!

Moving The Mouse And Clicking Mouse Buttons With Software
I am trying to move the mouse and press buttons using software. I have figured out how to move the mouse using the Cursor class, but I can't figure out how to create mouse clicks.

If that isn't clear enough, here is a simplistic example of the program I am trying to complete:

1. Move mouse to screen coordinate 100,100

2. Left Click


Code would be great, but I'm really just looking for a shove in the right direction. I've been pouring over MSDN and I can't find anything.

- How To Draw Image On Mouse Down / Mouse Move
hi friends,
i hv two picture boxes. pic1 contains a image (16 * 16 pixel). on mouse down of pic2 i need to draw the pic1 image on pic2, a perfect square
how do i do that
plz help.

thanx in advance
harry

regards

harry

Moving Mouse
I want to make my mouse move after a period of time using timer, I have got the code of changing position.. but I don't know how to put it in a timer (below)...



Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long

Private Type POINTAPI
X As Long
Y As Long
End Type

Private Sub MoveMouse()
Dim pt As POINTAPI
GetCursorPos pt
SetCursorPos pt.X, pt.Y - 40
SetCursorPos pt.X, pt.Y
End Sub




and my timer with other statements:

Private Sub Timer1_Timer()
Dim X As String
X = "Windows is on"
Print X
End Sub

Mouse Moving
Here is the code I Have so far.....


Code:
Option Explicit
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" _
(lpPoint As POINTAPI) As Long
Dim Pt As POINTAPI

Private Sub Timer1_Timer()
GetCursorPos Pt
lblxpositon.Caption = Str$(Pt.X)
End Sub
It works fine.

I want to know where the actual number is located in and how I could change that number. What I want is to move the mouse up 200 every time it gets to 350.

Something like


Code:
If GetCursorPos.Pt = 350 Then
GetCursorPos.Pt = GetCursorPos.Pt + 200
End if
This is a complete guess and i'm sure it is wrong

Thanks
Edit by moderator: Please post your threads in the appropriate forum.

Moving The Mouse?
I'm making a macro program and want to move the mouse to a specific location on the screen, but I each macro file to operate independantly of screen resolution.... how can I do that? The optimal way to do this would be to get a percent, multiply times the resolution and then move the mouse there and click, but any ideas?

Thanks!
sirSolarius

Mouse Not Moving?
is there a way of detecting if the mouse has not moved for x seconds? I want to display a screensaver within my app based on this.. similar to how MSN sets your status to 'away' if you dont move the mouse for x seconds

Help Moving Mouse
In VB6 i'm trying to move my mouse around the screen and click. so for i found a code to move my mouse but i can't find out the coordinates for off my program and how to tell the mouse to move. heres my code:
Code:
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, _
ByVal Y As Long) As Long
Private Declare Function ClientToScreen Lib "user32" (ByVal hWnd As Long, _
lpPoint As POINTAPI) As Long
Sub MoveMouseCursor(ByVal X As Long, ByVal Y As Long, _
Optional ByVal hWnd As Long)
If hWnd = 0 Then
SetCursorPos X, Y
Else
Dim lpPoint As POINTAPI
lpPoint.X = X
lpPoint.Y = Y
ClientToScreen hWnd, lpPoint
SetCursorPos lpPoint.X, lpPoint.Y
End If
End Sub

Moving The Mouse
If i click on a picturebox how can i get it so the mouse moves to the top left of the picture box?

Moving Mouse
How can I move the mouse using a timer so it move the mouse from its position to another one every 2 or 3 minutes for example..


Thanks for help,
zeid

Mouse Moving
If the leftmousebutton is pressed (and hold down) the mousepointer has to move upwards or sideways smoothly.

Any idea where to start or what to use?

Moving Mouse
I use the code below for detecting if the computer is idle, how can i detect if the mouse is being moved or keys are being pressed?


VB Code:
Private Sub ActivityTimer_Timer()    Static lNotActive As Long    Static LastCursorPos As POINTAPI    Dim CursorPos As POINTAPI    Dim lCounter As Long            'Count another second    If start = 0 Then GoTo end2    If pauseclick = 1 Then GoTo end2    lNotActive = lNotActive + 1     'Get the current position of the mouse    GetCursorPos CursorPos        If (CursorPos.x <> LastCursorPos.x) Or (CursorPos.y <> LastCursorPos.y) Then        'The mouse has moved         'Save the new position        LastCursorPos = CursorPos        'Reset the seconds count                        lNotActive = 0    Else        'The mouse hasn't moved, check the keys        For lCounter = 0 To 255            If GetAsyncKeyState(lCounter) <> 0 Then                'The key was pressed, reset the counter                lNotActive = 0            End If        Next    End If        If lNotActive = 2 Then        pause2_Click        notactive = 1    End Ifend2:End Sub

Moving Tha Mouse???
da_silvy, im prolly doin somethin wrong but... i added a timer and under "Private Sub Timer1_Timer()" i pasted yo code, and when i press play an error pops up sayin "Compile error. Only Comments may appear after end sub end function or end property."

just so u know im new to visual basic so...

Moving The Mouse
Is there a way to actually move the mouse pointer via code?

Mouse Moving
hi

im am a vb newbie and have a question:
i found this commands to move the mouse cursor:

Declare Function SetCursorPos& Lib "user32" _
(ByVal x As Long, ByVal y As Long)


t& = SetCursorPos(0,0)


when i copy this commands in a *.vbs file it doesnt work
what commands must i add that it works?
please help me. without help i will never learn visual basic


thanks

Moving An Image To Move Another Image
Im creating my first small program for my assignment and ive done the design and code, just havign trouble with another part if anyone could help me please.

Here is my whole code first off.


Code:
Option Explicit

Private Sub cmdBat_Click()

While imgBall.Left < imgBatter.Left
'Moves the ball away from the bowler
imgBall.Left = imgBall.Left + 1
'Comment
DoEvents
Wend
'Comment
While imgBall.Left < imgBatter.Left
'Comment
imgBall.Top = imgBall.Top - 1
'Comment
imgBall.Left = imgBall.Left
' Allows the user to respond to another button
DoEvents
Wend
End Sub

Private Sub cmdBowl_Click()

While imgBall.Left < imgBowler.Left
' Moves the ball towards the batter
imgBall.Left = imgBall.Left - 1
' Allows the user to respond to another button
DoEvents
Wend
'Comment
While imgBall.Left < imgBowler.Left
'Comment
imgBall.Top = imgBall.Top + 1
'Comment
imgBall.Left = imgBall.Left
'Comment
DoEvents
Wend

End Sub

Private Sub cmdExit_Click()
End
End Sub

Private Sub cmdStart_Click()
imgBowler.Left = 8400
imgBowler.Top = 960
imgBatter.Left = 840
imgBatter.Top = 960
imgBall.Left = 7920
imgBall.Top = 2520
End Sub
What i need to do, as the ball gets to the bat for the bat to hit the ball and move it back where it came from. Ive done so far that the ball goes past the batter and when the bat button is pressed the ball comes back to the bat and goes back again.

I cant work out how to move the ball back when the ball is moving and the button is pressed. Im not advanced in programing either, ive been doing it for about a year

Here is an EXE of the program so far to demonstate
<link removed>

Moving Mouse Over The List Box
Hi, I am trying to manually make my own Menu Editor. I don't like how you cannot edit the font and color of the regular menu editor.I got it all working and looking great, but there are 2 small problems that I cannot figure out how to fix.

I want to be able to move the mouse over a list box, and just like a regular menu I want the one that is under the mouse to be highlighted. And as you move the mouse over different selections it will highlight them, without yet clicking on the mouse, anyone know how to do that?

Also, does anyone know how to change the forecolor of a command button? It is possible?


I appreciate any help.

Thanks,

Dan

Moving Object By Mouse!
Ok I have a bit of Newbie problem..(I quess)

I have a form with a (small) pictbox control and like it to move around the form when/where ever I move the mouse. I don't want to drag en drop I don't even want to "click" first before moving. Now I sort of have this working for one small detail. As an object is basicly moved by changing its Left and top posision to x and y there doesn't seem to be a way of moving it by its midpoint possision or in otherwords the center of the object (pictbox) doesn't seem to be stucked to the mouse. So my pictbox only moves when I put my mouse pointer to the left border of the pictbox, the movement is then fine, but when I move to the right, the pictbox doesn't move before I "hit" the right border and then it doesn't move but sort of jumps to the "new" left posision.
making the movement not very smoothly..the same happens up and down! (up works better than down)

So I actually only sort of want to stick my mouse pointer to the center of the pictbox and then move it (maybe I should just use a piece of tape uh..)

Moving Text Box With Mouse
Hi,

I have a text box within a picturebox which I want to move when I hold down the mouse button.

I have tried using the X and Y coord for the mouse but cant get the calculation right.

heres the code in module:


Code:
Private Type POINTAPI
X As Long
Y As Long
End Type

Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long

On the form:


factor = 1


Code:
Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
GetCursorPos P
P.X = Int(P.X / factor) * factor
P.Y = Int(P.Y / factor) * factor
TextX = P.X - Label1.Left
TextY = P.Y - Label1.Top
Timer1.Enabled = True
End Sub

Private Sub Label1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Timer1.Enabled = False
End Sub

Private Sub Timer1_Timer()
GetCursorPos P
P.X = Int(P.X / factor) * factor
P.Y = Int(P.Y / factor) * factor
Label1.Left = P.X - TextX
Label1.Top = P.Y - TextY
End Sub

When I click and move the mouse, the label moves but not under the mouse. it moves about an tenth the distance.

I ahve attached the sample code as well.

Cheers,
pG

Moving A Button With Mouse?
Hi all, well i am new to excel VB and was wondering how i can create a userform with a command button that moves when my mouse goes over the button?

I am really new so if it's possible could it be in doled down terms

Cheers

Moving Mouse Pointers
Is there I was I can move the mouse pointer in my program? Example, when user clicks on something, the program moves the pointer to a particular point on the form, like the pointer, "jumped," to that location.

I have no clue if VB can do this. Is there like a Mouse.Goto(x,y) function?

Moving Mouse Pointer
Hai everybody,

Is there any method to move the mouse pointer from one point to another point on the form at run time.
Thank you all.

Moving Form With Mouse
I am making a program that requires me to be able to move a form by clicking and dragging it. Except it doesn't have a border so it won't work. On top of that, I want to be able to click a picture on the form and drag the entire form. How can I do that?

Auto Moving The Mouse
hi, wat i wana be able to do is move the mouse over a certain button or sumfing on the form, for example i wana be able to move it so its over the exit button if a condition is met.

also ive got some plans for animation purposes where i wana show the mouse moving across the screen, but i dont wana use pictures of mouse cursers, if u c wat i mean

thanx

andy

Moving A Form Around Using The Mouse
Hi

I have an application that I have removed the title bar and control box because I have customised the graphics. With the loss of the title bar and window controls I have also lost the ability to move my application around on the desktop. What code do I need to make my form move with the movement of my mouse?

Thanks for any help

SC

Moving The Mouse Arrow
Does anyone know if API calls can be used to place the mouse arrow over a program button on the taskbar?

I am using Excel VBA.

Any help would be appreciated.

Click The Mouse Without Moving!
I'm SOO Frustrated. I've seen it done before and i'm about 99% positive it's with SendMessage!

I need to know how to make the mouse CLICK on something on a program without moving the mouse or even activating that window..

Basically, SENDING a CLICK to it instead of CLICKING it...

Thanks to anybody that can help!

Moving The Mouse To Position X,Y
I know there is a simple way to move the mouse to any position on the screen in vb. A search brought up nothing specific to what I am trying to do. Basically, I have two textboxes on a form to represent x and y. When I click a command button, I want the mouse to move to position x and y. Any hints?

[2005] VB.net: Moving Mouse, Do I Really Need API?
Hi all, let me explain my part, programming is definitely not my bowl of rice. a noob. I'm developing my test tool, and coming to this part, mouse simulation. Read up several threads on moving the mouse, go through MSDN on GetCursorPos and SetCursorPos, just do not understand the theory behind and how to apply.

My obj is when data are parsed into the web Browser fields, my mouse will move to the submit btn itself, and click.

so now at the moving mouse portion. So many threads I came across, all the similar methods but reason for their existences? I just copy n paste them as I browse through, trying to catch the logics

can someone give me comments? appreciate.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Option Explicit On
Imports System.Runtime.InteropServices <-- required for POINTAPI, am i right

Public Class Form1

Private Declare Function GetCursorPos Lib "user32" (ByVal lpPoint As POINTAPI) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, ByVal lpRect As RECT) As Long
Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function ClientToScreen Lib "user32" (ByVal hWnd As Long, ByVal lpPoint As POINTAPI) As Long
Private Declare Function GetWindowPlacement Lib "user32" (ByVal hwnd As Integer, ByRef lpwndpl As WINDOWPLACEMENT) As Integer
Private Declare Function ScreenToClient Lib "user32.dll" (ByVal hwnd As Long, ByRef lpPoint As POINTAPI) As Long

Private Structure RECT <-- RECT is for what?
Public Left As Integer
Public Top As Integer
Public Right As Integer
Public Bottom As Integer
End Structure

Private Structure POINTAPI <-- for mouse coordinates, right?
Public x As Integer
Public y As Integer
End Structure

Private Structure WINDOWPLACEMENT <-- for? some threads had this, some do not
Public Length As Integer
Public flags As Integer
Public showCmd As Integer
Public ptMinPosition As POINTAPI
Public ptMaxPosition As POINTAPI
Public rcNormalPosition As RECT
End Structure

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click <-- alot using command1 which I guess is frm old vb. but what does the content do?
Dim wp As WINDOWPLACEMENT
wp.showCmd = Marshal.SizeOf(wp)
Dim x As Integer
x = GetWindowPlacement(&H1075C, wp)
MessageBox.Show(x)
End Sub

Sub MoveMouseCursor(ByVal X As Long, ByVal Y As Long, ByVal hWnd As Long) <-- definitely I will need this, to move my mouse right, but the contents?
If hWnd = 0 Then
SetCursorPos(X, Y)
Else
Dim lpPoint As POINTAPI
lpPoint.x = X
lpPoint.y = Y
ClientToScreen(hWnd, lpPoint)
SetCursorPos(lpPoint.x, lpPoint.y)
End If
End Sub

End Class

Moving Mouse && Exiting Sub
K, I have two questions....
Is there a way to move the mouse? I want to do a replay of tic tac toe if someone wins and chooses to watch the replay. But I want the mouse to move where their mouse moved at the time. Is this possible?
Second question -> If I call a sub is there a way to exit out of both subs from the called sub? eg.


VB Code:
Private Sub cmdStart_Click()call ESubEnd Sub Sub ESub()'I want to exit both the first and this sub out of here'I don't want to return back to the other subEnd Sub


Thanks to all that help

Moving The Mouse Remotely
I looked for a way to move the mouse through random number generation by this technique:

Declare Function SetCursorPosition& Lib "user32" _
(ByVal x As Long, ByVal y As Long)

SetCursorPos(x,y)

But it did not work.... any ideas?

Moving The Mouse In Code
Does anyone know of any way to do this? For example, if you click on an picture control, have something in the code move your mouse pointer so that it is now in the exact center of the picture control? Any suggestions?

Moving The Mouse Around Automatically
Does anyone know how to move the mouse around automatically, and stop when it comes over a particular piece of text or an image.

Moving The Mouse Cursor
this has prolly been asked a bazillion times, but what is the simplest what to move the mouse cursor (dont be a smarta$$ and say use the mouse) :P

Moving The Mouse Cursor
this has prolly been asked a bazillion times, but what is the simplest what to move the mouse cursor (dont be a smarta$$ and say use the mouse) :P

Moving The Mouse With A VB Program
I get the mouse to move through vb? like move it from one corner to another corner? Or something to this exstant?

Moving Clicking Mouse
does anyone know the vb code for moving your mouse from point "A" to another point "B" my mouse moves from my computer icon to my documents icon, with different codinates and also goes back and forth. also i want it to click a point A then click at point B. please dont give me this:

Option Explicit
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long

Private Sub Form_Load()
SetCursorPos 500, 500
End Sub


i want it to move to another spot then back again and click at the 2 spots, thx

Moving A Picture With Mouse
Hey...........is it possible to move a picture around the form with the
mouse ?

I have a form with one picture on it........when I hold down the mouse I
would like the picture to follow the mouse until mouse is released and then
place the picture there.........can anyone tell me how with a short code
example ??

Moving Control Along With The Mouse
Hello all,

I have two issues that I am hoping that you could help me resolve.

1- Is there a way that i can move a picture control along with my mouse. If i mopve my mouse i want the picture to follow the mouse?

2- When i create controls and add them dynamically to a form at run time how can i capture their names to access their events? ortry to refrence them and their events?

Thank you so much in advance!

Hisham

Mouse Moving && Clicking
How can i auto move the mouse and let it left click??

not in the program but everywhere on my desktop

Moving The Mouse Cursor
I have to bother you again but this time with a different question.
I would like to know what to do i order to move the mouse cursor on the screen without physically touching the mouse. For instance, I would like my application to move the mouse cursor from time to time one inch to the left, and then one inch back to the right again.
Does anybody know if this is considered by the system as if you are physically moving the mouse and, for instance, is preventing the screen saver from launching?

Any ideas would be appreciated.

Thank you for your time, God bless.

Vio


Vio

Moving Images With Mouse
How do i get am image to move left and right when my mouse moves left and right?

Image Follows Mouse, But Image Bounces And Distorts
I simply have an image follow the mouse when the left mouse button is depressed. This is basically letting the user drag the image accross a picture box. Here's my problem, when the user drags the image accross the picture box, the image starts to bounce all over the place and it gets all distorted and crazy. How can I prevent this from happening?
Code:
Dim Move As Boolean

Private Sub Image1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
Image1.MousePointer = 5
    Move = True
End Sub

Private Sub Image1_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
Image1.MousePointer = 0
    Move = False
End Sub

Private Sub Image1_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Move = True Then
        Image1.Left = X
        Image1.Top = Y
    End If
End Sub



Does anyone else have this problem?



Edited by - Marce22 on 7/28/2003 8:21:45 AM

Moving Objects To The Mouse Cursor?
I am making a diablo style RPG and I need to implement a mouse system like diablo where you click somewhere and your character will move towards it.
All I need to know tho is how to make objects move to the mouse cursor position.

And I was also wondering how I can use the arrow keys on the keyboard to make them do commands.

MSChart - Moving The Mouse Over A 2D Line
MSChart - 2D line gragh question

You can move a mouse over the top of one of the 2D lines in an MSChart and a little box appears (like a tool tip) and it displays the name of that 2D line.
I have seen it work in another VB program but I have no idea of the code, could somebody help me please?

Thanks

Moving Mouse Pointer To The Specified Position
Hi there!

How could I move my mouse pointer to the control (button) which has got focus? Like if the user changes focus from the Command1 to the Command2 with the TAB key the mouse should move there too.

Any idea?

Problem With ShellExecute And Moving Mouse
I use the ShellExecute API to launch a 3rd party app I need to manipulate.
Problem is that when the program is launched, it appears to require the mouse to be moved over its window for it to fully activate and allow VB to use appactivate and sendkeys on it.
What kind of code do I need to use to make the mouse move over the 3rd party app's window once its been activated, or is there a way to programmatically send a mouse move/mouse over event to that window? Thanks!

Copyright © 2005-08 www.BigResource.com, All rights reserved