我正在使用python应用程序,我希望在窗口应用程序如" FileZila"调整大小或改变大小。
我不知道为什么,但是," MyWndProc"没有被触发..
显示为:
resolution:
width : 1366
height : 768
328924 # print(hwnd)
我有这个样本:
hwnd = -1;
oldWndProc = False;
root = tk.Tk()
tk.Entry(root)
root.grid_columnconfigure(0, weight=1)
root.title("test REZize trigger")
root.geometry("200x200")
app = tk.Frame(root)
app.grid()
btn_start = tk.Button(app, text="Start Scan", command=start)
btn_stop = tk.Button(app, text="Stop", command=stop)
app_text = tk.Entry(app, text="")
war_label = tk.Label(app, text="", fg="red",font = "Times")
info_label = tk.Label(app, text="", fg="blue",font = "Times")
btn_start.grid()
btn_stop.grid()
app_text.grid()
war_label.grid()
info_label.grid()
def start():
"""Enable scanning by setting the global flag to True."""
global running
if(running == False):
running = True
startbot();
def MyWndProc(hWnd, msg, wParam, lParam):
global oldWndProc;
# Display what we've got.
print ("PRINT MyWndProc")
if msg == win32con.WM_SIZE:
print("RESIZE STUFF")
win32api.SetWindowLong(hwnd,
win32con.GWL_WNDPROC,
oldWndProc)
if msg == win32con.WM_SIZING:
print("RESIZING STUFF")
return win32gui.CallWindowProc(oldWndProc,
hWnd, msg, wParam, lParam)
def startbot():
global hwnd,oldWndProc;
bug = False
width = height = 0;
width = win32api.GetSystemMetrics(0)
height = win32api.GetSystemMetrics(1)
print("resolution: ")
print("width : " + str(width) + " \nheight : " + str(height))
msg = "";
hwnd = get_window_hwnd("FileZilla")
print(hwnd);
oldWndProc = win32gui.SetWindowLong(hwnd,win32con.GWL_WNDPROC,MyWndProc)
while(bug == False):
if(hwnd != -1 or hwnd != False):
#do something
info_label.config(text=msg);
stop()
bug = True
if __name__ == "__main__":
root.mainloop()
任何想法??