R
1280x1024 firefox
tabs on always
fullscreen
queue.h
struct Queue {
int key1;
int key2;
int key3;
int key4;
int key5;
int delay;
int tickid;
int type;
};
jlbot.cpp
// jam legend bot (2.0)
// drachlen@gmail.com
#include "stdafx.h"
#include "queue.h"
#include <stdio.h>
#include <string>
#include <iostream>
#include <sstream>
#include <math.h>
#include "Windows.h"
#include <WinAble.h>
using std::string;
using namespace std;
int returnTotal(int x, int y, HDC hdc)
{
int pixel;
int pixR;
int pixG;
int pixB;
int total;
pixel = GetPixel( hdc, x, y );
pixR = GetRValue(pixel);
pixG = GetGValue(pixel);
pixB = GetBValue(pixel);
total = pixR+pixG+pixB;
return total;
}
int checkStreak( HDC hdc )
{
//153 153 153 612 612 153 612 153
if( returnTotal(247,253, hdc) < 155 &&
returnTotal(253,246, hdc) < 155 &&
returnTotal(249,253, hdc) < 155 &&
returnTotal(250,252, hdc) > 155 &&
returnTotal(322,245, hdc) > 155 &&
returnTotal(321,250, hdc) < 155 &&
returnTotal(320,255, hdc) > 155 &&
returnTotal(326,261, hdc) < 155 )
{
return 0; // streak is 0
} else {
return 1; // streak is greater than 0
}
return 0;
}
int readNote( int note, HDC hdc )
{
int baseX = 535;
int baseY = 494;
int total;
switch(note)
{
case 1:
baseX = 535;// SUSTAIN/NOTE TYPE: 551 (baseX + 16)
break;
case 2:
baseX = 575;//591
break;
case 3:
baseX = 615;//631
break;
case 4:
baseX = 655;//671
break;
case 5:
baseX = 695;//etc
break;
default:
baseX = 535;
break;
}
//baseX = baseX-8;
total = returnTotal( baseX, baseY, hdc);
if( total > 400 )
{
// note detected, what kind of note?
// check if it's a non-strum note
// baseX + 16 is the coordinate for note type
// baseX + 16 and baseY-17, baseY-19, baseY-21 to check sustain
//what kind of note is this?
if( returnTotal( baseX + 16, baseY, hdc) > 700 )
{
//non strum note
//check the streak. is it 0?
// If the streak is 0, then we have to strum this non-strum note.
// if it's greater than 0, we don't have to strum
if( checkStreak(hdc) == 0 )
{
return 1;//1 // treat this as a note with strum
} else {
return 3; // note without strum
}
} else {
//this is a strum note:
return 1;
}
}
//couldn't find a note
return 0;
}
void sendKey(char ch, int state)
{
if(state == 1)
{
INPUT input[2];
::ZeroMemory(input, sizeof(input));
input[0].type = input[1].type = INPUT_KEYBOARD;
input[0].ki.wVk = input[1].ki.wVk = ch;
//input[1].ki.dwFlags = KEYEVENTF_KEYUP;
::SendInput(2, input, sizeof(INPUT));
} else {
INPUT input[2];
::ZeroMemory(input, sizeof(input));
input[0].type = input[1].type = INPUT_KEYBOARD;
input[0].ki.wVk = input[1].ki.wVk = ch;
input[1].ki.dwFlags = KEYEVENTF_KEYUP;
::SendInput(2, input, sizeof(INPUT));
}
}
void releaseNote( int key )
{
switch( key )
{
case 1:
// sendKey(0x31, 1);
//Sleep(1);
sendKey(0x31, 0);
break;
case 2:
//sendKey(0x32, 1);
//Sleep(1);
sendKey(0x32, 0);
break;
case 3:
// sendKey(0x33, 1);
//Sleep(1);
sendKey(0x33, 0);
break;
case 4:
// sendKey(0x34, 1);
// Sleep(1);
sendKey(0x34, 0);
break;
case 5:
// sendKey(0x35, 1);
//Sleep(1);
sendKey(0x35, 0);
break;
default:// ??
break;
}
}
void pressNote( int key )
{
switch( key )
{
case 1:
sendKey(0x31, 1);
break;
case 2:
sendKey(0x32, 1);
break;
case 3:
sendKey(0x33, 1);
break;
case 4:
sendKey(0x34, 1);
break;
case 5:
sendKey(0x35, 1);
break;
default:// ??
break;
}
}
void doTap( int key )
{
switch( key )
{
case 1:
sendKey(0x31, 0);
//Sleep(1);
sendKey(0x31, 1);
break;
case 2:
sendKey(0x32, 0);
//Sleep(1);
sendKey(0x32, 1);
break;
case 3:
sendKey(0x33, 0);
//Sleep(1);
sendKey(0x33, 1);
break;
case 4:
sendKey(0x34, 0);
//Sleep(1);
sendKey(0x34, 1);
break;
case 5:
sendKey(0x35, 0);
//Sleep(1);
sendKey(0x35, 1);
break;
default:// ??
break;
}
}
void main()
{
int dispc = 0;
/*
function: readNote( [1-5] );
returns the following:
0, no note
1, note with strum
2, note with strum and with sustain
3, note without strum
4, note without strum, with sustain
---
notes will not be released until a new note needs to be pressed
the held note will be based on the lowest note in the queue
*/
HDC hdc = GetDC(NULL);
Queue queue[30000];
int queueBottom = 0;
int queueIndex = 0;
int tick = 0;
int run = 0;
int queueLoop=0;
int delay1=0;
int delay2=0;
int delay3=0;
int delay4=0;
int delay5=0;
int lastHeld1 = 0;
int lastHeld2 = 0;
int lastHeld3 = 0;
int lastHeld4 = 0;
int lastHeld5 = 0;
int foundNote = 0;
int indexQueue = 0;
//
//modify these to tweak for specific songs
/////////////////
int varDelay = 67;
int betweenDelay = 74;
int indexQueueInt = 104;
int replaymode = 1;
int indexUp = 0;
///////////
//
int waitNext = 0;
int f5waitNext = 0;
int nextSong=0;
int pixR,pixG,pixB,pixel;
int f5wait=0;
INPUT input[2];
///////////
while(1)
{
///////////////////////////////////////////
////////////////////////////////////////////
/// JAM LEGEND BOT V1.0 CODE FOR PLAYING NEXT SONG:::
if(waitNext > 0)
{
waitNext--;
}
if(f5waitNext > 0)
{
f5waitNext--;
}
nextSong = GetPixel(hdc, 552, 420);
pixR = GetRValue(nextSong);
pixG = GetGValue(nextSong);
pixB = GetBValue(nextSong);
if(pixR == 9 && pixG == 121 && pixB == 201 && run == 1 && f5waitNext == 0)
{
nextSong = GetPixel(hdc, 553, 420);
pixR = GetRValue(nextSong);
pixG = GetGValue(nextSong);
pixB = GetBValue(nextSong);
if(pixR == 0 && pixG == 171 && pixB == 222 && run == 1)
{
if(f5wait == 0 && f5waitNext == 0)
{
f5waitNext = 750;
f5wait = 1;
}
if(f5wait == 1 && f5waitNext == 0)
{
f5wait = 2;
f5waitNext=1500;
}
if(f5wait == 2 && f5waitNext == 0)
{
f5wait=0;
f5waitNext = 700;
sendKey(0x74, 1);
//Sleep(1);
sendKey(0x74, 0);
}
}
}
nextSong = GetPixel(hdc, 750, 420);
pixR = GetRValue(nextSong);
pixG = GetGValue(nextSong);
pixB = GetBValue(nextSong);
if(pixR == 100 && pixG == 255 && pixB == 100 && run == 1 && f5waitNext == 0)
{
if(f5wait == 0)
{
f5waitNext = 1500;
f5wait = 1;
}
if(f5wait == 1 && f5waitNext == 0)
{
f5wait = 2;
f5waitNext=1300;
}
if(f5wait == 2 && f5waitNext == 0)
{
f5wait=0;
f5waitNext = 1300;
sendKey(0x74, 1);
Sleep(2);
sendKey(0x74, 0);
Sleep(8000);
}
}
nextSong = GetPixel(hdc, 460, 440);
pixR = GetRValue(nextSong);
pixG = GetGValue(nextSong);
pixB = GetBValue(nextSong);
if( (pixR > 240 && pixG > 240 && pixB > 240) && (run == 1 && waitNext == 0) )
{
::ZeroMemory(input, sizeof(input));
input[0].type = input[1].type = INPUT_MOUSE;
input[0].mi.dx = input[1].mi.dx = 37040; //23650 { center
input[0].mi.dy = input[1].mi.dy = 28020; // 9500 { center
input[1].mi.dwFlags = (MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE | MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP);
::SendInput(2, input, sizeof(INPUT));
Sleep(2500);
}
nextSong = GetPixel(hdc, 485, 512);
pixR = GetRValue(nextSong);
pixG = GetGValue(nextSong);
pixB = GetBValue(nextSong);
//34.34.34
if( ( (pixR == 34 && pixG == 34 && pixB == 34) || ( pixR == 33 && pixG == 33 && pixB == 33 ) ) && (run == 1 && waitNext == 0) )
{
Sleep(2500);
nextSong = GetPixel(hdc, 544, 522);//544,522
pixR = GetRValue(nextSong);
pixG = GetGValue(nextSong);
pixB = GetBValue(nextSong);
//255.255.255
if(pixR == 255 && pixG == 255 && pixB == 255 && run == 1)
{
//600,510
if(replaymode==1)
{
printf("replay mode\n");
/*::ZeroMemory(input, sizeof(input));
input[0].type = input[1].type = INPUT_MOUSE;
input[0].mi.dx = input[1].mi.dx = 32040; //23650 { center
input[0].mi.dy = input[1].mi.dy = 36000; //9500 { center
input[1].mi.dwFlags = (MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE | MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP );
::SendInput(2, input, sizeof(INPUT));*/
::ZeroMemory(input, sizeof(input));
input[0].type = input[1].type = INPUT_MOUSE;
input[0].mi.dx = input[1].mi.dx = 29040; //23650 { center
input[0].mi.dy = input[1].mi.dy = 36000; // 9500 { center
input[1].mi.dwFlags = (MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE | MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP);
::SendInput(2, input, sizeof(INPUT));
}else{
::ZeroMemory(input, sizeof(input));
input[0].type = input[1].type = INPUT_MOUSE;
input[0].mi.dx = input[1].mi.dx = 34040; //23650 { center
input[0].mi.dy = input[1].mi.dy = 32000; //9500 { center
input[1].mi.dwFlags = (MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE | MOUSEEVENTF_LEFTDOWN);
::SendInput(2, input, sizeof(INPUT));
::ZeroMemory(input, sizeof(input));
input[0].type = input[1].type = INPUT_MOUSE;
input[0].mi.dx = input[1].mi.dx = 34040; //23650 { center
input[0].mi.dy = input[1].mi.dy = 32000; // 9500 { center
input[1].mi.dwFlags = (MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE | MOUSEEVENTF_LEFTUP);
::SendInput(2, input, sizeof(INPUT));
}
Sleep(2500);
printf("sddf");
queueBottom = 0;
queueIndex = 1;
tick=0;
Sleep(1000);
::ZeroMemory(input, sizeof(input));
input[0].type = input[1].type = INPUT_MOUSE;
input[0].mi.dx = input[1].mi.dx = 24040; //23650 { center
input[0].mi.dy = input[1].mi.dy = 28020; //9500 { center
input[1].mi.dwFlags = (MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE);
::SendInput(2, input, sizeof(INPUT));
::ZeroMemory(input, sizeof(input));
input[0].type = input[1].type = INPUT_MOUSE;
input[0].mi.dx = input[1].mi.dx = 24040; //23650 { center
input[0].mi.dy = input[1].mi.dy = 28020; // 9500 { center
input[1].mi.dwFlags = (MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE);
::SendInput(2, input, sizeof(INPUT));
printf("second click\n");
waitNext = 10500;
}
}
nextSong = GetPixel(hdc, 555, 348);
pixR = GetRValue(nextSong);
pixG = GetGValue(nextSong);
pixB = GetBValue(nextSong);
//34.34.34
if(pixR == 173 && pixG == 250 && pixB == 39 && run == 1 && waitNext == 0)
{
printf("next song waitNext = 0 \n");
nextSong = GetPixel(hdc, 595, 350);
pixR = GetRValue(nextSong);
pixG = GetGValue(nextSong);
pixB = GetBValue(nextSong);
//255.255.255
Sleep(2500);
if(run == 1)
{
//600,510
::ZeroMemory(input, sizeof(input));
input[0].type = input[1].type = INPUT_MOUSE;
input[0].mi.dx = input[1].mi.dx = 34040; //23650 { center
input[0].mi.dy = input[1].mi.dy = 22020; //9500 { center
input[1].mi.dwFlags = (MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE | MOUSEEVENTF_LEFTDOWN);
::SendInput(2, input, sizeof(INPUT));
::ZeroMemory(input, sizeof(input));
input[0].type = input[1].type = INPUT_MOUSE;
input[0].mi.dx = input[1].mi.dx = 34040; //23650 { center
input[0].mi.dy = input[1].mi.dy = 22020; // 9500 { center
input[1].mi.dwFlags = (MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE | MOUSEEVENTF_LEFTUP);
::SendInput(2, input, sizeof(INPUT));
Sleep(5);
queueBottom = 0;
queueIndex = 2;
indexUp = 0;
if( lastHeld1 == 1 )
{
releaseNote( 1 );
lastHeld1=0;
}
if( lastHeld2 == 1 )
{
releaseNote( 2 );
lastHeld2=0;
}
if( lastHeld3 == 1 )
{
releaseNote( 3 );
lastHeld3=0;
}
if( lastHeld4 == 1 )
{
releaseNote( 4 );
lastHeld4=0;
}
if( lastHeld5 == 1 )
{
releaseNote( 5 );
lastHeld5=0;
}
Sleep(10);
::ZeroMemory(input, sizeof(input));
input[0].type = input[1].type = INPUT_MOUSE;
input[0].mi.dx = input[1].mi.dx = 14040; //23650 { center
input[0].mi.dy = input[1].mi.dy = 28020; //9500 { center
input[1].mi.dwFlags = (MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE);
::SendInput(2, input, sizeof(INPUT));
::ZeroMemory(input, sizeof(input));
input[0].type = input[1].type = INPUT_MOUSE;
input[0].mi.dx = input[1].mi.dx = 14040; //23650 { center
input[0].mi.dy = input[1].mi.dy = 28020; // 9500 { center
input[1].mi.dwFlags = (MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE);
::SendInput(2, input, sizeof(INPUT));
waitNext = 10050;
}
}
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////// ////////////////////////////////////////////
// END OLD CODE
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
Sleep(0.5);
if( run == 1 )
{
tick++;
if( ( (indexUp == 1) &&
( queue[queueBottom].key1 != queue[queueBottom+1].key1 ||
queue[queueBottom].key2 != queue[queueBottom+1].key2 ||
queue[queueBottom].key3 != queue[queueBottom+1].key3 ||
queue[queueBottom].key4 != queue[queueBottom+1].key4 ||
queue[queueBottom].key5 != queue[queueBottom+1].key5 )
))
{
indexUp = 0;
if( lastHeld1 == 1)
{
releaseNote( 1 );
}
if( lastHeld2 == 1 )
{
releaseNote( 2 );
}
if( lastHeld3 == 1 )
{
releaseNote( 3 );
}
if( lastHeld4 == 1 )
{
releaseNote( 4 );
}
if( lastHeld5 == 1 )
{
releaseNote( 5 );
}
//Sleep(1);
if( queue[queueBottom].key1 == 1 )
{
pressNote( 1 );
lastHeld1 = 1;
} else {
lastHeld1 = 0;
}
if( queue[queueBottom].key2 == 1 )
{
pressNote( 2 );
lastHeld2 = 1;
} else {
lastHeld2 = 0;
}
if( queue[queueBottom].key3 == 1 )
{
pressNote( 3 );
lastHeld3 = 1;
} else {
lastHeld3 = 0;
}
if( queue[queueBottom].key4 == 1 )
{
pressNote( 4 );
lastHeld4 = 1;
} else {
lastHeld4 = 0;
}
if( queue[queueBottom].key5 == 1 )
{
pressNote( 5 );
lastHeld5 = 1;
} else {
lastHeld5 = 0;
}
}
for( queueLoop=queueBottom; queueLoop<queueIndex; queueLoop++ )
{
if( queue[queueLoop].delay > 0 )
{
queue[queueLoop].delay--;
}
if( queue[queueLoop].delay == 23 )
{
if( queue[queueLoop].type == 0 )
{
//send strum
printf("strum\n");
sendKey(VK_RETURN, 1);
//Sleep(1);
sendKey(VK_RETURN, 0);
} else {
if( checkStreak( hdc ) == 0 )
{
// this note was queued as a non-strummed note,
// but a note must have been missed and now it must be strummed
//send strum
//printf("strum\n");
sendKey(VK_RETURN, 1);
//Sleep(1);
sendKey(VK_RETURN, 0);
} else {
//release note and re-press note (non-strummed)
//printf("note non strum\n");
if( queue[queueLoop].key1 == 1 )
{
doTap( 1 );
}
if( queue[queueLoop].key2 == 1 )
{
doTap( 2 );
}
if( queue[queueLoop].key3 == 1 )
{
doTap( 3 );
}
if( queue[queueLoop].key4 == 1 )
{
doTap( 4 );
}
if( queue[queueLoop].key5 == 1 )
{
doTap( 5 );
}
//sendKey(VK_RETURN, 1);
//Sleep(1);
//sendKey(VK_RETURN, 0);
}
}
}
if( queue[queueLoop].delay == 0 )
{
queue[queueLoop].key1 = 0;
queue[queueLoop].key2 = 0;
queue[queueLoop].key3 = 0;
queue[queueLoop].key4 = 0;
queue[queueLoop].key5 = 0;
queue[queueLoop].tickid = 0;
queue[queueLoop].type = 0;
queueBottom++;
}
}
//reset delays
if( delay1 > 0 )
{
delay1--;
}
if( delay2 > 0 )
{
delay2--;
}
if( delay3 > 0 )
{
delay3--;
}
if( delay4 > 0 )
{
delay4--;
}
if( delay5 > 0 )
{
delay5--;
}
//first note
//note with strum
if( readNote(1, hdc) == 1 && delay1 == 0)
{
delay1 = 100;
queue[queueIndex].delay = varDelay;
queue[queueIndex].key1 = 1;
queue[queueIndex].tickid = tick;
queue[queueIndex].type = 0;
foundNote = 1;
}
//note without strum
if( readNote(1, hdc) == 3 && delay1 == 0)
{
delay1 = 100;
queue[queueIndex].delay = varDelay;
queue[queueIndex].key1 = 1;
queue[queueIndex].tickid = tick;
queue[queueIndex].type = 1;
foundNote = 1;
}
//second note
//note with strum
if( readNote(2, hdc) == 1 && delay2 == 0)
{
delay2 = betweenDelay;
queue[queueIndex].delay = varDelay;
queue[queueIndex].key2 = 1;
queue[queueIndex].tickid = tick;
queue[queueIndex].type = 0;
foundNote = 1;
}
//note without strum
if( readNote(2, hdc) == 3 && delay2 == 0)
{
delay2 = betweenDelay;
queue[queueIndex].delay = varDelay;
queue[queueIndex].key2 = 1;
queue[queueIndex].tickid = tick;
queue[queueIndex].type = 1;
foundNote = 1;
}
//third note
//note with strum
if( readNote(3, hdc) == 1 && delay3 == 0)
{
delay3 = betweenDelay;
queue[queueIndex].delay = varDelay;
queue[queueIndex].key3 = 1;
queue[queueIndex].tickid = tick;
queue[queueIndex].type = 0;
foundNote = 1;
}
//note without strum
if( readNote(3, hdc) == 3 && delay3 == 0)
{
delay3 = betweenDelay;
queue[queueIndex].delay = varDelay;
queue[queueIndex].key3 = 1;
queue[queueIndex].tickid = tick;
queue[queueIndex].type = 1;
foundNote = 1;
}
//fourth note
//note with strum
if( readNote(4, hdc) == 1 && delay4 == 0)
{
delay4 = betweenDelay;
queue[queueIndex].delay = varDelay;
queue[queueIndex].key4 = 1;
queue[queueIndex].tickid = tick;
queue[queueIndex].type = 0;
foundNote = 1;
}
//note without strum
if( readNote(4, hdc) == 3 && delay4 == 0)
{
delay4 = betweenDelay;
queue[queueIndex].delay = varDelay;
queue[queueIndex].key4 = 1;
queue[queueIndex].tickid = tick;
queue[queueIndex].type = 1;
foundNote = 1;
}
//fifth note
//note with strum
if( readNote(5, hdc) == 1 && delay5 == 0)
{
delay5 = betweenDelay;
queue[queueIndex].delay = varDelay;
queue[queueIndex].key5 = 1;
queue[queueIndex].tickid = tick;
queue[queueIndex].type = 0;
foundNote = 1;
}
//note without strum
if( readNote(5, hdc) == 3 && delay5 == 0)
{
delay5 = betweenDelay;
queue[queueIndex].delay = varDelay;
queue[queueIndex].key5 = 1;
queue[queueIndex].tickid = tick;
queue[queueIndex].type = 1;
foundNote = 1;
}
if( foundNote == 1 )
{
indexQueue = indexQueueInt;
foundNote = 0;
}
if(indexQueue == 1 )
{
queueIndex++;
indexUp=1;
}
if( indexQueue > 0 )
{
indexQueue--;
}
//checkStreak(hdc);
/*if(dispc>0)
{
dispc--;
}
if( (readNote(1, hdc) > 0 || readNote(2, hdc) > 0 || readNote(3, hdc) > 0 || readNote(4, hdc) > 0 || readNote(5, hdc) > 0) && (run == 1) && (dispc==0) )
{
printf("%d|%d|%d|%d|%d\n", readNote(1, hdc), readNote(2, hdc), readNote(3, hdc), readNote(4, hdc), readNote(5, hdc) );
dispc=105;
}*/
}
if( ( GetAsyncKeyState(VK_F8) ) )
{
run = 1;
}
if( ( GetAsyncKeyState(VK_F9) ) )
{
run = 0;
}
}
return;
}