rebind error Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
zed6250jb
Posts: 54
Joined: 20 Apr 2024, 18:25
Contact:

rebind error

20 Apr 2024, 19:20

Code: Select all

#Requires AutoHotkey v2.0


$left::
            While GetKeyState("left","p"){ ; While it is held down
            left,
            Sleep 100
}      
return
image.png
(9.2 KiB) Downloaded 118 times
User avatar
mikeyww
Posts: 27205
Joined: 09 Sep 2014, 18:38

Re: rebind error

20 Apr 2024, 21:26

Welcome to this AutoHotkey forum!

You cannot actually make up your own syntax in AHK.

Would start here: Using the program

The error message is telling you exactly what the problem is with the script.

You might also want to call the :arrow: Send function.

Code: Select all

#Requires AutoHotkey v2.0

$Left:: {
 While GetKeyState('Left', 'P') {
  Send '{Left}'
  Sleep 100
 }
}
zed6250jb
Posts: 54
Joined: 20 Apr 2024, 18:25
Contact:

Re: rebind error

21 Apr 2024, 14:35

Thanks, sorry about syntax, didn't realize the format was so specific. I'm actually wanting to make the arrow keys move the cursor around in windows, but it appears to not work and I don't know why... I'm using this method in conjunction with an ir remote and a usb dongle that Flirc sells. I am able to program 84 keys on the keyboard to the remote, but obviously not the arrow keys since the lack of 104 keys in the software configurator... Here is what I have so far, and suffice to say, I'm not even able to remap the numpad arrows to the regular arrow keys, let alone get the universal ir remote working with this part. Any thoughts on the below code snippet?

Code: Select all

#Requires AutoHotkey v2.0

$Left:: {
 While GetKeyState('Left', 'P') {
  Send '{NumbpadLeft}'
  Sleep 100
 }
}
$Right:: {
 While GetKeyState('Right', 'P') {
  Send '{NumbpadRight}'
  Sleep 100
 }
}
$Up:: {
 While GetKeyState('Up', 'P') {
  Send '{NumbpadUp}'
  Sleep 100
 }
}
$Down:: {
 While GetKeyState('Down', 'P') {
  Send '{NumbpadDown}'
  Sleep 100
 }
}

[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]
User avatar
boiler
Posts: 17228
Joined: 21 Dec 2014, 02:44

Re: rebind error

21 Apr 2024, 15:46

zed6250jb wrote: I'm not even able to remap the numpad arrows to the regular arrow keys, let alone get the universal ir remote working with this part. Any thoughts on the below code snippet?
It’s Numpad…, not Numbpad….

Please use [code][/code] tags when posting code on the forum.
zed6250jb
Posts: 54
Joined: 20 Apr 2024, 18:25
Contact:

Re: rebind error

22 Apr 2024, 10:36

Thank you for reminding me and your patience. I fixed the typo and still get the same results (no action), even when running as admin.

Code: Select all

#Requires AutoHotkey v2.0

$Left:: {
 While GetKeyState('Left', 'P') {
  Send '{NumpadLeft}'
  Sleep 100
 }
}
$Right:: {
 While GetKeyState('Right', 'P') {
  Send '{NumpadRight}'
  Sleep 100
 }
}
$Up:: {
 While GetKeyState('Up', 'P') {
  Send '{NumpadUp}'
  Sleep 100
 }
}
$Down:: {
 While GetKeyState('Down', 'P') {
  Send '{NumpadDown}'
  Sleep 100
 }
}
User avatar
mikeyww
Posts: 27205
Joined: 09 Sep 2014, 18:38

Re: rebind error

22 Apr 2024, 11:12

I tried one of your hotkeys here (without your other program, of course), and it worked.

My approach to troubleshooting this would be to test a shorter and simpler script to understand how your program is using and responding to hotkeys. The following script might show whether you can trigger and send anything, but I think that you will need to experiment further. There is also no guarantee that you will get it working, but some programs that use other hotkeys do allow AHK to trigger them.

Code: Select all

#Requires AutoHotkey v2.0
Left::MsgBox 1
b::Send '{NumpadLeft}'
c::Send '{Left}'
If you are doing this in Notepad on Win 11, you will want to use SendEvent instead of SendInput.
zed6250jb
Posts: 54
Joined: 20 Apr 2024, 18:25
Contact:

Re: rebind error  Topic is solved

22 Apr 2024, 11:29

Thanks for the input (nopunintended) mikey. I decieded to just bypass the windows mouse keys and tell ahk to do the action directly with favorable results. Not that it needs it's own repo, here it is, and the code it self.

Code: Select all

#Requires AutoHotkey v2.0
;Python code snippet to simulate arrow key presses using AutoHotkey syntax
;Define hotkeys for arrow keys
$up:: {
    While GetKeyState('up', 'P') {
        MouseMove 0, -10, 100, "R"
        Sleep 5
    }
}
$down:: {
    While GetKeyState('down', 'P') {
        MouseMove 0, 10, 100, "R"
        Sleep 5
    }
}
$left:: {
    While GetKeyState('left', 'P') {
        MouseMove -10, 0, 100, "R"
        Sleep 5
    }
}

$right:: {
    While GetKeyState('right', 'P') {
        MouseMove 10, 0, 100, "R"
        Sleep 5
    }
}
return

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: bugeshan, just me, teadrinker, trpldss and 31 guests