smasherprog / screen_capture_lite

cross platform screen/window capturing library
MIT License
638 stars 156 forks source link

Window title missing first char on Windows #68

Closed yuliswe closed 5 years ago

yuliswe commented 5 years ago

What's the reason in src/windows/GetWindows.cpp, the function EnumWindowsProc puts a \n at the beginning of the window title retrieved? When I use it to get window titles, every first char is somehow missing. For example, window title "Task Manager" is incorrectly set as "\nask Manager". The issue apparently can be solved by simply removing the line w.Name[textlen] = '\n';.

yuliswe commented 5 years ago

I don't understand the lines

             textlen = std::max(textlen - 1, static_cast<int>(sizeof(w.Name)) - 1);                                                   
             textlen = std::min(textlen, 0);  
             w.Name[textlen] = '\n';

This second line is setting textlen to 0. I believe this is a bug.

smasherprog commented 5 years ago

Thanks for pointing this out I just pushed a change It should fix this.