Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Add config support
Browse files Browse the repository at this point in the history
  • Loading branch information
Roblox-Thot committed Jun 1, 2023
1 parent 3bc9c6e commit 41d3052
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 18 deletions.
4 changes: 1 addition & 3 deletions MicrosoftRBX-FPS/MicrosoftRBX-FPS/MicrosoftRBX-FPS.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,11 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="resource.h" />
<ClInclude Include="SimpleIni.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Resource.rc" />
</ItemGroup>
<ItemGroup>
<Image Include="..\..\..\..\Downloads\icon.ico" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,13 @@
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SimpleIni.h">
<Filter>Resource Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Resource.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<Image Include="..\..\..\..\Downloads\icon.ico">
<Filter>Resource Files</Filter>
</Image>
</ItemGroup>
</Project>
Binary file modified MicrosoftRBX-FPS/MicrosoftRBX-FPS/Resource.rc
Binary file not shown.
65 changes: 55 additions & 10 deletions MicrosoftRBX-FPS/MicrosoftRBX-FPS/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <string>
#include <vector>
#include <thread>
#include "SimpleIni.h"

#define RST "\x1B[0m"
#define KRED "\x1B[31m"
Expand All @@ -26,6 +27,14 @@

HWND robloxHWND;
bool isEnabled = false;
int letterbox = 5; // Just how much to move the mouse back by to prevent it from being stuck LUL
int toggleKey = VK_INSERT;
std::string toggleKeyName = "INSERT";

int leftBorder = 30;
int rightBorder = 20;
int topBorder = 70;
int bottomBorder = 20;

int mode = 1;

Expand All @@ -35,6 +44,32 @@ std::string convert(wchar_t* lab) {
return str;
}

std::string GetKeyText(UCHAR virtualKey)
{ // "Borrowed" from https://stackoverflow.com/a/38107083
UINT scanCode = MapVirtualKey(virtualKey, MAPVK_VK_TO_VSC);

CHAR szName[128];
int result = 0;
switch (virtualKey)
{
case VK_LEFT: case VK_UP: case VK_RIGHT: case VK_DOWN:
case VK_RCONTROL: case VK_RMENU:
case VK_LWIN: case VK_RWIN: case VK_APPS:
case VK_PRIOR: case VK_NEXT:
case VK_END: case VK_HOME:
case VK_INSERT: case VK_DELETE:
case VK_DIVIDE:
case VK_NUMLOCK:
scanCode |= KF_EXTENDED;
default:
result = GetKeyNameTextA(scanCode << 16, szName, 128);
}
if (result == 0)
throw std::system_error(std::error_code(GetLastError(), std::system_category()),
"WinAPI Error occured.");
return szName;
}

bool isRbxActive()
{
return (GetForegroundWindow() == robloxHWND);
Expand Down Expand Up @@ -93,22 +128,21 @@ void fixCursor(HWND handle)
POINT realP;
if (GetCursorPos(&realP))
{
// Don't judge this :(
if (p.x < 30)
{
SetCursorPos(rect.left + 100, realP.y);
SetCursorPos(rect.left + leftBorder + letterbox, realP.y);
}
else if (p.x > sizeX - 40)
else if (p.x > sizeX - 20)
{
SetCursorPos(rect.right - 100, realP.y);
SetCursorPos(rect.right - rightBorder - letterbox, realP.y);
}
else if (p.y < 70)
{
SetCursorPos(realP.x, rect.top + 100);
SetCursorPos(realP.x, rect.top + topBorder + letterbox);
}
else if (p.y > sizeY - 40)
else if (p.y > sizeY - 20)
{
SetCursorPos(realP.x, rect.bottom - 100);
SetCursorPos(realP.x, rect.bottom - bottomBorder - letterbox);
}
}
}
Expand Down Expand Up @@ -146,7 +180,7 @@ void init()
std::cout << KBLU;
std::cout << BOLD("Roblox-HWND: ") << robloxHWND << std::endl;
std::cout << KYEL;
std::cout << BOLD("Keybind: ") << "INSERT" << std::endl;
std::cout << BOLD("Keybind: ") << toggleKeyName << std::endl;
std::cout << KCYN;
std::cout << BOLD("Enabled: ") << (isEnabled ? "Enabled" : "Disabled");
}
Expand All @@ -168,14 +202,14 @@ void toggle()
{
while (true)
{
if (GetAsyncKeyState(VK_INSERT))
if (GetAsyncKeyState(toggleKey))
{
isEnabled = not isEnabled;
system("cls");
std::cout << KBLU;
std::cout << BOLD("Roblox-HWND: ") << robloxHWND << std::endl;
std::cout << KYEL;
std::cout << BOLD("Keybind: ") << "INSERT" << std::endl;
std::cout << BOLD("Keybind: ") << toggleKeyName << std::endl;
std::cout << KCYN;
std::cout << BOLD("Enabled: ") << (isEnabled ? "Enabled" : "Disabled");
Sleep(1000);
Expand All @@ -186,6 +220,17 @@ void toggle()

int main()
{
CSimpleIniA ini;
ini.LoadFile("config.ini");
const char* section = "Settings";
toggleKey = static_cast<int>(ini.GetLongValue(section, "ToggleKey", VK_END));
toggleKeyName = GetKeyText(toggleKey);

leftBorder = static_cast<int>(ini.GetLongValue(section, "LeftBorder", 30));
rightBorder = static_cast<int>(ini.GetLongValue(section, "RightBorder", 20));
topBorder = static_cast<int>(ini.GetLongValue(section, "TopBorder", 70));
bottomBorder = static_cast<int>(ini.GetLongValue(section, "BottomBorder", 20));

std::cout << KYEL << "1. Force Center Lock\n2. Lock Border\n\n";
std::cout << KCYN << "Input: ";
std::cin >> mode;
Expand Down

0 comments on commit 41d3052

Please sign in to comment.