forcomputers.blogg.se

Window keeps opening and closing
Window keeps opening and closing







For example if pythonw.exe and python_cmd_k.pyw are at C:\Python37\ then: "C:\Python37\pythonw.exe" "C:\Python37\python_cmd_k.pyw" "%1" I do not know if there are different paths in the registry for file association for different versions of Windows but for me it is at: HKEY_CURRENT_USER\Software\Classes\Applications\python.exe\shell\open\commandĬhange the data to the pythonw.exe path (not python.exe) and add the path to the ptyhon script above and "%1" as arguments ("%1" passes the full path of the doubled clicked file). py files with python.exe (not pythonw.exe) through Windows if they are not already and edit the registry entry for this association (Disclaimer: Always back up your registry before editing it if you are unsure of what you are doing). The intended script displays because the code in the initial script above runs the intended script with python.exe. Otherwise if you run it through python.exe an annoying blink of a command prompt appear as a result of the first window showing briefly each time. Running through pythonw.exe suppresses the command prompt window when this initial script runs. py script and launches a new command prompt to run the script you double clicked. This runs every time you double click any. #Run a python script in a new command prompt that does not closeĬommand = 'start cmd /k C:\Python37\python.exe "' + sys.argv + '"' pyw files to pythonw.exe (not python.exe) through Windows if they aren't already. Change the path C:\Python37\python.exe to the location of your python installation. The code required may differ for other versions. Now, for the implementation, I call the initial python script python_cmd_k.pyw. One possibly undesirable side effect is dragging and dropping or typing and running from a command prompt now opens a second command prompt rather than running in the command prompt you dragged or typed in.

window keeps opening and closing

Maybe there are good reasons not to do this, those with more knowledge please comment if so, but I figure if I run into any it is easy to revert back if needed. The initial script launches a new command prompt window with the /k parameter which keeps the command prompt open after completion and runs your intended script in the new window. py files so they run a separate initial script before running the intended script.

window keeps opening and closing window keeps opening and closing

I guess I'm too lazy to drag and drop or type when I don't need to so after some experimentation I came up with a solution. I couldn't find anywhere on the internet a true non-script specific, double click and the window doesn't close solution.









Window keeps opening and closing