@@ -28,10 +28,12 @@ T getValueFromCallbackData(const Napi::CallbackInfo &info,
2828
2929std::string toUtf8 (const std::wstring &str) {
3030 std::string ret;
31- int len = WideCharToMultiByte (CP_UTF8, 0 , str.c_str (), str.length (), NULL , 0 , NULL , NULL );
31+ int len = WideCharToMultiByte (CP_UTF8, 0 , str.c_str (), str.length (), NULL ,
32+ 0 , NULL , NULL );
3233 if (len > 0 ) {
3334 ret.resize (len);
34- WideCharToMultiByte (CP_UTF8, 0 , str.c_str (), str.length (), &ret[0 ], len, NULL , NULL );
35+ WideCharToMultiByte (CP_UTF8, 0 , str.c_str (), str.length (), &ret[0 ], len,
36+ NULL , NULL );
3537 }
3638 return ret;
3739}
@@ -51,7 +53,6 @@ Process getWindowProcess(HWND handle) {
5153 return {static_cast <int >(pid), path};
5254}
5355
54-
5556Napi::Object getActiveWindow (const Napi::CallbackInfo &info) {
5657 Napi::Env env{info.Env ()};
5758
@@ -85,7 +86,7 @@ Napi::Array getWindows(const Napi::CallbackInfo &info) {
8586
8687 for (int i = 0 ; i < _windows.size (); i++) {
8788 auto obj{Napi::Object::New (env)};
88-
89+
8990 obj.Set (" id" , _windows[i].id );
9091 obj.Set (" processId" , _windows[i].process .pid );
9192 obj.Set (" path" , _windows[i].process .path );
@@ -96,7 +97,6 @@ Napi::Array getWindows(const Napi::CallbackInfo &info) {
9697 return arr;
9798}
9899
99-
100100Napi::Number getMonitorFromWindow (const Napi::CallbackInfo &info) {
101101 Napi::Env env{info.Env ()};
102102
@@ -234,6 +234,9 @@ Napi::Boolean bringWindowToTop(const Napi::CallbackInfo &info) {
234234
235235 auto handle{getValueFromCallbackData<HWND>(info, 0 )};
236236 BOOL b{SetForegroundWindow (handle)};
237+ SetActiveWindow (handle);
238+ SetWindowPos (handle, HWND_TOP, 0 , 0 , 0 , 0 ,
239+ SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
237240
238241 return Napi::Boolean::New (env, b);
239242}
0 commit comments