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




Sending Left Mouse Click To Another Program


Hey, i want to send send a mouse click to another program, in a certain amount of time like say every 5 seconds, it doesn't matter where the cursor is going to be but if i have to set a position i will, anybody got an example i looked all over the forum but nothing thx in advance




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Automate To Detect A Left Mouse Click Without Using The Form Mouse Click Event
hello all ,How do I automate to detect a left mouse click without using the form mouse click event ?

Right-click Menu And Sending Left Click To Item
Can anyone tell me how I can use insert a right-click menu into my program so that when the user has selected a file (in a file list) and right-clicks, a menu appears at the location of the mouse pointer. I aleady know how to use the PopupMenu function to show a menu as I suppose that will need to be used, I just don't know how to capture a right-click mouse event and also use the position of the mouse pointer to show the menu.

Thanks in advance!

Mouse Click: Left Or Right
Hi,

I'm looking for some code to paste in the label1_click event to let this event only work when the left mouse button is pressed and not the middle or the right mouse button?

Thank you,

Gaz

Left & Right Mouse Click!
A ListView is populated with many items (all the items are URLs of web pages). I want that when any of the items is left-clicked with the mouse, then the user should be taken to that URL but if any of the items is right-clicked with the mouse, then a pop-up menu should come up. I tried it this way:
VB Code:
[color=blue]Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)    Item.SmallIcon = 2    wWeb.Navigate2 Item.TagEnd Sub Private Sub ListView1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)    If (Button = 2) Then        PopupMenu mnuPopup    ElseIf (Button = 1) Then        Call ListView1_ItemClick(ListView1.SelectedItem)    End IfEnd Sub[/color]
The problem with the above code is that when I right-click any item in the ListView, then the pop-up menu comes up but at the same time, the browser opens the URL that was clicked. How do I prevent the browser from navigating to the URL when any of the items in the ListView is right-clicked?

In fact, I didn't include the ElseIf condition in the ListView1_MouseUp event function but since right-clicking any item was taking the user to the appropriate URL, I added the ElseIf condition but that doesn't make any difference.

Thanks,

Arpan

Left And Right Mouse Click
I want to allow users to use the left mouse click while the right one will do something else... is there any way to check for which mouse button is clicked or _Click ?

~$uper-$tar

Left Mouse Click
how can I get VB to send a left mouse click to windows
so that windows thinks that the user did it over
the item the mouse is over

Mouse Left Click
Does anyone know what the code for a Left Mouse Click is? i want to loop certain keys in a continous cycle, i've completed the keyboard, i just need the code for the mouse. heres an example.

Private Sub Timer2_Timer()
SendKeys "z"
End Sub

Any help is appriciable
thanks.

Left Mouse Click Question
hello all.

i've come accross a small problem with mouseclicks and can't seem to find the awnser, and wondered if anyone knew how to do this.

basically all i want it to do is.

if label1.backcolour = vbred then
'click the left button on mouse
end if

any feedback would be greatly appreciated.

toothpick

How Can I Get Left Click Event Of Mouse?
HI All!
In my application i have to have all the three events of a mouse.... like left click, right click and the middle button(scroll) click events.

I already wrote the event mouses's down event. in that event i am able to get the middle button(scroll)'s event and right click event, but i am unable to get the left button's click event....

How can i get this Leftclik event of mouse? here is my sample code...

Private Sub Image1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)

If Button = 4 Then
boolDragDrop = True
End If

If Button = 2 Then
Delete.Tag = Index
Me.PopupMenu RClick
End If

