watch mouse cursor

  • (2 Pages)
  • +
  • 1
  • 2

20 Replies - 4090 Views - Last Post: 21 April 2009 - 08:46 PM Rate Topic: -----

#1 holestary   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 17-April 09

watch mouse cursor

Post icon  Posted 17 April 2009 - 08:10 AM

hi,

i have a problem with C#..while i moving the mouse cursor eye will watch it..but eye will not move with mouse cursor..it is only watching it simultaneously ...

how can i do that.. i try it again and again but i couldn't do.. i asked that my friends..they say i should use mousemove event...and timer...but i couldn't..


there is a eye picture on the groupbox and groupbox move with mouse but i don't want this..


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace son
{
	public partial class Form1 : Form
	{
		public Form1()
		{
			InitializeComponent();
		}

		private void Form1_MouseMove(object sender, MouseEventArgs e)
		{
		   {

				int x = e.X;

				int y = e.Y;

				groupBox1.Location = new Point(x, y);

		   }
		}

		private void Form1_Load(object sender, EventArgs e)
		{

		}
	}
}



Mod Edit: Please use code tags when posting your code. Code tags are used like so => :code:

Thanks,
PsychoCoder :)

This post has been edited by PsychoCoder: 17 April 2009 - 10:39 AM


Is This A Good Question/Topic? 0
  • +

Replies To: watch mouse cursor

#2 [email protected]   User is offline

  • JMP *0x0(%RIP)
  • member icon

Reputation: 37
  • View blog
  • Posts: 1,019
  • Joined: 20-February 09

Re: watch mouse cursor

Posted 17 April 2009 - 10:37 AM

Pleas But your code in the Code Tag :P
Was This Post Helpful? 0
  • +
  • -

#3 PsychoCoder   User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1660
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: watch mouse cursor

Posted 17 April 2009 - 10:40 AM

Very confusing question you have there :crazy: It reads like you're wanting to be able to move your mouse with your eyes....but I'm not sure what you're asking :blink:
Was This Post Helpful? 0
  • +
  • -

#4 SixOfEleven   User is offline

  • Planeswalker
  • member icon

Reputation: 1055
  • View blog
  • Posts: 6,643
  • Joined: 18-October 08

Re: watch mouse cursor

Posted 17 April 2009 - 12:19 PM

Let me see if I have this right.

You have a picture that you want to follow the mouse as you move it around the form?

As that right?
Was This Post Helpful? 0
  • +
  • -

#5 holestary   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 17-April 09

Re: watch mouse cursor

Posted 17 April 2009 - 12:35 PM

can i give a link about this..is it problem? i found jscript..but i want in C#...
Was This Post Helpful? 0
  • +
  • -

#6 carlbrecon   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 15-April 09

Re: watch mouse cursor

Posted 17 April 2009 - 02:35 PM

i think i know what you mean.
i saw a basic one in a tutorial somewhere . it was a circle with a dot inside to represent a eyeball and the dot (or eye) looked (moved to the edge of the circle) towards the location of the mouse cursor
is that what your after?
Was This Post Helpful? 0
  • +
  • -

#7 holestary   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 17-April 09

Re: watch mouse cursor

Posted 17 April 2009 - 02:41 PM

yes i mean this..:)

This post has been edited by holestary: 18 April 2009 - 08:58 AM

Was This Post Helpful? 0
  • +
  • -

#8 carlbrecon   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 15-April 09

Re: watch mouse cursor

Posted 17 April 2009 - 02:50 PM

i am a beginner in c# too but i will try to find the tutorial for you.
but i know from experience that "sixofeleven" and "psychocoder" will probably solve this in the next hour or two for you. they are
"True elite ninja coding monkeys"
Was This Post Helpful? 0
  • +
  • -

#9 holestary   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 17-April 09

Re: watch mouse cursor

Posted 17 April 2009 - 02:56 PM

thanks
i will wait your message :^:
Was This Post Helpful? 0
  • +
  • -

#10 carlbrecon   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 15-April 09

Re: watch mouse cursor

Posted 17 April 2009 - 03:48 PM

