C++ bunny-hop

  • Rejestracja: dni
  • Ostatnio: dni
0

Od pol-roku pisze w c++ proste programy , takie zadania z themisa czy spoj . chcialem cos zrobic podchodzacego pod b-hopa w cs 1.6.
jednak gra nie wyczytuje wciskania klawiszy przez c++ . probowalem z myszka i dziala . nie wiem co trzeba zrobic i czy da sie w ten sposob wpisywac wartosci to gry. na przegladarce dziala.

Kopiuj
#define _WIN32_WINNT 0x0501
#include <windows.h>
#include <winuser.h>
#include <iostream>
using namespace std;

int sleep=0;

void sleepy()
{
	cout<<"Sleep time [miliseconds] [500-700]? : ";
	cin>>sleep;
}

bool bul=false;
const int KEYEVENT_KEYUP = 0x02;

void bunny_hop()
{
	cout<<"Press N to stop \n";
	bul=false;
	             
	while(bul!=true)
	{
		keybd_event(VK_UP,0,0,0);//UP arrow down
		
		///on left////////////////////////////////////////////
		keybd_event(VK_LEFT,0,0,0);//Left arrow down
		
		keybd_event(0x4B,0,0,0);//K - mouse left down
		///////////////////////////////////////////////////////
//		
//		for(int i=0;i<100;i++)
//		{
			/////jump///////////////////////////////////////
			keybd_event(VK_SPACE,0,0,0);//space bar
		
			keybd_event(VK_SPACE,0,KEYEVENT_KEYUP,0);
			////////////////////////////////////////////////
			if(GetAsyncKeyState(0x50))//P
			{
				bul==true;
			}
//		}
		
		Sleep(sleep);
		
		///off left////////////////////////////////////////////
		keybd_event(VK_LEFT,0,KEYEVENT_KEYUP,0);//Left arrow up
		
		keybd_event(0x4B,0,KEYEVENT_KEYUP,0);//K - mouse left up
		////////////////////////////////////////////////////////
		
		///on right////////////////////////////////////////////
		keybd_event(VK_RIGHT,0,0,0);//right arrow down
		
		keybd_event(0x4C,0,0,0);//L - mouse left down
		///////////////////////////////////////////////////////
		
//		for(int i=0;i<100;i++)
//		{
			/////jump///////////////////////////////////////
			keybd_event(VK_SPACE,0,0,0);//space bar
		
			keybd_event(VK_SPACE,0,KEYEVENT_KEYUP,0);
			////////////////////////////////////////////////
			if(GetAsyncKeyState(0x50))//P 
			{
				bul==true;
			}
//		
//		}
		
		Sleep(sleep);
		
		///off right////////////////////////////////////////////
		keybd_event(VK_RIGHT,0,KEYEVENT_KEYUP,0);//right arrow up
		
		keybd_event(0x4C,0,KEYEVENT_KEYUP,0);//L - mouse left up
		////////////////////////////////////////////////////////
		if(GetAsyncKeyState(0x50))//P
		{
			bul==true;
		}
	}
	keybd_event(VK_UP,0,KEYEVENT_KEYUP,0);//UP arrow down
	cout<<"B-hop ended \n";
}   

bool bull=false;

int main()
{
	sleepy();
	
	cout<<"Press I to start b_hop\n";
	while(bull!=true)
	{
		Sleep(300);
		
		if(GetAsyncKeyState(VK_ESCAPE))//ESC
		{
			bull=true;
			continue;
		}
		
		else if(GetAsyncKeyState(0x53))//S
		{
			sleepy();
			continue;
		}
		
		else if(GetAsyncKeyState(0x49))//I
		{
			bunny_hop();
			continue;
		}
		
	}
	
}
  • Rejestracja: dni
  • Ostatnio: dni
0

K i L to turn left i turn right

  • Rejestracja: dni
  • Ostatnio: dni
0

Zrobilem tez cookie auto clicker jakby ktos chcial

#define _WIN32_WINNT 0x500
#include <iostream>
#include <windows.h>
#include <ctime>
using namespace std;

bool gate=false;

int commands()
{
cout<<"ESCAPE to break clicking loop\nRIGHT CLICK to start setting position funkction\nS to change sleep time\n\n";
//cout<<"K to open commands listed above \n\n";
}

int sleep;

int sleepy()
{
cout<<"Time of 'sleep' before each click [in miliseconds] : ";
cin>>sleep;
}

bool bul;
POINT CursorPos;
float x=0,y=0;

int GetCursorPosition()
{
cout<<"SPACEBAR when positioned\n";
bul=false;
while(bul!=true)
{
if(GetAsyncKeyState(VK_SPACE))
{
GetCursorPos(&CursorPos);

		x= CursorPos.x;
		y= CursorPos.y;

		cout<<"x : "<<x<<"\n"<<"y : "<<y<<"\n";
		bul=true;
	}
}

}

void mouseLeftClick ()
{
INPUT Input = {0};

 // left down
 Input.type = INPUT_MOUSE;
 Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
 ::SendInput(1,&Input,sizeof(INPUT));
 
 // left up
 ::ZeroMemory(&Input,sizeof(INPUT));
 Input.type = INPUT_MOUSE;
 Input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
 ::SendInput(1,&Input,sizeof(INPUT));

}

int click_count=0;

int main()
{
cout<<"P.S This program never stops runing\n\n"; ///

commands();

sleepy();

GetCursorPosition();

time_t poczatek=time(0);

while(gate==false)
{
	if(GetAsyncKeyState(VK_RBUTTON))
	{
		GetCursorPosition();
	}
	
	if(GetAsyncKeyState(0x53))
	{
		sleepy();
	}

// if(GetAsyncKeyState(0x4B))
// {
// commands();
// }

	Sleep(sleep);

	SetCursorPos(x,y);
	
	mouseLeftClick ();
	
	click_count++;
	
	time_t koniec=time(0);
	
	if(GetAsyncKeyState(VK_ESCAPE))
	{
    	gate=true;
	}
	
}

time_t koniec=time(0);
cout<<"Running time : "<<difftime(koniec,poczatek)<<" seconds\n";
cout<<"Click count : "<<click_count<<"\n";
cout<<"Thank you for using this program , Goodbye til next time :) ";

}

Zarejestruj się i dołącz do największej społeczności programistów w Polsce.

Otrzymaj wsparcie, dziel się wiedzą i rozwijaj swoje umiejętności z najlepszymi.