I’m sure the answer to this is embarrassingly easy, but I cannot for the life of me figure this one out. I have this code and if I just have the if statement it works perfectly, but when I add the else it stops working. What on earth am I doing wrong?!
import wmi
import win32api
c = wmi.WMI()
process_watcher = c.Win32_Process.watch_for("creation")
while True:
new_process = process_watcher()
if(new_process.Caption == "java.exe"):
win32api.MessageBox(0, 'Java has started, did you mean for this to happen?', 'Warning', 0x00001000)
else:
win32api.MessageBox(0, 'Not Java', 'Warning', 0x00001000)
You are using tabs for indentation, and I think you have an indentation error.
Use
python -tt scriptname.pyto detect.