Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • September 01, 2015, 03:19:16 PM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: IDEA: remap extra keyboard keys for other tasks  (Read 3462 times)

noth(a)nk.you

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 78
  • More than meets the eye.
    • View Profile
    • Donate to Member
IDEA: remap extra keyboard keys for other tasks
« on: March 22, 2006, 01:33:50 PM »
This is probably a quick thing to do in AHK, but I have not yet learned all the necessary commands so I'd really enjoy some help.  On to the task!

I own a MS Natural Ergonomic 4000 keyboard (stolen picture, click to zoom):
http://www.virtual-hideout.net/reviews/microsoft_4000_kb/image26.jpg
IDEA: remap extra keyboard keys for other tasks


The bundled software does not allow many changes, so I was thinking that I could use AHK to alter the functionality of a few things.  In particular, the zoom slider (in the middle) and the back/forward keys (at the bottom).

Firstly, the slider.  From AHK's Key History view (which is only showing the key strokes), I believe it works by sending Ctrl+Scroll wheel up/down every ~.1s or so.  Since zoom is not very useful to me, I'd prefer this combination be mapped to just the scroll wheel up/down.  Is this doable?

Secondly, the back/fwd keys.  My mouse is already equipped with such buttons so the keyboard is redundant.  Instead, I'd like these keys to map to left/right mouse buttons (a throwback to my lappy).  Again with AHK, I see these keys are mapped to Alt+Left/Right in the following way: Alt d, Left d, Left u, Alt u--but all sequenced without delay.  The problem I'm running in to with coding is translating this to the analogous mousing.  That is, I'd like to be able to hold down the back/fwd keys and drag files/folders.  Is this doable?
 
(This is more useful than it sounds.)
I've found that the mouse can be moved around more freely when the fingers are loose, so using the alternate hand to control the buttons makes repetitive mousing a breeze.  E.g. big file operations, simple Flash games, AutoCAD, etc.


I should also like to note that my mouse uses RightAlt+L/R, so there shouldn't be a conflict there if the script just recognizes LeftAlt. 
Thanks for reading, any help you can provide would be most appreciated.

Cheers,
noth(a)nk.you

P.S. Thanks for tolerating my playing with the spoiler tag!
« Last Edit: March 22, 2006, 02:26:00 PM by brotherS »

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: IDEA: remap extra keyboard keys for other tasks
« Reply #1 on: March 22, 2006, 04:51:57 PM »
EhEh.. So much text for such a small solution!

Code: [Select]
^WheelDown::WheelDown
^WheelUp::WheelUp

<!Left::Lbutton
<!Right::RButton
Does that solve it? ;)

noth(a)nk.you

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 78
  • More than meets the eye.
    • View Profile
    • Donate to Member
Re: IDEA: remap extra keyboard keys for other tasks
« Reply #2 on: March 22, 2006, 06:36:14 PM »
Thanks a lot for your help, jgpaiva--it's close.

The scrolling wasn't working.  Ctrl was still down when AHK executed the Wheel commands, so (if anybody's interested) I changed it to
Code: [Select]
^WheelDown::Send {^Up}{WheelDown}
^WheelUp::Send {^Up}{WheelUp}
Now it works pretty well, reverting back to the default behavior only when trying to scroll past the limits of the page (perhaps some timing issue?)

On the L/Rbuttons, though, I'm running into more trouble.

When pressing those keys in programs without "Back" support (e.g. Notepad and AHK), AHK reports:
Code: [Select]
A4  038 d 1.30 Alt
25  14B h d 0.00 Left
01  000 i d 0.00 LButton
25  14B h u 0.00 Left
01  000 i u 0.00 LButton
A4  038 u 0.00 Alt
and it works beautifully.

But in those programs with back support (e.g. Firefox and Explorer), AHK reports:
Code: [Select]
01  000 d 4.68 LButton
01  000 u 0.10 LButton
and the programs respond as though they were given the Back or Forward commands.

I'm thinking that the Back/Fwd commands might have some deeper hook into the OS?

Any thoughts?

Thanks,
noth(a)nk.you

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: IDEA: remap extra keyboard keys for other tasks
« Reply #3 on: March 22, 2006, 06:49:44 PM »
Hum.. Then. it's harder than i thought.
How about the following, to replace the back/forward?

Code: [Select]
Browser_Back::Lbutton
Browser_Forward::RButton

noth(a)nk.you

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 78
  • More than meets the eye.
    • View Profile
    • Donate to Member
Re: IDEA: remap extra keyboard keys for other tasks
« Reply #4 on: March 22, 2006, 06:55:05 PM »
No, still getting just the LButton.
Interestingly, I get LButton for both the Back and Forward buttons.  Is that of some significance?

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: IDEA: remap extra keyboard keys for other tasks
« Reply #5 on: March 22, 2006, 07:03:58 PM »
That's very odd...
Please try the following:

Quit any running ahk script.
Open the following script:
Code: [Select]
#Persistent
#KeyHistory
Then, press one of the keys.
Copy the full line, and post it here.

I think that keyboard works in a strange way (well.. it's microsoft's, is there any other way to expect it to work? ;) ).
Still, if it sends always one only key, there might be a way to remap it.

noth(a)nk.you

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 78
  • More than meets the eye.
    • View Profile
    • Donate to Member
Re: IDEA: remap extra keyboard keys for other tasks
« Reply #6 on: April 05, 2006, 05:49:43 AM »
Just gave it another try.

Through MS's software, I mapped the keys to something I wouldn't use (Media Track Fwd/Back), then opened up AHK again.  I found them coming through under SC169 and SC16A (fwd and back, respectively).  Then the [simple!] .ahk script
Code: [Select]
SC16A::LButton
SC169::RButton
fixed it!

I think that the Back and Fwd commands were deep in the system, so AHK couldn't intercept them.  Changing MS' software to execute a shallower command then allowed AHK to do its magic.

Incidently, from the AHK page, it sounds like they would advocate completely uninstalling Microsoft's software and just using their's to execute all the required commands using these SC codes.  Not a half-bad idea, actually.  Maybe I'll do that some lazy morning.

Thanks for your assistance!
noth(a)nk.you

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: IDEA: remap extra keyboard keys for other tasks
« Reply #7 on: April 05, 2006, 08:17:49 AM »
Incidently, from the AHK page, it sounds like they would advocate completely uninstalling Microsoft's software and just using their's to execute all the required commands using these SC codes.  Not a half-bad idea, actually.  Maybe I'll do that some lazy morning.

Thanks for your assistance!
noth(a)nk.you
Yes, that might be the best way. I also don't have my mouse's software installed. However, that might make some of the keys not be possible to remap, as happens with one of my mouse buttons. On the other hand, i don't think that happens with keyboards since they have the scan code method, that is not usable with mouse keys. So, probably, the best way would be to just uninstall that software :D