Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 1459 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     .NET and MSSQL :

[VB.NET]Mouse click(coords problems)

Thread title: [VB.NET]Mouse click(coords problems)
Closed Thread  
Page 1 of 2 1 2 >
    Thread tools Search this thread Display Modes  
11-06-2007, 12:46 AM
#1
Nightscream is offline Nightscream
Status: Junior Member
Join date: Aug 2006
Location:
Expertise:
Software:
 
Posts: 58
iTrader: 0 / 0%
 

Nightscream is on a distinguished road

  Old  [VB.NET]Mouse click(coords problems)

What i want to acomplish, to find the coordinates of my screen so like upper left corner is 0,0 but i'm getting proble with it, I want to use the SetCursorPos function later wit the coords that are recorded
I'm using the GetCursorPos function to get the coords
But when i want to see the x and y coords i get something very strange.
x = 1155346203274
y = 0
Now i want to know how can i get this fixed? :s

Code:
Structure PointApi
	Dim x As Long
	Dim y As Long
End Structure

Declare Function GetCursorPos Lib "User32" ( _
		ByRef lpPoint As PointApi) As Long

Private Sub btnPosition_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPosition.Click
Dim pt32 As PointApi

GetCursorPos(pt32)

txtX.Text = pt32.x
txtY.Text = pt32.y

11-06-2007, 01:28 AM
#2
masfenix is offline masfenix
Status: Member
Join date: Mar 2006
Location: t.dot canaada
Expertise:
Software:
 
Posts: 182
iTrader: 1 / 100%
 

masfenix has a little shameless behaviour in the past

Send a message via AIM to masfenix

  Old

Is this for your winapp?

Before I give you the code, have you looked at MSDN?
Also I would recommend using the .net functions for mouse input.

http://msdn2.microsoft.com/en-us/library/ms645602.aspx

11-06-2007, 08:45 PM
#3
Nightscream is offline Nightscream
Status: Junior Member
Join date: Aug 2006
Location:
Expertise:
Software:
 
Posts: 58
iTrader: 0 / 0%
 

Nightscream is on a distinguished road

  Old

Yes it's for my winxp, it should be an auto clicker so i can open up some things and let them scan with just hit a start button.
I'm kind of new to vb.net
I think this fuction is good http://msdn2.microsoft.com/en-us/library/ms645607.aspx

11-06-2007, 10:44 PM
#4
masfenix is offline masfenix
Status: Member
Join date: Mar 2006
Location: t.dot canaada
Expertise:
Software:
 
Posts: 182
iTrader: 1 / 100%
 

masfenix has a little shameless behaviour in the past

Send a message via AIM to masfenix

  Old

Yup, I didnt post that link because it didnt have examples, but I'm sure if you google it you'll get something, and then if you have trouble post code here, and ill help you debug it

11-07-2007, 06:19 PM
#5
Nightscream is offline Nightscream
Status: Junior Member
Join date: Aug 2006
Location:
Expertise:
Software:
 
Posts: 58
iTrader: 0 / 0%
 

Nightscream is on a distinguished road

  Old

ok thanks
[Edit]
How do you get hwnd?

11-08-2007, 12:25 AM
#6
masfenix is offline masfenix
Status: Member
Join date: Mar 2006
Location: t.dot canaada
Expertise:
Software:
 
Posts: 182
iTrader: 1 / 100%
 

masfenix has a little shameless behaviour in the past

Send a message via AIM to masfenix

  Old

After looking that over I think that is C++ code.

OH SORRY! I gave you the wrong class, here

http://msdn2.microsoft.com/en-us/lib...or(VS.71).aspx

its the CURSOR CLASS.

look in the properties and you'll find , cursor.position

11-08-2007, 09:57 PM
#7
Nightscream is offline Nightscream
Status: Junior Member
Join date: Aug 2006
Location:
Expertise:
Software:
 
Posts: 58
iTrader: 0 / 0%
 

Nightscream is on a distinguished road

  Old

got that part to work thanks
but now I'm want to move cursor to a special position. I have
Code:
Declare Function mouse_event Lib "user32.dll" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)

mouse_event(MOUSEEVENTF_MOVE, txtX.Text, txtY.Text, 0, 0)
when running I get MarshalDirectiveException was unhandled :s

11-09-2007, 03:55 AM
#8
masfenix is offline masfenix
Status: Member
Join date: Mar 2006
Location: t.dot canaada
Expertise:
Software:
 
Posts: 182
iTrader: 1 / 100%
 

masfenix has a little shameless behaviour in the past

Send a message via AIM to masfenix

  Old

uhh, wow I've never seen that error before lol.

post the code.

11-10-2007, 04:57 PM
#9
Nightscream is offline Nightscream
Status: Junior Member
Join date: Aug 2006
Location:
Expertise:
Software:
 
Posts: 58
iTrader: 0 / 0%
 

Nightscream is on a distinguished road

  Old

ok full code
Code:
Public Class frmClicker
    Declare Function mouse_event Lib "user32.dll" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)

    Const MOUSEEVENTF_MOVE = &H1

    Private Sub btnPosition_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPosition.Click

        System.Threading.Thread.Sleep(2000)
        txtX.Text = System.Windows.Forms.Cursor.Position.X
        txtY.Text = System.Windows.Forms.Cursor.Position.Y

    End Sub

    Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
        mouse_event(MOUSEEVENTF_MOVE, txtX.Text, txtY.Text, 0, 0)

    End Sub
End Class

11-11-2007, 12:48 AM
#10
masfenix is offline masfenix
Status: Member
Join date: Mar 2006
Location: t.dot canaada
Expertise:
Software:
 
Posts: 182
iTrader: 1 / 100%
 

masfenix has a little shameless behaviour in the past

Send a message via AIM to masfenix

  Old

Code:
Public Class frmClicker
 
    Const MOUSEEVENTF_MOVE = &H1

    Private Sub btnPosition_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPosition.Click

        System.Threading.Thread.Sleep(2000)
        txtX.Text = System.Windows.Forms.Cursor.Position.X
        txtY.Text = System.Windows.Forms.Cursor.Position.Y

    End Sub

    Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
       'get the cursor handle
        Me.Cursor = New Cursor(Cursor.Current.Handle)
        Cursor.Position = New Point(Convert.ToInt32(txtX.text), Convert.ToInt32(txty.text))
        

    End Sub
End Class
try using the framework as much as possible. api is good but use it when its absolutely neccessary.

Closed Thread  
Page 1 of 2 1 2 >


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed