Page 1 of 1

wrong Script

Posted: 14 Apr 2023, 06:23
by Serquik

Code: Select all

key1 := "d"
key2 := "s"
key3 := "a"
key4 := "w"
interval := 30000

state := 1
toggleKey := "CapsLock"
SetTimer, ToggleKeys, %interval%
return

ToggleKeys:
    if GetKeyState(toggleKey) {
        if (state = 1) {
            SendInput, {%key1% Down}{%key2% Down}{LButton Down}
            Sleep, %interval%
            SendInput, {%key1% Up}{%key2% Up}{LButton Up}
            state := 2
        } else {
            SendInput, {%key3% Down}{%key4% Down}{LButton Down}
            Sleep, %interval%
            SendInput, {%key3% Up}{%key4% Up}{LButton Up}
            state := 1
        }
    }
    return
What's wrong with this code? It's supposed to hold down the W A S D keys at a certain interval with the left mouse button held down, but when I press Caps Lock, nothing happens.

Re: wrong Script

Posted: 14 Apr 2023, 10:03
by Xtra
For the toggle see help file for: GetKeyState --> read about the Mode parameter.

Your script shows nothing about using the left mouse button (LButton)