#include #include #include #include #include #include #include // Make sure this path matches your setup // Initialize Interception context globally InterceptionContext context; // Send a key stroke via Interception void InterceptorSendKey(WORD key, bool keyDown) { InterceptionStroke stroke = {}; stroke.key.code = key; stroke.key.flags = keyDown ? 0 : KEY_UP; // We will just send through the first keyboard device found // You can improve to send through all keyboards if needed InterceptionDevice device = interception_wait(context); if (device == 0) { // No device found; fallback or error return; } interception_send(context, device, &stroke, 1); } // Press and release a key void InterceptorPressKey(WORD key, bool shift = false) { // Press shift if needed if (shift) { InterceptorSendKey(VK_SHIFT, true); std::this_thread::sleep_for(std::chrono::milliseconds(5)); } InterceptorSendKey(key, true); std::this_thread::sleep_for(std::chrono::milliseconds(10)); InterceptorSendKey(key, false); if (shift) { std::this_thread::sleep_for(std::chrono::milliseconds(5)); InterceptorSendKey(VK_SHIFT, false); } std::this_thread::sleep_for(std::chrono::milliseconds(50)); } // Read clipboard text std::string GetClipboardText() { if (!OpenClipboard(nullptr)) return ""; HANDLE hData = GetClipboardData(CF_TEXT); if (!hData) { CloseClipboard(); return ""; } char* pszText = static_cast(GlobalLock(hData)); if (!pszText) { CloseClipboard(); return ""; } std::string text(pszText); GlobalUnlock(hData); CloseClipboard(); return text; } int main() { std::string itemName; std::string includeNewItemsStr; bool includeNewItems = false; int delayMs; std::cout << "Enter the item name to search: "; std::getline(std::cin, itemName); std::cout << "Include new (not buyable) items? (yes/no): "; std::getline(std::cin, includeNewItemsStr); std::transform(includeNewItemsStr.begin(), includeNewItemsStr.end(), includeNewItemsStr.begin(), ::tolower); includeNewItems = (includeNewItemsStr == "yes" || includeNewItemsStr == "y"); std::cout << "Enter delay between pages (ms): "; std::cin >> delayMs; // Initialize Interception context context = interception_create_context(); if (!context) { std::cerr << "Failed to create interception context\n"; return 1; } std::cout << "Switch to game window within 4 seconds...\n"; std::this_thread::sleep_for(std::chrono::seconds(4)); while (true) { // Press Shift+Z to copy market page InterceptorPressKey('Z', true); std::this_thread::sleep_for(std::chrono::milliseconds(500)); // wait for clipboard to update std::string clipboard = GetClipboardText(); if (clipboard.empty()) { std::cerr << "Clipboard empty after Shift+Z. Stopping search.\n"; break; // Stop searching if no text was copied } // Split clipboard into lines std::vector lines; size_t pos = 0; while ((pos = clipboard.find('\n')) != std::string::npos) { std::string line = clipboard.substr(0, pos); clipboard.erase(0, pos + 1); lines.push_back(line); } // Add last line if any if (!clipboard.empty()) lines.push_back(clipboard); int lineNumber = 0; bool found = false; for (const auto& line : lines) { if (line.find(itemName) != std::string::npos) { // Check if this line is "new item" and user wants to skip new items if (!includeNewItems) { // Example check: line contains keyword "New" or "Not Buyable" - adjust to your game's clipboard format std::string lineLower = line; std::transform(lineLower.begin(), lineLower.end(), lineLower.begin(), ::tolower); if (lineLower.find("new") != std::string::npos || lineLower.find("not buyable") != std::string::npos) { // Skip this line lineNumber++; continue; } } found = true; break; } lineNumber++; } if (found) { std::cout << "Item found on line " << lineNumber << ". Pressing S " << lineNumber << " times...\n"; for (int i = 0; i < lineNumber; ++i) { InterceptorPressKey('S'); std::this_thread::sleep_for(std::chrono::milliseconds(50)); } break; // Item found and selected, stop the loop } else { // Press E, N, Enter to go next page InterceptorPressKey('E'); InterceptorPressKey('N'); InterceptorPressKey(VK_RETURN); std::this_thread::sleep_for(std::chrono::milliseconds(delayMs)); } } interception_destroy_context(context); std::cout << "Search completed.\n"; return 0; }