If Button = 1 Then 'this is not working..... how can i get this ?
MsgBox ("
yes...it is button1")
End If

End Sub

Please let me know... if u know this..

Thanks in advance:
regards:
raghunadhs.v

Send Left Mouse Click
Ok i am using a list-tree-view and when you right click it opens a menu. However i want to send a mouse left click BEFORE the user right clicks so it selects that file that they right click on.

Thanks

Can I Disable The Left Mouse Click
Hello.

On my form I have a Frame containing 6 Textbox's and I need to stop the user from clicking on these Textbox's with the Left mouse button but I still need the user to be able to Tab from one box to the next. On the forum I have seen a couple of code posts that claim to disable the mouse click but I cannot get either one to work.

If anyone can help I would be most gratefull.

Thanks.
SKM

Left Mouse Click Button
How can i disable the left click button in a listview...??!

Desable Mouse Left Click
How can I disable the mouse click in all windows?????

PLease and thank you

How To Cause The Mouse To Send A Left-click ?
Hi,
I wanna know please how to cause the mouse to simulate a left click?
I already know how to set the cursor to a specific position using the API, but I dont know how to send then a left click.

Thanks.

Send A Left Mouse Click??
I've looked and looked to no avail...

How do I send a left mouse click via code?

Left Mouse Click Event
How can I make the click event code of a label execute only to a left mouse click? And I dont want to put the code in the mouse up and mouse down events.

Detect Shift+left Mouse Click
how would I detect if any shift button and the left mouse button has been clicked anywhere on the desktop?

Sending A Mouse Click
Hey,
Heres the code im currently using...

Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByRef lparam As Any) As Long
Private Declare Function WindowFromPoint Lib "user32.dll" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetCursorPos Lib "user32.dll" (ByRef lpPoint As POINTAPI) As Long

Private Const WM_LBUTTONUP As Long = &H202
Private Const WM_LBUTTONDOWN As Long = &H201
Const WM_MENURBUTTONUP As Long = &H122
Private Const MK_RBUTTON = 2
Private Type POINTAPI
x As Long
y As Long
End Type

Dim pos As POINTAPI, poshwnd As Long

GetCursorPos pos
poshwnd = WindowFromPoint(pos.x, pos.y)
SendMessage poshwnd, WM_LBUTTONDOWN, MK_RBUTTON, pos
SendMessage poshwnd, WM_LBUTTONUP, MK_RBUTTON, pos

It seems to me like it is clicking on the given control, but not in the exact area(Not the same effect as me actually clicking on the mouse). For example if i put my mouse on a text box it will draw focus at the beginnign of the text box where as if i had clicked my mouse it would draw focus to that exact area. Any idea how i can make a more precise mouse click... Basicly i want something that works like sendkeys does.. only for my mouse..

Thanks

Sending Mouse Click To App.
Hey I am trying to send Mouse Click Commands to One Appication without moving the Mouse Cursor.

I know that all appications get commands from Windows and then WndProc screens the messages and reacted to them.

Question is how do i inplant a message into one Appication's WndProc.

I was thinking a Virtual Mouse of sometype.

Thanks


P.S My Function Prototype needs to be like this


VB Code:
Public Function SendAPPClick( AppWinNum as HWnd, Clickx as Integer, Clicky as Integer )  'SEND FAKE MOUSE Y POSITION'SEND FAKE MOUSE X POSITION'SEND FAKE MOUSE LEFT CLICK End Function

Sending Mouse Click And Key Press
Hey, I've got an application where I need to be able to run a program that does a right mouse click then presses number 1 on the numpad where I position the mouse, or alternatively right mouse click then move the mouse to another location and left click on it.
Thanks in advance.

I Need Help Ading A Left Moust Click On Some Txt Added To My Program
and how do i make a button navigate to an internet page with it?+ the comand to click?

note:im asking so many questions because the msdn libary wouldnt instal

Sending A Mouse Click To The Current Position...
Hi all,

Is there any way to send a mouse click to the current position of the mouse (in a 3rd part application) without using the hwnd of it? Here's the code I'm using:

