How to properly close a process with NppExec?

Posted by Sam the Great on Stack Overflow See other posts from Stack Overflow or by Sam the Great
Published on 2012-12-16T23:01:19Z Indexed on 2012/12/16 23:02 UTC
Read the original article Hit count: 303

Filed under:
|
|
|

I'm not sure what's going on here, but the following code continues running even after I end the process in the NppExec console with Ctrl-C (during the execution of the while loop). I restarted my computer to stop the Ctrl key sends. However, if I run the script in Window's cmd prompt, Ctrl-C ends the script just fine.

import time
import win32com.client

shell = win32com.client.Dispatch("WScript.Shell")

time.sleep(2)
while True:
  shell.SendKeys('^') # Ctrl key
  time.sleep(0.5)

The NppExec run command I used was: cmd /C python -u "$(FULL_CURRENT_PATH)"

Let me know if there is any more information I can provide. Thanks.

© Stack Overflow or respective owner

Related posts about python

Related posts about notepad++