Maximum PC

It is currently Sun Apr 19, 2015 4:50 am

All times are UTC - 8 hours

Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Just a little project VB.NET
PostPosted: Thu Jun 19, 2008 9:57 am 
Team Member
Team Member
User avatar

Joined: Sun Jun 12, 2005 5:52 pm
Posts: 1319
Location: Infront of my Computer.
I have been trying to find a way to move the mouse using VB.NET programming, I have succeded, It took a while, but I finally found how to do it. Now the problem lies in how to get the color of a pixel anywhere on the screen when the x y coords are specified. I can't seem to find it anywhere. I use Visual Studio 2008. "Getpixel." command does not seem to exist in it. Here is my current code.

Public Class Form1
    Private Structure POINTAPI
        Dim x As Long
        Dim y As Long
    End Structure

    Private Declare Function ClientToScreen Lib "user32" _
    (ByVal hwnd As Long, ByVal lpPoint As POINTAPI) As Long

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

    Public Function SetCursorPosition(ByVal Window As Object, ByVal xPos As _
Long, ByVal yPos As Long) As Boolean
        On Error GoTo errorhandler

        Dim x As Long, y As Long
        Dim lRet As Long
        Dim lHandle As Long
        Dim typPoint As POINTAPI

        lHandle = Window.hwnd

        x = CLng(xPos / 15)
        y = CLng(yPos / 15)

        typPoint.x = x
        typPoint.y = y

        lRet = ClientToScreen(lHandle, typPoint)
        lRet = SetCursorPos(typPoint.x, typPoint.y)

        SetCursorPosition = (lRet <> 0)

        Exit Function


        SetCursorPosition = False
        Exit Function

    End Function

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        SetCursorPos(txtX.Text, txtY.Text)
        lblCurrentPs.Text = ("X = " & MousePosition.X & " And Y = " & MousePosition.Y)
    End Sub
End Class

 Post subject: Color under mouse
PostPosted: Wed Jun 25, 2008 6:52 pm 
User avatar

Joined: Fri Mar 30, 2007 4:10 pm
Posts: 1
Check out the code here, you should be able to figure it out.


Good luck,

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 8 hours

Who is online

Users browsing this forum: No registered users and 1 guest

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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

© 2014 Future US, Inc. All rights reserved.