Code:
Option Explicit
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_LBUTTONUP = &H202
Const WM_LBUTTONDOWN = &H201
Const MK_CONTROL = &H8
Const MK_LBUTTON = &H1
Const MK_MBUTTON = &H10
Const MK_RBUTTON = &H2
Const MK_SHIFT = &H4
Const MK_XBUTTON1 = &H20
Const MK_XBUTTON2 = &H40
Private Sub cmdConn_Click()
Dim strMy As Long
Dim strDCplus As Long
Dim strHublist As Long
Dim xcoord As Long, ycoord As Long
Dim winrect As RECT
Dim retval As Long
Dim x As Integer
Dim y As Integer
Dim z As Integer
Dim packed As Long
strDCplus = Find_DCplus
SetForegroundWindow (strDCplus)
Sleep 200
strMy = Find_PublicHubs
strHublist = Find_Hublist
retval = GetWindowRect(strMy, winrect)
ycoord = winrect.Bottom
xcoord = (winrect.Right - winrect.Left) / 2
x = xcoord
y = ycoord
z = y + 28
packed = (z * &H10000) + x
Call SendMessage(strMy, WM_LBUTTONDOWN, ByVal CLng(0), ByVal CLng(0))
Call SendMessage(strMy, WM_LBUTTONUP, ByVal CLng(0), ByVal CLng(0))
SetCursorPos x, z
End Sub
Function Find_PublicHubs()
Dim Win_Buff0 As Long
Dim Win_Buff1 As Long
Dim Win_Buff2 As Long
Dim sddx As Integer
Win_Buff2 = FindWindow("DC++", "DC++ 0.305 - [Public Hubs]")
If Win_Buff2 = 0 Then Win_Buff2 = FindWindow("DC++", vbNullString)

Win_Buff1 = findchildbyclass(Win_Buff2, "ReBarWindow32")
If Win_Buff1 = 0 Then Win_Buff1 = findchildbytitle(Win_Buff2, "")

Win_Buff1 = GetWindow(Win_Buff2, GW_CHILD)
For sddx = 1 To 1
Win_Buff1 = GetWindow(Win_Buff1, GW_HWNDNEXT)
Next sddx

Win_Buff0 = findchildbyclass(Win_Buff1, "ToolbarWindow32")
If Win_Buff0 = 0 Then Win_Buff0 = findchildbytitle(Win_Buff1, "")

Win_Buff0 = GetWindow(Win_Buff1, GW_CHILD)
Find_PublicHubs = Win_Buff0
End Function
Function Find_DCplus()
Dim Win_Buff0 As Long
Win_Buff0 = FindWindow("DC++", "DC++ 0.305 - [[Light™] Sweden #05 (light5.serveftp.com)]")
If Win_Buff0 = 0 Then Win_Buff0 = FindWindow("DC++", vbNullString)
Find_DCplus = Win_Buff0
End Function
Function Find_Hublist()
Dim Win_Buff0 As Long
Dim Win_Buff1 As Long
Dim Win_Buff2 As Long
Dim Win_Buff3 As Long
Dim sddx As Long
Win_Buff3 = FindWindow("DC++", "DC++ 0.305 - [Public Hubs]")
If Win_Buff3 = 0 Then Win_Buff3 = FindWindow("DC++", vbNullString)

Win_Buff2 = findchildbyclass(Win_Buff3, "MDIClient")
If Win_Buff2 = 0 Then Win_Buff2 = findchildbytitle(Win_Buff3, "")

Win_Buff2 = GetWindow(Win_Buff3, GW_CHILD)
Win_Buff1 = findchildbyclass(Win_Buff2, "PublicHubsFrame")
If Win_Buff1 = 0 Then Win_Buff1 = findchildbytitle(Win_Buff2, "Public Hubs")

Win_Buff1 = GetWindow(Win_Buff2, GW_CHILD)
Win_Buff0 = findchildbyclass(Win_Buff1, "ATL:004A3130")
If Win_Buff0 = 0 Then Win_Buff0 = findchildbytitle(Win_Buff1, "")

Win_Buff0 = GetWindow(Win_Buff1, GW_CHILD)
For sddx = 1 To 1
Win_Buff0 = GetWindow(Win_Buff0, GW_HWNDNEXT)
Next sddx

Find_Hublist = Win_Buff0
End Function
A lot of it may not make sense, but all I need to do is pass a mouse click (LeftDown and LeftUp) right after the "SetCursorPos x, y". In the past, I've been using the SendMessage API (which requires the hwnd). If I pass the hwnd in with the SendMessage like these lines:

