| View previous topic :: View next topic |
| Author |
Message |
blackmorpheus Expert Cheater
Reputation: 0
Joined: 05 Apr 2008 Posts: 159
|
Posted: Wed Oct 22, 2008 12:47 pm Post subject: Noob C++ question |
|
|
Hey all, i currently have to following code for my autoshooter ( not aimbot).
| Code: |
int main()
{
while(1)
{
Sleep(10);
if(GetAsyncKeyState(VK_F9)&1)
{
my code
}
}
return 0;
} |
When i press f9, it executes "my code" once. But now, i want that when i press F9 once, it keeps executing "my code" , and when i press F10, it stops executing mycode.
I thought of something like
i
| Code: |
if(GetAsyncKeyState(VK_F9)&1)
BOOL a = TRUE;
if(GetAsyncKeyState(VK_F10)&1)
BOOL a = FALSE;
while(a)
{
my code
}
|
but that doesn't seem to work... Can anyone give me some help?
|
|
| Back to top |
|
 |
TraxMate Master Cheater
Reputation: 0
Joined: 01 Mar 2008 Posts: 363
|
Posted: Wed Oct 22, 2008 1:33 pm Post subject: |
|
|
I think it's something like this:
| Code: | bool a;
if(GetAsyncKeyState(VK_F9)&1)
a = true;
else if(GetAsyncKeyState(VK_F10)&1)
a = false;
while(a == true)
{
my code
} |
|
|
| Back to top |
|
 |
Noz3001 I'm a spammer
Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Wed Oct 22, 2008 2:02 pm Post subject: |
|
|
| Follow the code, you will never get out of the loop to check the key state.
|
|
| Back to top |
|
 |
Spawnfestis GO Moderator
Reputation: 0
Joined: 02 Nov 2007 Posts: 1746 Location: Pakistan
|
Posted: Wed Oct 22, 2008 2:05 pm Post subject: |
|
|
Don't forget your brackets -> { }
Hehe!
_________________
CLICK TO HAX MAPLESTORAY ^ !!!! |
|
| Back to top |
|
 |
Heartless I post too much
Reputation: 0
Joined: 03 Dec 2006 Posts: 2436
|
Posted: Wed Oct 22, 2008 2:47 pm Post subject: |
|
|
| Code: | #include <windows.h>
bool Whatever = false;
int main()
{
while(true)
{
if (GetAsyncKeyState(VK_F9) && Whatever == false)
{
Whatever = true;
Sleep(250);
}
else if (GetAsyncKeyState(VK_F9) && Whatever == true)
{
Whatever = false;
Sleep(250);
}
if (Whatever == true)
{
//code here
}
}
return 0;
}
|
_________________
What dosen't kill you, usually does the second time. |
|
| Back to top |
|
 |
Noz3001 I'm a spammer
Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Wed Oct 22, 2008 3:01 pm Post subject: |
|
|
| HornyAZNBoy wrote: | | Code: | #include <windows.h>
bool Whatever = false;
int main()
{
while(true)
{
if (GetAsyncKeyState(VK_F9) && Whatever == false)
{
Whatever = true;
Sleep(250);
}
else if (GetAsyncKeyState(VK_F9) && Whatever == true)
{
Whatever = false;
Sleep(250);
}
if (Whatever == true)
{
//code here
}
}
return 0;
}
|
|
Into this:
| Code: | #include <windows.h>
#pragma comment(lib, "user32.lib")
int main( void )
{
bool Whatever = false;
for( ;;Sleep(10) )
{
if( GetAsyncKeyState(VK_F9)&01 ) {
Whatever ^= true;
}
if( Whatever == true ) {
// True
} else {
// False
}
}
return 0;
} |
|
|
| Back to top |
|
 |
nog_lorp Grandmaster Cheater
Reputation: 0
Joined: 26 Feb 2006 Posts: 743
|
Posted: Wed Oct 22, 2008 3:58 pm Post subject: |
|
|
| Code: | for(;;) {
if(GetAsyncKeyState(VK_F9))
for(;!GetAsyncKeyState(VK_F10);) {
...
}
}
|
Insert sleeps, and correct any errors with API usage since I haven't used win32 in quite awhile.
_________________
Mutilated lips give a kiss on the wrist of the worm-like tips of tentacles expanding in my mind
I'm fine accepting only fresh brine you can get another drop of this yeah you wish |
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Thu Oct 23, 2008 8:44 am Post subject: |
|
|
| RegisterHotKey...
|
|
| Back to top |
|
 |
blackmorpheus Expert Cheater
Reputation: 0
Joined: 05 Apr 2008 Posts: 159
|
Posted: Thu Oct 23, 2008 9:33 am Post subject: |
|
|
Tnx all. Don't really know how RegisterHotkey works so i used GetAsyncKeyState.
Anyway, here is my code. It's working for the game CounterStrike2D. But i think it can be improved.
| Code: |
#include <windows.h>
#include <iostream>
using namespace std;
int main()
{
bool Whatever = false;
bool Team = false; //false for CT, true for T
cout << "Welcome to CS2D Autoshooter" ;
while(true)
{
if(GetAsyncKeyState(VK_F9) && Whatever == false)
{
Whatever = true;
Sleep(250);
}
else if (GetAsyncKeyState(VK_F9) && Whatever == true)
{
Whatever = false;
Sleep(250);
}
if(GetAsyncKeyState(VK_F4) && Team == false)
{
Team = true;
Sleep(250);
}
else if (GetAsyncKeyState(VK_F4) && Team == true)
{
Team = false;
Sleep(250);
}
if (Whatever == true)
{
Sleep(10);
HWND hWnd;
hWnd = FindWindow(NULL, "Unreal Software's Counter-Strike 2D"); // can i place this outside the loop?
if(hWnd == NULL)
{
cout << "CounterStrike2D is not opened!\n";
}
else
{
POINT pos;
GetCursorPos(&pos);
HDC hScreenDC = GetDC(hWnd);
COLORREF rgb = GetPixel(hScreenDC, pos.x, pos.y);
ReleaseDC(hWnd, hScreenDC);
UINT red = GetRValue (rgb);
UINT green = GetGValue (rgb);
UINT blue = GetBValue (rgb);
if(Team == true)
{
if(red==255 && blue==0)
{
cout << rgb << endl;
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
}
}
else
{
if(blue==255 && red==0)
{
cout << rgb << endl;
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
}
}
rgb = 000;
}
}
}
return 0;
}
|
I am currently trying to make an aimbot using an entirely different method. OpenGL Hooking.
But i cannot figure out how to get coordinates of X,Y models.
I thought they were placed onto the screen with glOrtho().
I read some tutorials about wrappers and client hooks but they are mostly for normal CounterStrike, source.
|
|
| Back to top |
|
 |
|