Hiding the console window after reading input

前端 未结 1 1260
死守一世寂寞
死守一世寂寞 2021-01-06 21:10

I have a script that has a GUI, which takes user data and stores it into a text file. It runs another script (an .exe), which waits for user input and then does some work. W

相关标签:
1条回答
  • 2021-01-06 21:26

    Here's a code snippet to hide the Windows console in a Python script:

    import ctypes
    
    kernel32 = ctypes.WinDLL('kernel32')
    user32 = ctypes.WinDLL('user32')
    
    SW_HIDE = 0
    
    hWnd = kernel32.GetConsoleWindow()
    if hWnd:
        user32.ShowWindow(hWnd, SW_HIDE)
    
    0 讨论(0)
提交回复
热议问题