Code:
Call SendMessage(strMy, WM_LBUTTONDOWN, ByVal CLng(0), ByVal CLng(0))
Call SendMessage(strMy, WM_LBUTTONUP, ByVal CLng(0), ByVal CLng(0))
then obviously it's not clicking where the mouse cursor is at. I either need a way to simply pass the mouse click to where the mouse is already at or a way to set the index of a list box (I can set the index of a combo-box no problem, but can't figure out a way for a list box).

As always, any insight is greatly appreciated.

Mouse Click Outside A Program
I can use the GetCursorPos to see the mouse postion anywhere on the screen.
But how do I see "Mouse Up" or "Mouse Down".
I don't want to write code for every text box, label, frame or command button to see that a
"drag drop" or "mouse up" has occured.
If there is a universal method of detecting a "Mouse Up" or "Drag Drop", that would
save me a lot of programing.

Ira

Detecting Mouse Click Anywhere In Program
i'm writing a program in which i would like to detect a mouse click anywhere within the program, whether it's on the titlebar, the menubar, or anywhere within the form. The program auto-minimizes after 10 seconds, but i'd like it to not do this if the user clicks anywhere.

is there an API function or somtehing to detect a mouseclick anywhere within an application? or any other solutions?

any help would be appreciated.
thanks!

Does Mouse Can Be Program To Automatically Click
Hi I have a system on my mind, but the thing bothering me is that, is there a way or is it possible to make a code that will automatically move the mouse in any possition and when it search the object or possition specified it will automatically click with a click from outside world

Thanks

Mouse Click On External Program
ok here is my code


Private Sub cmdGo_Click()
Call SetCursorPos(530, 180)
Timer1.Enabled = True
End Sub

Private Sub cmdQuit_Click()
End
End Sub

Private Sub Timer1_Timer()
SendKeys ("Password")
Timer1.Enabled = False
End Sub

i am making an auomated program which runs throught an external program's login screen but i need someone to tell me how i can include a mouse click or send the key 'Enter' to press the ok button. Please dont refer me to another thread or url. Explain Please.

Help Needed - Start Program On Mouse Click
basically i need to the program to start when the mouse button is pressed BUT here's where its a bit more complex. this is usually easy using a simple boolean and mouse click procedure (to inhibit the mouse after it has been clicked once). However, in this program every mouse click is counted and different things happen depending on how many mouse clicks have been clicked. Therefore I need a bit of code at the beginning that says:

start prog. when the mouse button is clicked but then inhibit this so mouse clicks are still counted ok. but the program doesnt try to restart with every mouse click.

