用AutoHotkey重置Excel的Ctrl+Alt+方向键选择的范围
当前选择是蓝色单元格,原来的Ctrl+Alt+方向键,是选中【蓝色】到【红色】单元格的区域,
经过脚本修改后,则是【蓝色】到【黄色】的区域,应该更符合日常使用,
特别是表格比较大的时候,一直按住鼠标滚动选择单元格太累人了,还不能出错。
下面附上代码:
<^+Up:: <^+Down:: <^+Left:: <^+Right:: xl := ComObjActive("Excel.Application") RegExMatch(xl.Selection.CurrentRegion.Address, "\$(\w+)\$(\d+):\$(\w+)\$(\d+)", m) ;m1-m4分别是A1:F7(假设)里的A,1,F,7 rowStart := m2 rowEnd := m4 colStart := m1 colEnd := m3 addressSelect := xl.Selection.Address RegExMatch(addressSelect, "\$(\w+)\$(\d+)", m) ;m1,m2分别为选中单元格C3(假设)的C和3 rowSelect := m2 colSelect := m1 If InStr(A_ThisHotkey, "Up") xl.ActiveSheet.Range(colSelect . rowStart . ":" . addressSelect).Select Else If InStr(A_ThisHotkey, "Down") xl.ActiveSheet.Range(addressSelect . ":" . colSelect . rowEnd).Select Else If InStr(A_ThisHotkey, "Left") xl.ActiveSheet.Range(colStart . rowSelect . ":" . addressSelect).Select Else If InStr(A_ThisHotkey, "Right") xl.ActiveSheet.Range(addressSelect . ":" . colEnd . rowSelect).Select Return