DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Successfully added F1-F12 as fast Move Keys!  (Read 16,604 times)

Expletive

  • Participant
  • Joined in 2013
  • *
  • Posts: 7
Successfully added F1-F12 as fast Move Keys!
« on: February 25, 2013, 05:29 AM »
I've got it working! To do it, open command.ahk and replace the original code with my code:

Code
;Original Code
DefineHotkeys:
  loop,9
  {
     Hotkey, %FastMoveModifiers%%A_Index%, WinHotkeys
     Hotkey, %FastMoveModifiers%Numpad%A_Index%, WinHotkeys
  }
  Hotkey, %FastMoveModifiers%0, WinHotKey
  Hotkey, %FastMoveModifiers%Numpad0, WinHotkeys
  if FastMoveMeta <>
    Hotkey, %FastMoveModifiers%%FastMoveMeta%, WinHotkeysMeta
  return 

WinHotkeys:
  StringRight,Number,A_ThisHotkey,1
  MoveToGrid(Number)
  return

Code
;My Code
;FastMove Works with F1-F12 as grids 11-22 by Expletive
DefineHotkeys:

NewHotKeys := {1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,sc0b:10,F1:11,F2:12:F3:13:F4:14:F5:15,F6:16,F7:17,F8:18,F9:19,F10:20,F11:21,F12:22,Numpad0:10,Numpad1:1,Numpad2:2,Numpad3:3,Numpad4:4,Numpad5:5,Numpad6:6,Numpad7:7,Numpad8:8,Numpad9:9}
For key, value in NewHotKeys {
        if key
	hotkey, %FastMoveMeta%%key%, WinHotKeys
}
 if FastMoveMeta <>
    Hotkey, %FastMoveModifiers%%FastMoveMeta%, WinHotkeysMeta
return

WinHotkeys:  
  StringReplace, KeyPressed, A_ThisHotKey, %FastMoveMeta%
  Number := NewHotKeys[KeyPressed] 
  MoveToGrid(Number)
  return  

Edit: Ive noticed a couple of bugs:
1.) This code runs fine when run as .ahk but when compiling it, there's an error when it starts, probably because of the 0 key in newhotkeys, but I don't know why it'd only fail on compile.

Fixed:
2.) Pressing shift+3 seems to cause the window to shrink to nothing. I have no clue what's causing this. It doesn't seem to be related to %FastMoveMeta% since even when I change the meta to ^ for ctrl and restart it keeps doing it.

Edit 2:

So I fixed Error 2, and now there isn't an error message about '' not being a valid key, however it still only seems to work when ran as a script. After compiling, there is no error, but fast move has no modifer meta , and when grids are selected with the #g command, grids above 9 can't be selected.

I have no idea why there would be differences between a script and a compiled script. If anyone here has experience with autohotkey, I'd appreciate some help. But for anyone using gridmove as a .ahk, the above code should work fine for you.
« Last Edit: February 28, 2013, 12:25 PM by Expletive »

jgpaiva

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: Trying to make fast move accept F1-F12 isn't working
« Reply #1 on: February 25, 2013, 09:27 AM »
I see a few problems:
From what I understand, AHK doesn't support the "for each" loop you're using.
Also, you're defining a subroutine inside the loop, which I don't think can be done either (rubroutines can only be declared at topmost level?). Also, I don't think you can define a subroutine using the name of a variable (but I may be wrong).
If you want to use the keys only up to F9, this should work:

Code
DefineHotkeys:
  loop,9
  {
     Hotkey, F%A_Index%, WinHotkeys
  }
  if FastMoveMeta <>
    Hotkey, %FastMoveModifiers%%FastMoveMeta%, WinHotkeysMeta
  return 

WinHotkeys:
  StringRight,Number,A_ThisHotkey,1
  MoveToGrid(Number)
  return

To make this work for the remaining keys, you'd have to make the loop go up to 22, and change the code for parsing the number, which currently only takes the last character in the hotkey to figure out the grid. (I'm referring to this line:)
Code
  StringRight,Number,A_ThisHotkey,1

Expletive

  • Participant
  • Joined in 2013
  • *
  • Posts: 7
Re: Successfully added F1-F12 as fast Move Keys!
« Reply #2 on: February 26, 2013, 10:00 AM »
Updated original post

Original address: https://www.donationcoder.com/forum/index.php?topic=34141.0