Update Scan-it.py

This commit is contained in:
Gwyn 2026-02-16 16:38:45 -05:00
parent c53cc4bcb6
commit 24ff911c78

View file

@ -1,129 +1,126 @@
import PySimpleGUI as sg import PySimpleGUI as sg
import datetime import datetime
import barcode import barcode
import pyperclip import pyperclip
import keyboard import keyboard
from PIL import ImageGrab from PIL import ImageGrab
from pytesseract import pytesseract from pytesseract import pytesseract
# First the window layout in 2 columns # First the window layout in 2 columns
#You must remove Tesserect for PYinstaller rules = [[sg.Text("All scans copy output to clipboard:")]]
path_to_tesseract = r"C:\Users\30783009\AppData\Local\Programs\Tesseract-OCR\tesseract.exe" barker = [
[
rules = [[sg.Text("All scans copy output to clipboard:")]] sg.Text("Make Barcode:"),
barker = [ sg.In(size=(25, 10), enable_events=True, key="-mkbox-",),
[ sg.Button(button_text="Encode", enable_events=True, key="-GO-"),
sg.Text("Make Barcode:"), ],
sg.In(size=(25, 10), enable_events=True, key="-mkbox-",), ]
sg.Button(button_text="Encode", enable_events=True, key="-GO-"), newlot = [
], [
] sg.Text("Lot Pull:"),
newlot = [ sg.Input(size=(25, 10), enable_events=True, key="pull"),
[ sg.Button(button_text="Extract", enable_events=True, bind_return_key = True, key="noop"),
sg.Text("Lot Pull:"), ],
sg.Input(size=(25, 10), enable_events=True, key="pull"), ]
sg.Button(button_text="Extract", enable_events=True, bind_return_key = True, key="noop"), # ----- Full layout -----
], layout = [
] [sg.Column(rules, justification="Left")],
# ----- Full layout ----- [sg.Column(barker, justification="Right")],
layout = [ [sg.Column(newlot, justification="Right")],
[sg.Column(rules, justification="Left")], ]
[sg.Column(barker, justification="Right")],
[sg.Column(newlot, justification="Right")], window = sg.Window("Scanner Tool", layout)
] arrrg = "404barcodenotfound"
#Functionality
window = sg.Window("Scanner Tool", layout) def clippy(sluggers):
arrrg = "404barcodenotfound" pyperclip.copy(sluggers)
#Functionality pyperclip.paste()
def clippy(sluggers): def clippyB(mrpaperclip):
pyperclip.copy(sluggers) pyperclip.copy(mrpaperclip)
pyperclip.paste() pyperclip.paste()
def clippyB(mrpaperclip): keyboard.press_and_release("backspace")
pyperclip.copy(mrpaperclip) keyboard.press_and_release("backspace")
pyperclip.paste() def readpicture():
keyboard.press_and_release("backspace") try:
keyboard.press_and_release("backspace") foo = ImageGrab.grabclipboard()
def readpicture(): pytesseract.tesseract_cmd = path_to_tesseract
try: pitty = pytesseract.image_to_string(foo)
foo = ImageGrab.grabclipboard() foofighter = str(pitty)
pytesseract.tesseract_cmd = path_to_tesseract clippy(foofighter)
pitty = pytesseract.image_to_string(foo) print(foofighter)
foofighter = str(pitty) return foofighter
clippy(foofighter) except:
print(foofighter) print("I don't think you have a picture on your clipboard.\nTry using [windows]+[shift]+[s] to take a screen grab that I can read.\n -Best Regards, The AI")
return foofighter def Bark(): #I make barcodes
except: ean = barcode.get('code128', arrrg,)
print("I don't think you have a picture on your clipboard.\nTry using [windows]+[shift]+[s] to take a screen grab that I can read.\n -Best Regards, The AI") ean.save("Pybar")
def Bark(): #I make barcodes def longboifile(code): #I log what is done.
ean = barcode.get('code128', arrrg,) LOG = open("Loggy_Mclogface.log", "at")
ean.save("Pybar") LOG.write(str(code) + "||" + str(datetime.datetime.now()) + "\n")
def longboifile(code): #I log what is done. def newt():
LOG = open("Loggy_Mclogface.log", "at") lot = arrg.rsplit("|")
LOG.write(str(code) + "||" + str(datetime.datetime.now()) + "\n") #print(str(lot[0]))
def newt(): longboifile(lot[1])
lot = arrg.rsplit("|") print(str(lot[1]))
#print(str(lot[0])) clippy(str(lot[1]))
longboifile(lot[1]) def log():
print(str(lot[1])) maxleggy = len(arrg)
clippy(str(lot[1])) point1 = arrg[maxleggy-1]
def log(): point2 = arrg[maxleggy-2]
maxleggy = len(arrg) point3 = arrg[0]
point1 = arrg[maxleggy-1] point4 = arrg[1]
point2 = arrg[maxleggy-2] parse = arrg.strip(point1+point2+point3+point4)
point3 = arrg[0] print(parse)
point4 = arrg[1] longboifile(parse)
parse = arrg.strip(point1+point2+point3+point4) clippy(parse)
print(parse) def lep():
longboifile(parse) maxleggy = len(arrg)
clippy(parse) point1 = arrg[maxleggy-1]
def lep(): point2 = arrg[maxleggy-2]
maxleggy = len(arrg) parse = arrg.strip(arrg[0])
point1 = arrg[maxleggy-1] parses = arrg.strip("+H435")
point2 = arrg[maxleggy-2] fparse = parses.strip(point1+point2)
parse = arrg.strip(arrg[0]) print(fparse)
parses = arrg.strip("+H435") longboifile(fparse)
fparse = parses.strip(point1+point2) clippy(fparse)
print(fparse) def longcode(code):
longboifile(fparse) lenth = len(code)
clippy(fparse) print(code[26:lenth])
def longcode(code): clippy(code[26:lenth])
lenth = len(code) keyboard.add_hotkey(hotkey="h+f", callback=clippyB, args=["211698"])
print(code[26:lenth]) keyboard.add_hotkey(hotkey="t+g", callback=clippyB, args=["263611"])
clippy(code[26:lenth]) keyboard.add_hotkey(hotkey="ctrl+m+e", callback=clippyB, args=["230302"])
keyboard.add_hotkey(hotkey="h+f", callback=clippyB, args=["211698"]) keyboard.add_hotkey(hotkey="u+e", callback=clippyB, args=["259047"])
keyboard.add_hotkey(hotkey="t+g", callback=clippyB, args=["263611"]) keyboard.add_hotkey(hotkey="r+n", callback=clippyB, args=["228606"])
keyboard.add_hotkey(hotkey="ctrl+m+e", callback=clippyB, args=["230302"]) keyboard.add_hotkey(hotkey="f+d", callback=clippyB, args=["486513284"])
keyboard.add_hotkey(hotkey="u+e", callback=clippyB, args=["259047"]) keyboard.add_hotkey(hotkey="a+d", callback=clippyB, args=["46985 ENTERPRISE CT\nSTE A-100\nWIXOM MI, 48393"])
keyboard.add_hotkey(hotkey="r+n", callback=clippyB, args=["228606"]) while True:
keyboard.add_hotkey(hotkey="f+d", callback=clippyB, args=["486513284"]) event, values = window.read()
keyboard.add_hotkey(hotkey="a+d", callback=clippyB, args=["46985 ENTERPRISE CT\nSTE A-100\nWIXOM MI, 48393"]) if event == "Exit" or event == sg.WIN_CLOSED:
while True: break
event, values = window.read() if event == "-GO-":
if event == "Exit" or event == sg.WIN_CLOSED: arrrg = values["-mkbox-"]
break Bark()
if event == "-GO-": clippy(arrrg)
arrrg = values["-mkbox-"] longboifile(arrrg)
Bark() if event == "noop":
clippy(arrrg) arrg = values["pull"]
longboifile(arrrg) if "" == arrg:
if event == "noop": pass
arrg = values["pull"] elif "line" in arrg:
if "" == arrg: print("==========NEW=LINE=======================")
pass elif "yank" in arrg or "Yank" in arrg:
elif "line" in arrg: readpicture()
print("==========NEW=LINE=======================") elif "+H435" in arrg:
elif "yank" in arrg or "Yank" in arrg: lep()
readpicture() elif "010" in arrg[0:3]:
elif "+H435" in arrg: longcode(arrg)
lep() elif "|" in arrg:
elif "010" in arrg[0:3]: arrg = values["pull"]
longcode(arrg) newt()
elif "|" in arrg: longboifile(arrg)
arrg = values["pull"] else:
newt() log()
longboifile(arrg) element = window["pull"]
else: element.update("")
log()
element = window["pull"]
element.update("")
window.close() window.close()