0

I am trying to use python to take in a string from a barcode scanner and use it to select a laser engraver file to execute. I am able to get the Max Marking (laser software) to open with the correct file, but am getting lost after that. I want to press "f2", which is the hotkey to run the laser, then wait on the "etching" prompt that the Max Marking software displays on the screen, then close Max Marking. I suppose I could test each of the engravings for their respective lengths of time and just use time.sleep(SomeAmountOfTime), but would like to make closing the program literally contingent on the engraving finishing. Is there a way to make python wait on the "currently etching" prompt that displays while the laser is running? This is within the Max Marking application and not a windows prompt. Here is what I have so far...

def notepad():
    os.startfile('....filepath....')
    time.sleep(2)
    pyautogui.press('f2')
    #Where I need to wait on etching prompt
    os.system('taskkill /f /im maxmarking.exe')

1 Answers1

0

A very simple solution could be _ = input("press ENTER when etching is finished"), it is not automatic but reliable.

If you want something completely automatic, it will be much more difficult. To detect that the prompt in another process has been displayed, either it provides an API to do that (which I doubt) or it will be very hacky (see the whole topic of "window automation", for exemple this question).

If having to return to the Python executing script is bothersome, you could use a hotkey to message it, see for example this question.

Lenormju
  • 4,078
  • 2
  • 8
  • 22