i cant find tutorial yet but i did a little research
i created a blank form with a textbox
and placed this code in the form

private void Form1_MouseMove(object sender, MouseEventArgs e)
		{
			textBox1.Text = MousePosition.ToString();
		}


it will constantly update the mouse position and write it into textbox1 but only while you move over the form window.
i hope it helps.
but like i said before i dont know much so.
i will keep looking for the tutorial
Was This Post Helpful? 0
  • +
  • -

#11 papuccino1   User is offline

  • His name was Robert Paulson.
  • member icon

Reputation: 63
  • View blog
  • Posts: 1,121
  • Joined: 02-March 08

Re: watch mouse cursor

Posted 17 April 2009 - 06:10 PM

Ohhhh interesting question.

I think you want something like this?

Posted Image



I have absolutely no idea where to even start! But I guess I'll give it a shot. :P
Stay tuned!

This post has been edited by papuccino1: 17 April 2009 - 06:11 PM

Was This Post Helpful? 0
  • +
  • -

#12 papuccino1   User is offline

  • His name was Robert Paulson.
  • member icon

Reputation: 63
  • View blog
  • Posts: 1,121
  • Joined: 02-March 08

Re: watch mouse cursor

Posted 17 April 2009 - 06:42 PM

Hey bro, I got a little something something working here.

My Form1 Class

private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
            textBox1.Text = MousePosition.ToString();
            int xpos = MousePosition.X;
            

            if (xpos >= 366 && xpos <=425)
            {
                pictureBox1.Image = EyeExcercise.Properties.Resources.Eye1;
            }

            if (xpos >= 426 && xpos <= 491)
            {
                pictureBox1.Image = EyeExcercise.Properties.Resources.Eye2;
            }

            if (xpos >= 492 && xpos <= 540)
            {
                pictureBox1.Image = EyeExcercise.Properties.Resources.Eye3;
            }

            if (xpos >= 541 && xpos <= 596)
            {
                pictureBox1.Image = EyeExcercise.Properties.Resources.Eye4;
            }

            if (xpos >= 597 && xpos <= 657)
            {
                pictureBox1.Image = EyeExcercise.Properties.Resources.Eye5;
            }
        }


And the link to my solution folder.

My Solution


This is a basic implementation to your problem. Things some programmers with more experience should fix ASAP!
  • The method I use to get the mouse position only gets the X value.
  • The program only works properly when the form in Center Screen, if you move the form it miscalculates because it gets the position of the screen not the form.
  • I only use 5 images to simulate that the eye is following you, obviously more images = smoother eye movement.

Was This Post Helpful? 1
  • +
  • -

#13 holestary   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 17-April 09

Re: watch mouse cursor

Posted 18 April 2009 - 04:42 AM

hi,
after your suggestions i tried to do something..i used 30 pictures :crazy: ..i couldn't set the coordinats..how can i set that?? i want picturebox coordinat X=0,Y=0...now i use only one picturebox...if i can that i will put second picturebox near...and i think if i use bigger eye the number of pictures will decrease.. :P
i find javascript but i want that in C#
project latest version...