any help would be great i am very confused! (as u can probably tell

thanks

andy

Making Right-Click In A ListBox Select An Item Exactly Like The Left Click.
Heres a start:


Code:
Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
'Place code to select the item
End Sub

I need help where the comment is. Thanks

Mouse.left? (mouse Location)
I am making (trying to make) a real time strategy game with visual basic, and I need help writing code that, when you click, the left and top of the mouse's location where you clicked are displayed in two seperate labels/text boxes/ variables. I tried many things like "label1.caption = mouse.left" + "cursor.left" + "pointer.left". I can't make a label or object in every square because that is too many objects (I think the limit is 200 or something). I also looked it up in the help menu, but it wasn't there. Thanks for your help!

Right Click And Left Click Order?
Hello folks,

Here is my problem and I would appreciate your input.

When I want to left click on a lable, I want the colors of the label to change in one order.
When I want to right click on this label again, I want the color to change in opposite order.

It does the job but has one bug. For example, when I left click it works as expected but when I right click, it behave as it is left clicked (once) and then it changes to the opposite order. Please check the attachment. Thanks


Code:

Option Explicit
Dim intIncrementor As Integer

Private Sub Label3_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
'Private Sub Label3_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
' Select Case Button
' Case vbRightButton
' MsgBox "right button down"
' Case vbLeftButton
' MsgBox "left button down"
' End Select
'End Sub
Label6.Caption = intIncrementor

    Select Case Button
        Case vbRightButton
            'intIncrementor = intIncrementor - 1
            If intIncrementor = 0 Then
                Label3.BackColor = &H0& 'black
                intIncrementor = intIncrementor - 1
                Label3.Caption = "black"
                intIncrementor = 9 'reset to end
            ElseIf intIncrementor = 1 Then
                Label3.BackColor = &H404040 'brown
                intIncrementor = intIncrementor - 1
                Label3.Caption = "brown"
            ElseIf intIncrementor = 2 Then
                Label3.BackColor = &HFF& 'red
                intIncrementor = intIncrementor - 1
                Label3.Caption = "red"
            ElseIf intIncrementor = 3 Then
                Label3.BackColor = &H80FF& 'orange
                intIncrementor = intIncrementor - 1
                Label3.Caption = "orange"
            ElseIf intIncrementor = 4 Then
                Label3.BackColor = &HFFFF& 'yellow
                intIncrementor = intIncrementor - 1
                Label3.Caption = "yellow"
            ElseIf intIncrementor = 5 Then
                Label3.BackColor = &HC000& 'green
                intIncrementor = intIncrementor - 1
                Label3.Caption = "green"
            ElseIf intIncrementor = 6 Then
                Label3.BackColor = &HFF0000 'blue
                intIncrementor = intIncrementor - 1
                Label3.Caption = "blue"
            ElseIf intIncrementor = 7 Then
                Label3.BackColor = &HC000C0 'violet
                intIncrementor = intIncrementor - 1
                Label3.Caption = "violet"
            ElseIf intIncrementor = 8 Then
                Label3.BackColor = &HC0C0C0 'gray
                intIncrementor = intIncrementor - 1
                Label3.Caption = "gray"
            ElseIf intIncrementor = 9 Then
                Label3.BackColor = &HFFFFFF 'white
                intIncrementor = intIncrementor - 1
                Label3.Caption = "white"
            End If
     
        Case vbLeftButton
            If intIncrementor = 0 Then
                Label3.BackColor = &H0& 'black
                intIncrementor = intIncrementor + 1
                Label3.Caption = "black"
                Label5.Caption = intIncrementor
            ElseIf intIncrementor = 1 Then
                Label3.BackColor = &H404040 'brown
                intIncrementor = intIncrementor + 1
                Label3.Caption = "brown"
            ElseIf intIncrementor = 2 Then
                Label3.BackColor = &HFF& 'red
                intIncrementor = intIncrementor + 1
                Label3.Caption = "red"
            ElseIf intIncrementor = 3 Then
                Label3.BackColor = &H80FF& 'orange
                intIncrementor = intIncrementor + 1
                Label3.Caption = "orange"
            ElseIf intIncrementor = 4 Then
                Label3.BackColor = &HFFFF& 'yellow
                intIncrementor = intIncrementor + 1
                Label3.Caption = "yellow"
            ElseIf intIncrementor = 5 Then
                Label3.BackColor = &HC000& 'green
                intIncrementor = intIncrementor + 1
                Label3.Caption = "green"
            ElseIf intIncrementor = 6 Then
                Label3.BackColor = &HFF0000 'blue
                intIncrementor = intIncrementor + 1
                Label3.Caption = "blue"
            ElseIf intIncrementor = 7 Then
                Label3.BackColor = &HC000C0 'violet
                intIncrementor = intIncrementor + 1
                Label3.Caption = "violet"
            ElseIf intIncrementor = 8 Then
                Label3.BackColor = &HC0C0C0 'gray
                intIncrementor = intIncrementor + 1
                Label3.Caption = "gray"
            ElseIf intIncrementor = 9 Then
                Label3.BackColor = &HFFFFFF 'white
                intIncrementor = intIncrementor + 1
                Label3.Caption = "white"
                intIncrementor = 0 'reset to start
            End If
    End Select
    
End Sub




 

Written A Code To Move Mouse And Simulate Mouse Click, Its Not Working??
this code is to move mouse and simulate the mouse click.

My intension is to place the cursor in the middle of the screen initially and move.

the code contains approriate comments ,i think that helps to understand code (actually i've seen it in some other forum and made small changes).



when i run the code the cursor is not placed at the centre of the screen??

whats wrong with my code?? please somebody correct it??

here i'm giving my entire code.. (please have patience and go through)


Option Explicit

' ----------------------------------------------
' * MouseEvent Related Declares *
' ----------------------------------------------
Private Const MOUSEEVENTF_ABSOLUTE = &H8000
Private Const MOUSEEVENTF_LEFTDOWN = &H2
Private Const MOUSEEVENTF_LEFTUP = &H4
Private Const MOUSEEVENTF_MIDDLEDOWN = &H20
Private Const MOUSEEVENTF_MIDDLEUP = &H40
Private Const MOUSEEVENTF_MOVE = &H1
Private Const MOUSEEVENTF_RIGHTDOWN = &H8
Private Const MOUSEEVENTF_RIGHTUP = &H10

Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, _
ByVal dx As Long, ByVal dy As Long, ByVal cbuttons As Long, _
ByVal dwExtraInfo As Long)

' ----------------------------------------------
' * GetSystemMetrics Related Declares *
' ----------------------------------------------
Private Const SM_CXSCREEN = 0
Private Const SM_CYSCREEN = 1
Private Const TWIPS_PER_INCH = 1440
Private Const POINTS_PER_INCH = 72
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex _
As Long) As Long

