extract remaining text

This commit is contained in:
Akash Mozumdar 2018-12-18 16:32:28 -05:00
parent 5523644ef9
commit 240f5f235b
4 changed files with 25 additions and 14 deletions

View File

@ -1,4 +1,5 @@
#include "extension.h"
#include "text.h"
#include <winhttp.h>
#include <QInputDialog>
#include <QTimer>
@ -64,8 +65,8 @@ BOOL WINAPI DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved
{
translateTo = QInputDialog::getItem(
nullptr,
"Select Language",
"What language should Bing translate to?",
SELECT_LANGUAGE,
BING_PROMPT,
languages,
0, false, nullptr,
Qt::WindowCloseButtonHint
@ -139,7 +140,7 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
requestTimes.erase(std::remove_if(requestTimes.begin(), requestTimes.end(), [&](DWORD requestTime) { return GetTickCount() - requestTime > 60 * 1000; }), requestTimes.end());
if (!sentenceInfo["current select"] && requestTimes.size() > 30)
{
sentence += L"\r\nToo many translation requests: refuse to make more";
sentence += TOO_MANY_TRANS_REQUESTS;
return true;
}
}
@ -148,7 +149,7 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
Translate(sentence, translateFrom, translateTo);
translation = Translate(sentence, translateFrom, translateTo);
for (auto& c : translation) if (c == L'\\') c = 0x200b;
if (translation.empty()) translation = L"Error while translating.";
if (translation.empty()) translation = TRANSLATION_ERROR;
sentence += L"\r\n" + translation;
return true;
}

View File

@ -1,4 +1,5 @@
#include "extension.h"
#include "text.h"
#include <winhttp.h>
#include <ctime>
#include <QInputDialog>
@ -80,8 +81,8 @@ BOOL WINAPI DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved
{
translateTo = QInputDialog::getItem(
nullptr,
"Select Language",
"What language should Google translate to?",
SELECT_LANGUAGE,
GOOGLE_PROMPT,
languages,
0, false, nullptr,
Qt::WindowCloseButtonHint
@ -143,7 +144,7 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
requestTimes.erase(std::remove_if(requestTimes.begin(), requestTimes.end(), [&](DWORD requestTime) { return GetTickCount() - requestTime > 60 * 1000; }), requestTimes.end());
if (!sentenceInfo["current select"] && requestTimes.size() > 30)
{
sentence += L"\r\nToo many translation requests: refuse to make more";
sentence += TOO_MANY_TRANS_REQUESTS;
return true;
}
}
@ -203,7 +204,7 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
}
}
if (translation.empty()) translation = L"Error while translating (TKK=" + std::to_wstring(TKK) + L")";
if (translation.empty()) translation = TRANSLATION_ERROR + (L" (TKK=" + std::to_wstring(TKK) + L")");
sentence += L"\r\n" + translation;
return true;
}

View File

@ -1,4 +1,5 @@
#include "extension.h"
#include "text.h"
#include <QMainWindow>
#include <QLayout>
#include <QLabel>
@ -22,12 +23,12 @@ struct : QMainWindow {
{
std::lock_guard l(m);
try { regex = newRegex.toStdWString(); }
catch (...) { return output->setText("Invalid regex"); }
output->setText("Currently filtering: " + newRegex);
catch (...) { return output->setText(INVALID_REGEX); }
output->setText(CURRENT_FILTER + newRegex);
});
QMainWindow::resize(350, 60);
QMainWindow::setCentralWidget(centralWidget);
QMainWindow::setWindowTitle("Regex Filter");
QMainWindow::setWindowTitle(REGEX_FILTER);
QMainWindow::show();
}
}*window = nullptr;

View File

@ -55,6 +55,14 @@ constexpr auto TOO_MANY_HOOKS = u8"Textractor: too many hooks: can't insert";
constexpr auto FUNC_MISSING = u8"Textractor: function not present";
constexpr auto MODULE_MISSING = u8"Textractor: module not present";
constexpr auto GARBAGE_MEMORY = u8"Textractor: memory constantly changing, useless to read";
constexpr auto SELECT_LANGUAGE = u8"Select Language";
constexpr auto BING_PROMPT = u8"What language should Bing translate to?";
constexpr auto GOOGLE_PROMPT = u8"What language should Google translate to?";
constexpr auto TOO_MANY_TRANS_REQUESTS = L"\r\nToo many translation requests: refuse to make more";
constexpr auto TRANSLATION_ERROR = L"Error while translating";
constexpr auto REGEX_FILTER = u8"Regex Filter";
constexpr auto INVALID_REGEX = u8"Invalid regex";
constexpr auto CURRENT_FILTER = u8"Currently filtering: ";
#endif // ENGLISH
#ifdef TURKISH
@ -66,7 +74,7 @@ constexpr auto SETTINGS = u8"Ayarlar";
constexpr auto EXTENSIONS = u8"Uzantılar";
constexpr auto SELECT_PROCESS = u8"İşlem Seçin";
constexpr auto ATTACH_INFO = u8"Bağlanmak istediğiniz işlemi görmüyorsanız yönetici olarak çalıştırmayı deneyin";
constexpr auto CODE_INFODUMP = u8"Hook kodunu girin\r\n"
constexpr auto CODE_INFODUMP = u8"Kanca kodunu girin\r\n"
u8"/H{A|B|W|S|Q|V}[N][kod_sayfası#]göreli_veri_konumu[*göreli_referanstan_ayırma_konumu1][:göreli_ayırma_konumu[*göreli_referanstan_ayırma_konumu2]]@adres[:modül[:fonksiyon]]\r\n"
u8"YA DA\r\n"
u8"Okuma kodunu girin\r\n"