Code:if(GetAsyncKeyState(VK_NUMPAD0)&1) { //code goes here }
hi, i'm almost done with my first c++ project, a glitch-tool
i just haven't found a way to trigger my program with a keyboard
can you help me?
Code:if(GetAsyncKeyState(VK_NUMPAD0)&1) { //code goes here }
Ah we-a blaze the fyah, make it bun dem!
is this good (correct my errors plz)
Code:#include <windows.h> int main() if(GetAsyncKeyState(VK_NUMPAD1)&1) bool Project = true else if (GetAsyncKeyState (VK_NUMPAD0)&1) bool Project = false if Project = true { for(;;){ Sleep(100); keybd_event(VkKeyScan('z'),0,0,0); keybd_event(VkKeyScan('s'),0,0,0); } return 0; } if Project = false { for(;;){ Sleep(100); keybd_event(VkKeyScan('z'),0,0,0); keybd_event(VkKeyScan('s'),0,0,0); } }
The Problem isn't so much ur logic as it just seems you don't know how to write code. This will not even compile. You should be able to fix the compile errors u get for yourself. It's going to say something along the lines of:
"in function main int val is not returned."
That is because you did not put all of the lines of execution in brackets. Therefore only the first line will be executed o_O... and that line does not return an int. Also its incorrect. You did not put a semicolon on the line after ur if statement. The problem is you don't know how to program, and ur failure at these points reveals a weak grasp on the elementary concepts such as control, flow, and structure. However ur logic is there. I recommend reading the first chapter of any programming book and completing the first program, usually called: "hello world". It's a shame your going get stuck on little details when ur logic is very sound for someone just starting out. You have potential...
"Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."- Dwight D. Eisenhower
woodz (04-24-2010)
i fixed it,
now there is this:
what do i do? (my first dll)
hit f7 instead of f5.... there's no need to debug it. Well there is but I would just test it by injecting it into ur game manually.
"Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."- Dwight D. Eisenhower
woodz (04-24-2010)
Oh god, that looks like a mix of C++, VB and brainphuck >.>
Do as why says(no idea what he says, but im sure it contains valuable information)
Ah we-a blaze the fyah, make it bun dem!
Fixed and added comments for you
Code:#include <windows.h> bool Running; int main(){ while (true){ //infinite loop if(GetAsyncKeyState(VK_NUMPAD1)&1)//if numpad1 is pressed start pressing keys Running = true; while (Running) { //as long as Running == true, will continue to press buttons keybd_event(VkKeyScan('z'),0,0,0); keybd_event(VkKeyScan('z'),0,KEYEVENTF_KEYUP,0);//lifts up z key keybd_event(VkKeyScan('s'),0,0,0); keybd_event(VkKeyScan('s'),0,KEYEVENTF_KEYUP,0); //lifts up s key Sleep(100); if (GetAsyncKeyState(VK_NUMPAD0)&1) Running = false; // if you press numpad0 it will stop pressing buttons } } return 1; //although this will never be reached because of the infinite loop, it is necessary... }
woodz (05-08-2010)
Lol oops, I'm used to java where it is initialized as false nice catch
Code:#include <windows.h> bool Running; int main(){ Running = false; while (true){ //infinite loop if(GetAsyncKeyState(VK_NUMPAD1)&1)//if numpad1 is pressed start pressing keys Running = true; while (Running) { //as long as Running == true, will continue to press buttons keybd_event(VkKeyScan('z'),0,0,0); keybd_event(VkKeyScan('z'),0,KEYEVENTF_KEYUP,0);//lifts up z key keybd_event(VkKeyScan('s'),0,0,0); keybd_event(VkKeyScan('s'),0,KEYEVENTF_KEYUP,0); //lifts up s key Sleep(100); if (GetAsyncKeyState(VK_NUMPAD0)&1) Running = false; // if you press numpad0 it will stop pressing buttons } } return 1; //although this will never be reached because of the infinite loop, it is necessary... }
woodz (05-08-2010)