Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Do Loop, Sleep and Mouse Button
#3
Code: (Select All)
While -1
    Do
        While _MouseInput: Wend
        '...some code
        Locate 1, 1: Print "Hi, I'm in screen 1. Press 2 then any key for screen 2 or left click to exit."
        If InKey$ = "2" Then Cls: Exit Do
        If _MouseButton(1) Then Exit While
    Loop
    Sleep
    Do
        While _MouseInput: Wend
        '....some more code
        Locate 1, 1: Print "Hi, I'm in screen 2. Press 1 then any key for screen 1 or left click to exit."
        If InKey$ = "1" Then Cls: Exit Do
        If _MouseButton(1) Then Exit While
    Loop
    Sleep
Wend

Keep in mind with this structure you still need to press "any key" after pressing a 1 or 2 to switch screens, but when the prompt is visible, a left mouse click will exit the outer wend loop. Also note that if you press 1 and don't press "any key" the mouse is no longer enabled as coded. You are in a dead zone until "any key" is pressed as SLEEP doesn't poll the mouse.

Pete
Reply


Messages In This Thread
Do Loop, Sleep and Mouse Button - by Dimster - 09-05-2025, 06:19 PM
RE: Do Loop, Sleep and Mouse Button - by bplus - 09-05-2025, 09:10 PM
RE: Do Loop, Sleep and Mouse Button - by Pete - 09-05-2025, 11:03 PM
RE: Do Loop, Sleep and Mouse Button - by SMcNeill - 09-05-2025, 11:21 PM
RE: Do Loop, Sleep and Mouse Button - by Pete - 09-05-2025, 11:43 PM
RE: Do Loop, Sleep and Mouse Button - by Dimster - 09-06-2025, 12:57 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Setting mouse to ignore outside of _NewImage PhilOfPerth 11 712 12-18-2025, 07:20 PM
Last Post: Pete
  Exiting sub while inside a loop PhilOfPerth 5 507 12-05-2025, 09:40 AM
Last Post: PhilOfPerth
  Using modulo to loop through lists fistfullofnails 3 708 09-03-2025, 11:50 PM
Last Post: fistfullofnails
  Stopping repeated mouse-key press PhilOfPerth 8 851 09-02-2025, 11:28 PM
Last Post: Pete
  _MessageBox ignores default button johngreening 2 598 04-27-2025, 07:34 PM
Last Post: hsiangch_ong

Forum Jump:


Users browsing this thread: 1 Guest(s)