Help trying to make this work, stopping key spam after conditions are met.

Get help with using AutoHotkey and its commands and hotkeys
ahk nooblie
Posts: 6
Joined: 19 Jan 2020, 00:49

Help trying to make this work, stopping key spam after conditions are met.

02 Feb 2020, 00:06

Hello, new to AHK here, need help trying to figure out how to make my script do what's needed.

What I need it to do is:

Press key if mouse cursor passes a barrier coord (x > 960) but only once! then if the cursor moves to (x < 960) I need it to repeat the loop (separate macro making that happen), I have no control over the exact time I want it to to repeat this so it's pretty much triggers? I also fail at stopping key spam once ( x > 960) without putting a return.

Code: Select all

#MaxThreadsPerHotKey 3
#NoEnv


F3::
Loop
{
MouseGetPos, X, Y
if (x > 960)
Send {``}
Sleep, 1000
}
return
aifritz
Posts: 259
Joined: 29 Jul 2018, 11:30
Location: Germany

Re: Help trying to make this work, stopping key spam after conditions are met.

02 Feb 2020, 02:34

In this way?

Code: Select all


F3::
z := false
Loop
{
  MouseGetPos, X, Y
  if (x > 960 And !z)
    {
      Send {``}
      z := true
    }
  Else if (x<=960)
     z := false
  Sleep, 1000
}
return
ahk nooblie
Posts: 6
Joined: 19 Jan 2020, 00:49

Re: Help trying to make this work, stopping key spam after conditions are met.

02 Feb 2020, 04:04

Sorry but it still sends spams of tilde if the cursor stays past the trigger, slowly though.
aifritz
Posts: 259
Joined: 29 Jul 2018, 11:30
Location: Germany

Re: Help trying to make this work, stopping key spam after conditions are met.

02 Feb 2020, 05:22

seams so as I don't understand, what you exactly want. Perhaps a tooltip helps to see, what the status is.
The Sleep 1000 command means also, that you had to hold the mouse for min. 1 sec. to a position <= 960 to set the var z to false again.

Code: Select all

F3::
z := false
Loop
{
  MouseGetPos, X, Y
  tooltip x:%x% z:%z%
  if (x > 960 And !z)
    {
      Send {``}
      z := true
    }
  Else if (x<=960)
     z := false
  Sleep, 1000
}
return

Return to “Ask For Help”

Who is online

Users browsing this forum: 0xDEADC0DE, audante, Bing [Bot], FanaticGuru and 52 guests