' ----------------------------------------------
' * GetWindowRect Related Declares *
' ----------------------------------------------
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, _
lpRect As RECT) As Long


' ----------------------------------------------
' * Internal Constants and Types *
' ----------------------------------------------

Private Const MOUSE_MICKEYS = 65535

Public Enum enReportStyle
rsPixels
rsTwips
rsInches
rsPoints
End Enum

Public Enum enButtonToClick
btcLeft
btcRight
btcMiddle
End Enum


' Returns the screen size in pixels or, optionally,
' in others scalemode styles
Public Sub GetScreenRes(ByRef X As Long, ByRef Y As Long, Optional ByVal _
ReportStyle As enReportStyle)

X = GetSystemMetrics(SM_CXSCREEN)
Y = GetSystemMetrics(SM_CYSCREEN)
If Not IsMissing(ReportStyle) Then
If ReportStyle <> rsPixels Then
X = X * Screen.TwipsPerPixelX
Y = Y * Screen.TwipsPerPixelY
If ReportStyle = rsInches Or ReportStyle = rsPoints Then
X = X TWIPS_PER_INCH
Y = Y TWIPS_PER_INCH
If ReportStyle = rsPoints Then
X = X * POINTS_PER_INCH
Y = Y * POINTS_PER_INCH
End If
End If
End If
End If
End Sub


' Convert's the mouses coordinate system to
' a pixel position.
Public Function MickeyXToPixel(ByVal mouseX As Long) As Long
Dim X As Long
Dim Y As Long
Dim tX As Single
Dim tmouseX As Single
Dim tMickeys As Single

GetScreenRes X, Y
tX = X
tMickeys = MOUSE_MICKEYS
tmouseX = mouseX

MickeyXToPixel = CLng(tmouseX / (tMickeys / tX))

End Function


' Converts mouse Y coordinates to pixels
Public Function MickeyYToPixel(ByVal mouseY As Long) As Long
Dim X As Long
Dim Y As Long
Dim tY As Single
Dim tmouseY As Single
Dim tMickeys As Single

GetScreenRes X, Y
tY = Y
tMickeys = MOUSE_MICKEYS
tmouseY = mouseY

MickeyYToPixel = CLng(tmouseY / (tMickeys / tY))

End Function


' Converts pixel X coordinates to mickeys
Public Function PixelXToMickey(ByVal pixX As Long) As Long
Dim X As Long
Dim Y As Long
Dim tX As Single
Dim tpixX As Single
Dim tMickeys As Single

GetScreenRes X, Y
tMickeys = MOUSE_MICKEYS
tX = X
tpixX = pixX

PixelXToMickey = CLng((tMickeys / tX) * tpixX)

End Function


' Converts pixel Y coordinates to mickeys
Public Function PixelYToMickey(ByVal pixY As Long) As Long
Dim X As Long
Dim Y As Long
Dim tY As Single
Dim tpixY As Single
Dim tMickeys As Single

