Jump to content

.Net - mouse move when timer ticks

Hi, so I don't know if there is anyone out there programming .Net but I thought I'd give it a try and see if anyone did know anything about it here or if it's just more advanced stuff. So I have a timer that is set to tick every 7 minutes. Then, every 7 minutes, I want the timer to make a the mouse/cursor move slightly to the left or right. This is just so that I can have an OS running and the screen saver will not go on. I know, just change the settings. But no. I'm doing this for a teacher at my school because their computers cannot have their settings modified and when he wants to show a presentation and is on a slide for a long time. The screen saver goes on. The IT depertment at the school are morons and refuses to allow him to change it so I decided to make this for him. So I googled this but I couldn't come up with anything useful. At least that I could understand and put together into a timer.

 

 

Please help me with this. Would be great to help him out!

 

 

Regards,

 

Ludwig Johnson

Spoiler

System:

i5 3570k @ 4.4 GHz, MSI Z77A-G43, Dominator Platinum 1600MHz 16GB (2x8GB), EVGA GTX 980ti 6GB, CM HAF XM, Samsung 850 Pro 256GB + Some WD Red HDD, Corsair RM850 80+ Gold, Asus Xonar Essence STX, Windows 10 Pro 64bit

PCPP:

http://pcpartpicker.com/p/znZqcf

 

Link to comment
Share on other sites

Link to post
Share on other sites

i've coded the application on C# (i didnt wanted to mess around with vbnet since its been more than 2 years since i've coded with it) do you want me explain code lines with comments? or ill just upload source and exe 

alright here is the source code with all comments on it

https://www.dropbox.com/s/10hz3eo4q3nfkpx/MoveMouse.rar?m=

here is the EXE itself (it is also in bin/debug folder of source code)

https://www.dropbox.com/s/k9c5ja5u90qg6rd/MoveMouse.exe

here is the screenshot of the application

GFwISYp.png

mY sYsTeM iS Not pErfoRmInG aS gOOd As I sAW oN yOuTuBe. WhA t IS a GoOd FaN CuRVe??!!? wHat aRe tEh GoOd OvERclok SeTTinGS FoR My CaRd??  HoW CaN I foRcE my GpU to uSe 1o0%? BuT WiLL i HaVE Bo0tllEnEcKs? RyZEN dOeS NoT peRfORm BetTer wItH HiGhER sPEED RaM!!dId i WiN teH SiLiCON LotTerrYyOu ShoUlD dEsHrOuD uR GPUmy SYstEm iS UNDerPerforMiNg iN WarzONEcan mY Pc Run WiNdOwS 11 ?woUld BaKInG MY GRaPHics card fIX it? MultimETeR TeSTiNG!! aMd'S GpU DrIvErS aRe as goOD aS NviDia's YOU SHoUlD oVERCloCk yOUR ramS To 5000C18

 

Link to comment
Share on other sites

Link to post
Share on other sites

By .net I will assume you mean C# (You can have multiple languages with .Net framework)

 

To move the mouse in C#, I believe it is just this simple (move left, then back to where it was)

public static void shakeMouse() {	Point originalPos = Cursor.Position;	Point newPos = new Point(originalPos.X + 10, originalPos.Y);	Cursor.Position = newPos; //Sets the new position	Thread.Sleep(100); //Giving time for everything to register...most likely not necessary but I like putting it in	Cursor.Position = originalPos; //Back to the original}

Just to make your life easier...here is how I would do it (I don't like Timers....I have had them stop working when the program loses focus, which I really hate).

 

Anyways instructions (Yes this could be easier using WinForm...but I like this streamlined application.  If you use WinForm you could skip steps 2,3,4, but you will have to modify the code a bit):

1) Create a C# console applicaiton (This is important)

2) In your solution explorer right click on the "References" text and select Add Reference

3) In the .Net tab of the Add Reference, add System.Drawing (Double click on the "System.Drawing" text and it will add it)

4) Do the same as 2) but this time add "System.Windows.Forms"

5) Copy and paste the following into your program.cs file (Replace all the text with the following)

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Drawing;using System.Threading;using System.Windows.Forms;namespace TestConsoleApp{    class Program    {        private const double Minutes = 7; //Change this for time (can have 7.5, 7, 1, whatever you want)        static void Main(string[] args)        {            while (true) //Basically constantly going through the loop            {                Thread.Sleep(Convert.ToInt32(60000 * Minutes)); //Stop computing for Minutes amount of times                shakeMouse(); //Shake the mouse            }        }        private static void shakeMouse()        {            Point originalPos = Cursor.Position;            Point newPos = new Point(originalPos.X + 10, originalPos.Y);            Cursor.Position = newPos; //Sets the new position            Thread.Sleep(100); //Giving time for everything to register...most likely not necessary but I like putting it in            Cursor.Position = originalPos; //Back to the original        }    }}

I quickly tested this and it does work if you follow the steps....enjoy

 

*edit...added comments, and I should mention.  To turn off the program select the program and using ctrl-c

0b10111010 10101101 11110000 00001101

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×