Stopping the script on the start button

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
TallSmaN
Posts: 16
Joined: 22 Nov 2022, 14:08

Stopping the script on the start button

Post by TallSmaN » 25 Nov 2022, 11:31

Code: Select all

!7::
addChatMessage("123")
Loop
{
SendChat("/rr " text1 "")
sleep, %kd1%
SendChat("/rr " text2 "")
sleep, %kd1%
SendChat("/rr " text3 "")
sleep, %kd1%
}
if !GetKeyState(!7)
return

Hello, I want the script to stop on the start button, but for some reason it does not work

User avatar
mikeyww
Posts: 26877
Joined: 09 Sep 2014, 18:38

Re: Stopping the script on the start button

Post by mikeyww » 25 Nov 2022, 11:48

I would pick a different hotkey.

Code: Select all

F3::
addChatMessage("123")
While GetKeyState("F3", "P")
{
 SendChat("/rr " text1)
 Sleep, kd1
 SendChat("/rr " text2)
 Sleep, kd1
 SendChat("/rr " text3)
 Sleep, kd1
}
Return

TallSmaN
Posts: 16
Joined: 22 Nov 2022, 14:08

Re: Stopping the script on the start button

Post by TallSmaN » 25 Nov 2022, 13:52

mikeyww wrote:
25 Nov 2022, 11:48
I would pick a different hotkey.

Code: Select all

F3::
addChatMessage("123")
While GetKeyState("F3", "P")
{
 SendChat("/rr " text1)
 Sleep, kd1
 SendChat("/rr " text2)
 Sleep, kd1
 SendChat("/rr " text3)
 Sleep, kd1
}
Return

Code: Select all

!1::
While GetKeyState("!1", "P")
{
 SendInput, G
 Sleep, 1000
 SendInput, F
 Sleep, 1000
 SendInput, H
 Sleep, 1000
}
Return
1. How can I set it to work on e.g. 1!
2. For some reason there is no loop, just writes GFH and stops (

User avatar
mikeyww
Posts: 26877
Joined: 09 Sep 2014, 18:38

Re: Stopping the script on the start button

Post by mikeyww » 25 Nov 2022, 17:43

GetKeyState checks the state of one key, explained in the documentation.
This can be just about any single character from the keyboard or one of the key names from the key list.

Code: Select all

wait = 1000

!1::
on := True
SendMode Input
While on
{
 Send g
 Sleep, wait * on
 If on
  Send f
 Sleep, wait * on
 If on
  Send h
 Sleep, wait * on
}
#If on
*1 Up::on := False
*1::Return
#If

Post Reply

Return to “Ask for Help (v1)”