GetScreenRes X, Y
tMickeys = MOUSE_MICKEYS
tY = Y
tpixY = pixY

PixelYToMickey = CLng((tMickeys / tY) * tpixY)

End Function


' The function will center the mouse on a window
' or control with an hWnd property. No checking
' is done to ensure that the window is not obscured
' or not minimized, however it does make sure that
' the target is within the boundaries of the
' screen.
Public Function CenterMouseOn(ByVal hwnd As Long) As Boolean
Dim X As Long
Dim Y As Long
Dim maxX As Long
Dim maxY As Long
Dim crect As RECT
Dim rc As Long

GetScreenRes maxX, maxY
rc = GetWindowRect(hwnd, crect)

If rc Then
X = crect.Left + ((crect.Right - crect.Left) / 2)
Y = crect.Top + ((crect.Bottom - crect.Top) / 2)
If (X >= 0 And X <= maxX) And (Y >= 0 And Y <= maxY) Then
MouseMove X, Y
CenterMouseOn = True
Else
CenterMouseOn = False
End If
Else
CenterMouseOn = False
End If
End Function


' Simulates a mouse click
Public Function MouseFullClick(ByVal MBClick As enButtonToClick) As Boolean
Dim cbuttons As Long
Dim dwExtraInfo As Long
Dim mevent As Long

Select Case MBClick
Case btcLeft
mevent = MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP
Case btcRight
mevent = MOUSEEVENTF_RIGHTDOWN Or MOUSEEVENTF_RIGHTUP
Case btcMiddle
mevent = MOUSEEVENTF_MIDDLEDOWN Or MOUSEEVENTF_MIDDLEUP
Case Else
MouseFullClick = False
Exit Function
End Select
mouse_event mevent, 0&, 0&, cbuttons, dwExtraInfo
MouseFullClick = True

End Function


Public Sub MouseMove(ByRef xPixel As Long, ByRef yPixel As Long)
Dim cbuttons As Long
Dim dwExtraInfo As Long

mouse_event MOUSEEVENTF_ABSOLUTE Or MOUSEEVENTF_MOVE, _
PixelXToMickey(xPixel), PixelYToMickey(yPixel), cbuttons, dwExtraInfo

End Sub

Right N Left Click
Hi,


How can i define wether the right or left mouse button has been clicked?

Thanks in advance


Ciao

Steve

Left And Right Click
now this is a problem with clicks!
i have a msflexgrid and when i select a row it highlights that row and other rows alternatingly by the given function below

its working perfect

also i have a mouseup event for the same grid it also works but i want it like this

when i right click a row the row must get selected first then the popup menu should appear.but what actually happens is that if i have selected the first row and then right click over the 3rd row .the 3rd row does not get selected but the selection remains over the first row! .how do i solve this


VB Code:
Private Sub msfg4_Click()Dim j%, iCurRow%Static iLastRow As Integer     With msfg4        If .Row = 0 Then Exit Sub        iCurRow = .Row        If .Row <> iLastRow Then            .Row = iLastRow            For j = 1 To .Cols - 1                .Col = j                If iLastRow Mod 2 = 0 Then                    .CellBackColor = ODDROW_COLOR                Else                    .CellBackColor = EVENROW_COLOR                End If            Next j        Else            Exit Sub        End If        .Row = iCurRow        For j = 1 To .Cols - 1            .Col = j            .CellBackColor = SELROW_COLOR        Next j        iLastRow = .Row    End With End Sub

Right Click, Left...etc
I was wondering how to make a specific button on the key board do a certain task (shoot, move ... ) but can someone give me a code to help me out or a tuturial?

Left/ Right Click
How can I detect the left/right if the object haven't mousedown, mousemove, mouseup... event??
How can I make the mouse right click whereever it is on the screen through code?

Simulate Mouse Move And Mouse Click With Directinput
I've been trying to figure this one out for a while. I can already do it with mouse_event calls but would like to get it working with direct input. I've found lots of tutorials on how to HANDLE mouse input with directinput, but not one tutorial on how to simulate mouse events with directinput. (without using mouse_event at all). I'm getting stumped here, and Im pretty new to the directx sdk, so please use kid gloves

