R
R
Rafael Agishev2021-05-27 20:48:58
PyQt
Rafael Agishev, 2021-05-27 20:48:58

What to do if the application crashes while using a certain piece of python code?

Hello. Created a python autoclicker program using pyqt5. But as soon as the clicker starts, the application stops working (as if the clicker itself works, i.e. when the button is pressed, it stops, but the application does not open)
60afda928c26e372881057.png
Also, if the time delay value is greater than 0.1, the clicker does not stop, even when the stop button is pressed

Code snippet that performs the function:

def function(self):
        self.start_button.clicked.connect(self.auto_clicker)

    def auto_clicker(self):
        start = self.startkey.text().lower()
        stop = self.stopkey.text().lower()
        time_delay = float(self.time_delay.text())

        while True:
            if keyboard.is_pressed(start):
                mouse.is_pressed(button = self.comboBox.currentText())
                while True:
                    time.sleep(time_delay)
                    mouse.double_click(button=self.comboBox.currentText())
                    if keyboard.is_pressed(stop):
                        break


|EXPLANATION|
self.startkey - lineedit where the value is taken from (keyboard button)
self.stopkey - the same
self.time_delay - the same
self.combobox - combo box where the value is taken from (which button will be pressed during the clicker)

Please help, please!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mrisid, 2021-05-27
@kematin

The interface of your program itself works in a loop, so if you try to run any loop, your program will freeze.
To avoid this, use the Threading module , it will allow you to launch separate threads responsible for certain functions in your program.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question