1.HTML中input type 为 file 则打开系统窗口

Python处理文件打开窗口

 

2.使用Python进行处理

1)安装win32相应的库

pip install pywin32

2)相关处理代码

import win32con
import win32gui

def open_file_dialog(file_path):
    dialog = win32gui.FindWindow("#32770", u"打开")
    if dialog == 0:
        return False
    assert dialog != 0
    button = win32gui.GetDlgItem(dialog, int("00000001", 16))
    assert button != 0
    edit = win32gui.GetDlgItem(dialog, int("0000047C", 16))
    assert edit != 0
    win32gui.SendMessage(edit, win32con.WM_SETTEXT, None, file_path)
    win32gui.SendMessage(dialog, win32con.WM_COMMAND, 1, button)
    return True

3)使用方法

open_file_dialog('G:\\29.png')

 

以上。

相关文章:

  • 2022-12-23
  • 2021-11-07
  • 2021-12-20
  • 2021-07-25
  • 2021-06-26
  • 2021-12-19
  • 2022-12-23
猜你喜欢
  • 2021-06-02
  • 2021-07-28
  • 2022-12-23
  • 2021-06-27
  • 2021-06-11
  • 2021-10-07
相关资源
相似解决方案