Python Forum
Need help with infinite loop & making hotkeys/shortcuts
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help with infinite loop & making hotkeys/shortcuts
#1
Before you ask, yes i'm new, i started coding like today, and no i have no idea what i'm doing.

I want to be able to run my code on an infinite loop, and be able to toggle it on/off using key combos (leftalt + M specifically) but whatever solution i've found on youtube is either ancient, not what i'm looking for or straight up doesn't work.

import time
import random
import pyautogui

pyautogui.moveTo(1560, 970, duration=random.uniform(0.1,0.14))
pyautogui.mouseDown(button='left', duration=(5))
time.sleep(5)
pyautogui.mouseUp(button='left')
pyautogui.mouseDown(button='left')
pyautogui.moveTo(1060, 500, duration=random.uniform(0.08,0.16))
pyautogui.moveTo(1170, 500, duration=random.uniform(0.08,0.16))
pyautogui.moveTo(1280, 500, duration=random.uniform(0.08,0.16))
pyautogui.mouseUp(button='left')
this is the code that i want to run on an infinite loop with a key combination toggle.
Reply
#2
Have you looked at pynput for doing the hotkeys?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Keyboard hotkeys purushothama2222 4 1,626 Mar-14-2024, 07:57 PM
Last Post: suppliedorange
Shocked Why this code does not go into an infinite loop? 2367409125 2 836 Dec-02-2022, 08:22 PM
Last Post: deanhystad
  Creating Shortcuts with python Oshadha 2 1,769 Jun-23-2022, 08:07 AM
Last Post: Oshadha
  Infinite loop problem Zirconyl 5 2,923 Nov-16-2020, 09:06 AM
Last Post: DeaD_EyE
  using 'while loop' output going into infinite loop... amitkb 2 1,910 Oct-05-2020, 09:18 PM
Last Post: micseydel
  Infinite loop not working pmp2 2 1,609 Aug-18-2020, 12:27 PM
Last Post: deanhystad
  Why is this code not an infinite loop? psi2kgcm 1 1,802 Dec-24-2019, 02:04 PM
Last Post: buran
  Appending to list not working and causing a infinite loop eiger23 8 3,942 Oct-10-2019, 03:41 PM
Last Post: eiger23
  Server infinite loop input from user tomislav91 1 4,170 May-23-2019, 02:18 PM
Last Post: heiner55
  IDLE keyboard shortcuts tam 2 2,817 May-15-2019, 06:34 AM
Last Post: tam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020