Posted Image



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace mouse_takip
{
	public partial class Form1 : Form
	{
		public Form1()
		{
			InitializeComponent();
		}

		private void Form1_MouseMove(object sender, MouseEventArgs e)
		{
		   
	   

			if (e.X >= 0 && e.X < 12) pictureBox1.Image = mouse_takip.Properties.Resources.yuvarlak1;
			if (e.X >= 12 && e.X < 24) pictureBox1.Image = mouse_takip.Properties.Resources.yuvarlak2;
			if (e.X >= 24 && e.X < 36) pictureBox1.Image = mouse_takip.Properties.Resources.yuvarlak3;
			if (e.X >= 36 && e.X < 48) pictureBox1.Image = mouse_takip.Properties.Resources.yuvarlak4;
			if (e.X >= 48 && e.X < 60) pictureBox1.Image = mouse_takip.Properties.Resources.yuvarlak5;
			if (e.X >= 60 && e.X < 72) pictureBox1.Image = mouse_takip.Properties.Resources.yuvarlak6;
			if (e.X >= 72 && e.X < 84) pictureBox1.Image = mouse_takip.Properties.Resources.yuvarlak7;
			if (e.X >= 84 && e.X < 96) pictureBox1.Image = mouse_takip.Properties.Resources.yuvarlak8;
			if (e.X >= 96 && e.X < 108) pictureBox1.Image = mouse_takip.Properties.Resources.yuvarlak9;
			if (e.X >= 108 && e.X < 130) pictureBox1.Image = mouse_takip.Properties.Resources.yuvarlak10;
			if (e.X >= 130 && e.X < 142) pictureBox1.Image = mouse_takip.Properties.Resources.yuvarlak11;
			if (e.X >= 142 && e.X < 154) pictureBox1.Image = mouse_takip.Properties.Resources.yuvarlak12;
			if (e.X >= 154 && e.X < 166) pictureBox1.Image = mouse_takip.Properties.Resources.yuvarlak13;
			if (e.X >= 166 && e.X < 178) pictureBox1.Image = mouse_takip.Properties.Resources.yuvarlak14;
			if (e.X >= 178 && e.X < 190) pictureBox1.Image = mouse_takip.Properties.Resources.yuvarlak15;
			if (e.X >= 190 && e.X < 202) pictureBox1.Image = mouse_takip.Properties.Resources.yuvarlak16;
			if (e.X >= 202 && e.X < 214) pictureBox1.Image = mouse_takip.Properties.Resources.yuvarlak17;
			if (e.X >= 214 && e.X < 226) pictureBox1.Image = mouse_takip.Properties.Resources.yuvarlak18;
			if (e.X >= 226 && e.X < 238) pictureBox1.Image = mouse_takip.Properties.Resources.yuvarlak19;
			if (e.X >= 238 && e.X < 250) pictureBox1.Image = mouse_takip.Properties.Resources.yuvarlak20;
			if (e.X >= 250 && e.X < 262) pictureBox1.Image = mouse_takip.Properties.Resources.yuvarlak21;
			if (e.X >= 262 && e.X < 274) pictureBox1.Image = mouse_takip.Properties.Resources.yuvarlak22;
			if (e.X >= 274 && e.X < 286) pictureBox1.Image = mouse_takip.Properties.Resources.yuvarlak23;
			if (e.X >= 286 && e.X < 298) pictureBox1.Image = mouse_takip.Properties.Resources.yuvarlak24;
			if (e.X >= 298 && e.X < 310) pictureBox1.Image = mouse_takip.Properties.Resources.yuvarlak25;
			if (e.X >= 310 && e.X < 322) pictureBox1.Image = mouse_takip.Properties.Resources.yuvarlak26;
			if (e.X >= 322 && e.X < 334) pictureBox1.Image = mouse_takip.Properties.Resources.yuvarlak27;
			if (e.X >= 334 && e.X < 346) pictureBox1.Image = mouse_takip.Properties.Resources.yuvarlak28;
			if (e.X >= 346 && e.X < 360) pictureBox1.Image = mouse_takip.Properties.Resources.yuvarlak29;
			



		}

	}
}

This post has been edited by holestary: 18 April 2009 - 06:25 AM

Was This Post Helpful? 0
  • +
  • -

#14 holestary   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 17-April 09

Re: watch mouse cursor

Posted 18 April 2009 - 05:20 AM

do u know another way to do same things??? :blink: only one or two picture and codes...
Was This Post Helpful? 0
  • +
  • -

#15 lesPaul456   User is offline

  • D.I.C Addict
  • member icon

Reputation: 175
  • View blog
  • Posts: 729
  • Joined: 16-April 09

Re: watch mouse cursor

Posted 18 April 2009 - 10:37 AM

View Postholestary, on 18 Apr, 2009 - 04:20 AM, said:

do u know another way to do same things??? :blink: only one or two picture and codes...


What about having two images, one of that's just a white circle, and the other that is the eye. Just overlap the two images so it looks like an eye. Then, set the position of the eye image relative to the mouse poisiton.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2