42 lines
1.5 KiB
Python
42 lines
1.5 KiB
Python
import io
|
|
p = r'C:\Users\locpham\SonicForgeStudio\native_bridge\src\gui_probe.cpp'
|
|
s = io.open(p, encoding='utf-8', newline='').read()
|
|
def crlf(x): return x.replace('\n', '\r\n')
|
|
|
|
old = crlf(''' MSG msg;
|
|
while (PeekMessageW(&msg, nullptr, 0, 0, PM_REMOVE)) {
|
|
TranslateMessage(&msg);
|
|
DispatchMessageW(&msg);
|
|
}
|
|
Sleep(5);''')
|
|
new = crlf(''' MSG msg;
|
|
while (PeekMessageW(&msg, nullptr, 0, 0, PM_REMOVE)) {
|
|
printf("[pump] msg=0x%X hwnd=%p\\n", (unsigned)msg.message, (void*)msg.hwnd);
|
|
fflush(stdout);
|
|
TranslateMessage(&msg);
|
|
DispatchMessageW(&msg);
|
|
}
|
|
Sleep(5);''')
|
|
n = s.count(old)
|
|
print('pump_for match:', n)
|
|
s = s.replace(old, new)
|
|
|
|
old2 = crlf(''' MSG msg;
|
|
while (PeekMessageW(&msg, nullptr, 0, 0, PM_REMOVE)) {
|
|
TranslateMessage(&msg);
|
|
DispatchMessageW(&msg);
|
|
}''')
|
|
new2 = crlf(''' MSG msg;
|
|
while (PeekMessageW(&msg, nullptr, 0, 0, PM_REMOVE)) {
|
|
printf("[wpump] msg=0x%X hwnd=%p\\n", (unsigned)msg.message, (void*)msg.hwnd);
|
|
fflush(stdout);
|
|
TranslateMessage(&msg);
|
|
DispatchMessageW(&msg);
|
|
}''')
|
|
n2 = s.count(old2)
|
|
print('worker pump match:', n2)
|
|
s = s.replace(old2, new2)
|
|
|
|
io.open(p, 'w', encoding='utf-8', newline='').write(s)
|
|
print('written')
|