From 15e5315e835ddd9ca30fcc30c9a6885001f8dfac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <1173718158@qq.com> Date: Fri, 15 Nov 2024 03:53:55 +0800 Subject: [PATCH] fix --- cpp/winrtutils/winrtocr.cpp | 18 ++++++++++++++---- cpp/winrtutils/winrtsnapshot.cpp | 7 ++++++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/cpp/winrtutils/winrtocr.cpp b/cpp/winrtutils/winrtocr.cpp index c50ded98..55eacf5a 100644 --- a/cpp/winrtutils/winrtocr.cpp +++ b/cpp/winrtutils/winrtocr.cpp @@ -1,3 +1,5 @@ + +#ifndef WINXP #include #include #include @@ -25,8 +27,10 @@ using namespace Windows::Media::Devices; using namespace Windows::Security::Cryptography; using namespace Windows::Globalization; using namespace Windows::Foundation::Collections; +#endif DECLARE_API bool check_language_valid(wchar_t *language) { +#ifndef WINXP OcrEngine ocrEngine = OcrEngine::TryCreateFromUserProfileLanguages(); std::wstring l = language; try @@ -38,20 +42,26 @@ DECLARE_API bool check_language_valid(wchar_t *language) { return false; } +#else + return false; +#endif } -DECLARE_API void getlanguagelist(void(*cb)(LPCWSTR)) +DECLARE_API void getlanguagelist(void (*cb)(LPCWSTR)) { +#ifndef WINXP OcrEngine ocrEngine = OcrEngine::TryCreateFromUserProfileLanguages(); auto languages = ocrEngine.AvailableRecognizerLanguages(); - + for (auto &&language : languages) { auto lang = language.LanguageTag(); cb(lang.c_str()); } +#endif } DECLARE_API void OCR(void *ptr, size_t size, wchar_t *lang, wchar_t *space, void (*cb)(int, int, int, int, LPCWSTR)) { +#ifndef WINXP IBuffer buffer = CryptographicBuffer::CreateFromByteArray( winrt::array_view(static_cast(ptr), size)); InMemoryRandomAccessStream memoryStream; @@ -82,7 +92,7 @@ DECLARE_API void OCR(void *ptr, size_t size, wchar_t *lang, wchar_t *space, void y1 = std::min((unsigned int)rect.Y, y1); y2 = std::max(y2, (unsigned int)(rect.Y + rect.Height)); } - cb(x1,y1,x2,y2,xx.c_str()); + cb(x1, y1, x2, y2, xx.c_str()); } - +#endif } diff --git a/cpp/winrtutils/winrtsnapshot.cpp b/cpp/winrtutils/winrtsnapshot.cpp index 98aa9759..00d18fec 100644 --- a/cpp/winrtutils/winrtsnapshot.cpp +++ b/cpp/winrtutils/winrtsnapshot.cpp @@ -1,4 +1,6 @@ -#include + +#ifndef WINXP +#include #include #include #include @@ -203,8 +205,10 @@ void capture_window(HWND window_handle, void (*cb)(byte *, size_t)) memcpy(ptr, p_buf.get(), l_bmp_info.bmiHeader.biSizeImage); cb(p_buf2.get(), bmfh.bfSize); } +#endif DECLARE_API void winrt_capture_window(HWND hwnd, void (*cb)(byte *, size_t)) { +#ifndef WINXP // auto hwnd = GetForegroundWindow();// FindWindow(L"Window_Magpie_967EB565-6F73-4E94-AE53-00CC42592A22", 0); auto style_ex = GetWindowLong(hwnd, GWL_EXSTYLE); auto style_ex_save = style_ex; @@ -220,4 +224,5 @@ DECLARE_API void winrt_capture_window(HWND hwnd, void (*cb)(byte *, size_t)) capture_window(hwnd, cb); if (needset) SetWindowLong(hwnd, GWL_EXSTYLE, style_ex_save); +#endif }