Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python触发器函数wndProc(win32api)_Python_Python 3.x_Winapi - Fatal编程技术网

Python触发器函数wndProc(win32api)

Python触发器函数wndProc(win32api),python,python-3.x,winapi,Python,Python 3.x,Winapi,我正在开发一个python应用程序,我想在窗口应用程序(如“FileZila”)调整大小或更改大小时触发我的a函数 我不知道为什么,但是“MyWndProc”没有被触发 显示器为: resolution: width : 1366 height : 768 328924 # print(hwnd) 我有这个样本: hwnd = -1; oldWndProc = False; root = tk.Tk() tk.Entry(root) root.grid_columnconfigure(

我正在开发一个python应用程序,我想在窗口应用程序(如“FileZila”)调整大小或更改大小时触发我的a函数

我不知道为什么,但是“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()
有什么想法吗


基于

如果
filezilla
窗口不是源于您的进程,则无法使用
SetWindowLong()
执行此操作。这在
GWL\u WNDPROC
的API帮助中有明确说明:
如果窗口与调用线程不属于同一进程,则无法更改此属性。请看一看
SetWindowsHookEx()
。哦。。我懂了。所以用这种方式。。我需要在
文件zilla
中创建一个dll,并尝试创建一些东西?因此,我无法将
wm_size
wm_size
挂接到我的软件中的函数,以编辑变量示例
is_resizing=True
?我需要创建一个
DLL
,使用一个函数直接应用于
filezilla软件
,而不是我的?是吗?