You are viewing our Forum Archives. To view or take place in current topics click here.
[C#] How to make a skidomatic 3000 (Toggles capslock key)
Posted:
[C#] How to make a skidomatic 3000 (Toggles capslock key)Posted:
Status: Offline
Joined: Nov 04, 201014Year Member
Posts: 134
Reputation Power: 7
Ok, first off, fire up your Visual Studio.
Create a new project. It will be a C# Console Application.
Now, go to where you see all the "using *whatever*;" and add this to it:
You may or may not have to manually reference it.
Referencing tut:
Right click your solution explorer,
Click "Add reference",
In our case, we stay in the .NET tab and scroll down,
Scroll down until you find "System.Windows.Forms" and select it,
Click OK,
Give your self a pat on the back, you can follow basic instructions.
In the main block, add this between the curly brackets:
Explanation of code:
This creates an infinite loop. The while block is executed if the statement evaluates to true, and in this case it always does.
Sends the capslock key, imitating the key being pressed.
Tells the thread to stop for 20 milliseconds and then continue. This is so you don't overwork your computer on something useless. You know, so this doesn't skyrocket your CPU usage.
Now, for an extra bit of fun, you can make the console window go away, making this invisible. Do this by double clicking "Properties" in the solution explorer, and then by changing it from a "Console Application" to a "Windows Forms Application"
Happy pranking 3333ch
Create a new project. It will be a C# Console Application.
Now, go to where you see all the "using *whatever*;" and add this to it:
using System.Threading;
using System.Windows.Forms;
You may or may not have to manually reference it.
Referencing tut:
Right click your solution explorer,
Click "Add reference",
In our case, we stay in the .NET tab and scroll down,
Scroll down until you find "System.Windows.Forms" and select it,
Click OK,
Give your self a pat on the back, you can follow basic instructions.
In the main block, add this between the curly brackets:
while (true)
{
SendKeys.SendWait("{CAPSLOCK}");
Thread.Sleep(20);
}
Explanation of code:
while (true)
This creates an infinite loop. The while block is executed if the statement evaluates to true, and in this case it always does.
SendKeys.SendWait("{CAPSLOCK}");
Sends the capslock key, imitating the key being pressed.
Thread.Sleep(20);
Tells the thread to stop for 20 milliseconds and then continue. This is so you don't overwork your computer on something useless. You know, so this doesn't skyrocket your CPU usage.
Now, for an extra bit of fun, you can make the console window go away, making this invisible. Do this by double clicking "Properties" in the solution explorer, and then by changing it from a "Console Application" to a "Windows Forms Application"
Happy pranking 3333ch
You are viewing our Forum Archives. To view or take place in current topics click here.