initial commit
This commit is contained in:
commit
bd8d3a4041
114
babbageCup.py
Normal file
114
babbageCup.py
Normal file
@ -0,0 +1,114 @@
|
||||
import _winreg
|
||||
import win32api
|
||||
import win32print
|
||||
import time
|
||||
import datetime
|
||||
import os
|
||||
|
||||
blacklist = ["Fax","Microsoft Print to PDF","Microsoft XPS Document Writer"]
|
||||
|
||||
def printers():
|
||||
path = r'SYSTEM\CurrentControlSet\Control\Print\Printers'
|
||||
hKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, path)
|
||||
|
||||
subkeyCnt, valuesCnt, modtime = _winreg.QueryInfoKey(hKey)
|
||||
|
||||
for n in xrange(subkeyCnt):
|
||||
subName = _winreg.EnumKey(hKey, n)
|
||||
p2 = path + '\\' + subName
|
||||
hK2 = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, p2)
|
||||
|
||||
yield (_winreg.QueryValueEx(hK2, 'Name')[0],
|
||||
_winreg.QueryValueEx(hK2, 'Port')[0])
|
||||
|
||||
_winreg.CloseKey(hK2)
|
||||
|
||||
_winreg.CloseKey(hKey)
|
||||
|
||||
def getInputs():
|
||||
pages = int(raw_input(" [>] How many pages do you want to print? [0 = Infinite]> "))
|
||||
file_path = raw_input(" [>] Drag and Drop the file, you want to print and press enter...")
|
||||
while True:
|
||||
temp = raw_input(" [>] Launch [n]ow or at specified date and [t]ime?> ")
|
||||
if temp=="n":
|
||||
return pages,file_path,False
|
||||
elif temp=="t":
|
||||
return pages,file_path,True
|
||||
print(" Error: Please only enter 'n' or 't'")
|
||||
|
||||
def babbage(pages,file_path):
|
||||
os.system("cls")
|
||||
print("""
|
||||
,----,------------------------------,------.
|
||||
| ## | [BabbageCup] | - |
|
||||
| ## | | - |
|
||||
| |------------------------------| - |
|
||||
| ||............................|| |
|
||||
| ||,- -.|| |
|
||||
| ||___ ___|| ##|
|
||||
| ||---`--------------------'---|| |
|
||||
`----'|_|______________________==__|`------'\n""")
|
||||
if pages==0:
|
||||
pages = 1000000
|
||||
for page in range(pages):
|
||||
for p in printers():
|
||||
if p[0] not in blacklist:
|
||||
try:
|
||||
print(" [*] Printing page "+str(page)+" on printer '"+str(p[0])+"'")
|
||||
win32print.SetDefaultPrinter(p[0])
|
||||
win32api.ShellExecute(0, "print", "babbageCup.py", None, ".", 0)
|
||||
except Exception as e:
|
||||
print(" [!] Error: "+str(e[2])+"\n")
|
||||
time.sleep(0.5)
|
||||
|
||||
def waitInput():
|
||||
print("\n [+] Now {"+datetime.datetime.today().strftime('%H:%M %d.%m.%Y')+"}")
|
||||
t = datetime.datetime(int(raw_input(" [>] Year ["+str(datetime.datetime.today().year)+"]> ")),int(raw_input(" [>] Month ["+str(datetime.datetime.today().month)+"]> ")),int(raw_input(" [>] Day ["+str(datetime.datetime.today().day)+"]> ")),int(raw_input(" [>] Hour ["+str(datetime.datetime.today().hour)+"]> ")),int(raw_input(" [>] Minute ["+str(datetime.datetime.today().minute)+"]> ")),0)
|
||||
print(" [+] Launch {"+t.strftime('%H:%M %d.%m.%Y')+"}\n")
|
||||
now = datetime.datetime.today()
|
||||
print(" [*] Launching in T-"+str((t-now).seconds)+" seconds")
|
||||
time.sleep((t-now).seconds)
|
||||
|
||||
if __name__ == '__main__':
|
||||
os.system("cls")
|
||||
|
||||
for i in range(3):
|
||||
os.system("cls")
|
||||
print("""
|
||||
,----,------------------------------,------.
|
||||
| ## | [BabbageCup] | - |
|
||||
| ## | | - |
|
||||
| |------------------------------| - |
|
||||
| ||............................|| |
|
||||
| ||,- -.|| |
|
||||
| ||___ ~~~~~~~~~~~~~~~~~~~~ ___|| ##|
|
||||
| ||---`--------------------'---|| |
|
||||
`----'|_|______________________==__|`------'\n""")
|
||||
time.sleep(0.5)
|
||||
os.system("cls")
|
||||
print("""
|
||||
,----,------------------------------,------.
|
||||
| ## | [BabbageCup] | - |
|
||||
| ## | | - |
|
||||
| |------------------------------| - |
|
||||
| ||............................|| |
|
||||
| ||,- -.|| |
|
||||
| ||___ ___|| ##|
|
||||
| ||---`--------------------'---|| |
|
||||
`----'|_|______________________==__|`------'\n""")
|
||||
time.sleep(0.5)
|
||||
|
||||
print(" [*] Printers found:")
|
||||
for p in printers():
|
||||
if p[0] not in blacklist:
|
||||
print(" "+str(p[0]))
|
||||
print("")
|
||||
|
||||
time.sleep(0.2)
|
||||
|
||||
p,f,l = getInputs()
|
||||
if l:
|
||||
waitInput()
|
||||
else:
|
||||
raw_input("\n [#] Press >enter< to start")
|
||||
babbage(p,f)
|
Loading…
Reference in New Issue
Block a user