Raising A Mouse Click Event Without Clicking On The Mouse
I want to raise a mouse click event on a form in a project from another
project without actually clicking on the command button..

For eg:
I have an application which has a sign in form where i accept username
and password... There is a sign in command button..
I want to try and sign in from another project without actually
clicking on the sign in button...
i.e I want to call the commandbutton_Click( ) function of that command
button
I know there is something like "reflection" in C# (VB.NET) but i want
to do this in Visual Basic 6.0...

The Mouse Has Left The Form
Hello.

I'm using PictureBoxes as buttons and using the MouseMove event to HotTrack by swapping the .pictures (and wishing there was an event for when the mouse leaves instead of tracking PictureBox MouseMove, checking if it's changed, and tracking the MouseMoves over the rest of the form as well . . . )

It's working fine, but the only problem is the .picture sticks if you move the mouse off the form. I'm guessing there's not an event for when the mouse leaves the form either, so I'll use a timer and check to see if the mouse has left the form, right? If so . . .

Anyone have a quick way to check if the mouse is off the form?

Clicking Mouse (left)
Hello. Can someone give me a source for clicking the mouse in certain coordinates? Im just getting into and need some things. Thank you.

Regards,
Mark

Mouse Buttons. The Left One And The Right One.
When the mouse is clicked on the form, how can I tell which button was clicked? "Button" in Form_MouseMove seems to only work if the mouse was being moved at the time of the click, which doesn't happen too often.

Mouse Has Left Toolbar
Hi everyone! I was wondering how I could track the mouse to know if it has left the toolbar of an MDI application... I believe it can be done using windows API... Any ideas?

VXFlexGrid Left Click
I am using VXFlexGrid and when you left click it selects a cell. Is it possible to repeat this behavior with the right click? Some how I would have to get the xy of the click, then do try and pass that to the flex grid to let it knwo what cell to select? I couldn't find the right functions, or maybe i'm barking up the wrong tree?

Click.top/.left Capture
under the Form_Click sub, how would you say:


Code:
Private Sub Form1_Click

(click).Top = top 'variable
(click).Left = left 'variable

'where (click) is whatever the click is called

End Sub

On Right And Left Click Events
i also have a thread up about click and double click events but can someone plz tell me how to turn the following into read VB code

private sub label1_leftclick()
bit of code
end sub

private sub label1_rightclick()
a different bit of code
end sub

yeh somethin like that

thnx a lot im sure it could be done

Emulating A Left Click.
Hello,

This is probably a silly question but I was wondering how you could make Visual Basic 6.0 emulate a left click on a specific location?

So if you have a button on your form you make your code left click on command1!

Is that possibe and if so how would you go about it?

Thanks

Fraggy

PS: I hope my question was clear?

Left Click Over And Over Again On A Location?
How do you have it so when you press a command button the next place you click will be clicked over and over again until you click again? Thanks in advance

How To Define On Left Click &gt; Do Something
i knew that ...but im so old that i forget things =] hhhhh
please remind me =]

**and if some moderator see that ...can i donate the forum via paypal? if i do ..how?

Playing A .wav On Left Click
Im using this code to play a .wav file everytime i left click

Code:
Option Explicit

Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

Private Const SND_ASYNC = &H1


Private Sub Form_Mousedown(Button As Integer, Shift As Integer, X As Single, Y As Single)


sndPlaySound _
"The file Path", _
SND_ASYNC



Everytime i click on the form it will make the .wav play. But thats the thing it only plays when i click on the form. I want it to still play even if i click off the form. Thanks in advance.

How Would I Add A Left Click To This Button?
Code:
Private Sub Command1_Click()
Inet1.Execute "http://neopets.com/games/launch_game.phtml?age=0&chall=0&dc=&hiscore=600&sp=0&va=1&world=Space+Station&height=500&width=500&user_full_name=sasa_kill&r=1395972&game_id=156&nc_referer=neopets&questionSet=&quality=High"
End Sub

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