Saving a script when closing a window and opening a text editor in Python

As we all know, April Fools are coming, so I would write a good script to play a trick on someone, a harmless version of the famous and dangerous MEMZ virus.

script I have:

import webbrowser
import time

def program():
    time.sleep(13)
    url = "https://www.google.nl/#q=TROLOL+GO+TO+LAUGH+IDIOT&*"
    webbrowser.open(url,new=new)
    time.sleep(16)
    url = "https://www.google.nl/webhp?sourceid=chrome-instant&rlz=1CAACAG_enNL654NL655&ion=1&espv=2&ie=UTF-8#q=CS:GO+Hacks+No+Download&*"
    webbrowser.open(url, new=new)
    time.sleep(18)
    url = "https://www.youtube.com/watch?v=7S94ohyErSw"
    webbrowser.open(url, new=new)
    time.sleep(23)

def main():
    pass

if __name__ == "__main__":
    main()

      

I want to be able to open a text editor with text like in a real virus. The window with windows error will be fine. Also I don't want an invitation. so it would be convenient to close the prompt without ending the script.

Does anyone have any idea?

Thanks in advance.

Nathan.

EDIT: My Victim The computer has Windows.

EDIT2: I updated the script:

import webbrowser
import ctypes
import time

MB_OK = 0x0
MB_OKCXL = 0x01
MB_YESNOCXL = 0x03
MB_YESNO = 0x04
MB_HELP = 0x4000
ICON_EXLAIM = 0x30
ICON_INFO = 0x40
ICON_STOP = 0x10
ICON_QUES = 0x20

def program():
    ctypes.windll.user32.MessageBoxW(0, "Your computer is fucked by the MEMZ Trojan, good luck trying to keep using it.", "GET REKT, DABBBB", MB_OK | ICON_INFO)
    time.sleep(2)
    ctypes.windll.user32.MessageBoxW(0, "BTW if you shut down your computer you wont be able to start it back up.", "Almost forgot....", MB_OK | ICON_INFO)
    time.sleep(13)
    url = "https://www.google.nl/#q=TROLOL+GO+TO+LAUGH+IDIOT&*"
    webbrowser.open(url,new=new)
    time.sleep(16)
    url = "https://www.google.nl/webhp?sourceid=chrome-instant&rlz=1CAACAG_enNL654NL655&ion=1&espv=2&ie=UTF-8#q=CS:GO+Hacks+No+Download&*"
    webbrowser.open(url, new=new)
    time.sleep(18)
    url = "https://www.youtube.com/watch?v=7S94ohyErSw"
    webbrowser.open(url, new=new)
    time.sleep(23)
    ctypes.windll.user32.MessageBoxW(0, "Still using this computer?", "Hell is that way", MB_OK | ICON_QUES)
    time.sleep(17)
    url = "https://www.gottabemobile.com/black-ops-3-cheats-hacks-things-to-know/"
    webbrowser.open(url, new=new)
    time.sleep(12)
    url = "https://thepiratebay.org/"
    webbrowser.open(url, new=new)
    time.sleep(32)
    url = "http://stackoverflow.com/questions/43114927/keeping-the-script-running-when-closing-the-window-and-opening-a-text-editor-in"
    webbrowser.open(url, new=new)
    ctypes.windll.user32.MessageBoxW(0, "Trololol. Fijne 1 april nog Justus! Groetjes Natan!", "April fools", MB_OK | ICON_INFO)

def main():
    program()

if __name__ == "__main__":
    main()

      

+3


source to share


2 answers


you can try the built-in library ctypes

to bring the popup to the screen.

import ctypes 
ctypes.windll.user32.MessageBoxW(0, "Your text", "Your title", 1)

      

Hope it helps.



you can use the pythonw.exe

file instead python.exe

Try the link - I haven't tried this thing but hopes it helps you in the hidden window console.

you just need to change the python file extension from file.py

to file.pyw

and it won't be there. The Windows console will not appear.

+1


source


The solution provided by @Abhishake gupta is good, you can also open the module to open notepad with some text.



import os
f = open('foo.txt','w')
f.write('Hello world!')
f.close()
os.system("notepad.exe foo.txt")

      

+1


source







All Articles