0

I am using

import ctypes
ctypes.windll.user32.ShowWindow( ctypes.windll.kernel32.GetConsoleWindow(), 6 )

to close the console and leave the pygame window open however I have to click on the window to interact with it. Can I make it so it goes back to the pygame window automatically?

Glitchd
  • 361
  • 2
  • 12
  • Perhaps you can focus the window manually - There's some python win32 examples of doing that here - https://stackoverflow.com/questions/6312627/windows-7-how-to-bring-a-window-to-the-front-no-matter-what-other-window-has-fo – Kingsley Feb 28 '19 at 21:26
  • @Kingsley thanks but i can't get this to work – Glitchd Feb 28 '19 at 21:37
  • How are you launching your code? Do you need to run your script as a windowed application instead of as a console? If you use `pythonw` to launch your script there will be no console window. – import random Feb 28 '19 at 21:48
  • @Eric ok but is there another file type to save it as to always open with python w. I use the console for 'non-pygame' codes – Glitchd Feb 28 '19 at 21:50
  • You can change your file extension to `.pyw` and double-clicking the file in explorer should launch the script in windowed mode. – import random Feb 28 '19 at 21:58
  • @Eric pls post that as an answer so u get some rep – Glitchd Feb 28 '19 at 22:20

1 Answers1

1

A python script may be run in windowed mode by launching with pythonw, this may be automatically handled by changing the file extension to .pyw.

See this answer for more detailed information.

import random
  • 3,054
  • 1
  • 17
  • 22