Author Topic: how to write windows key AHK script?  (Read 4981 times)

0 Members and 1 Guest are viewing this topic.

Offline MANISH7

  • Thread Starter
  • Posts: 155
how to write windows key AHK script?
« on: Fri, 05 March 2010, 18:40:14 »
forgive me for my lack of knowledge on this matter but i don't know how to write AHK scripts. it is so complicated for a seemingly modest request.  

i just want the (1) right alt to be windows key and (2) right control to be right mouse click (3) pause break mutes the volume (4) left control + down arrow lowers volume (5) right control + up arrow increases the volume.

i tried some sample scripts listed at the AKK website but i didn't know how to customize it. i have a cherry mx11800 & windows 7. i did a search prior to this thread. everyone recommended AHK but writing scripts is another matter. can someone please help me?

Offline Rajagra

  • Posts: 1930
how to write windows key AHK script?
« Reply #1 on: Fri, 05 March 2010, 19:18:51 »
Try
Code: [Select]
;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT
; Author:         A.N.Other <myemail@nowhere.com>
;
; Script Function:
; Template script (you can customize this template by editing &quot;ShellNew\Template.ahk&quot; in your Windows folder)
;

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.


RAlt::LWin
RCtrl::Rbutton

Pause::
  Send {Volume_Mute}
  SoundGet, master_mute, , mute
  if(master_mute = &quot;on&quot;)
  {
  Tooltip, Mute On
  }else
  {
  Tooltip, Mute Off
  }
  SetTimer, RemoveToolTip, 2000
return

LCtrl & Down::
  SoundSet -5
  SoundGet, master_volume
  voltip := Round(master_volume)
  Tooltip, Vol: %voltip%`%
  SetTimer, RemoveToolTip, 2000
return

RCtrl & Up::
  SoundSet +5
  SoundGet, master_volume
  voltip := Round(master_volume)
  Tooltip, Vol: %voltip%`%
  SetTimer, RemoveToolTip, 2000
return

RemoveToolTip:
  SetTimer, RemoveToolTip, Off
  ToolTip
return

You can learn a lot from the built-in help even though it can be confusing at first (right click the green H in the system tray while you have any AHK script running and choose help.)
I copied all the volume code from someone else's script though. :smile:
« Last Edit: Fri, 05 March 2010, 19:22:24 by Rajagra »

Offline MANISH7

  • Thread Starter
  • Posts: 155
how to write windows key AHK script?
« Reply #2 on: Fri, 05 March 2010, 19:43:48 »
very kind of you and i appreciate it.

 control + up or down arrow work to change volume but only after i click on the volume bar.

EDIT: sorry for the mix up. the rest work great thanks for your kind help! volume up and down isn't a big deal.
« Last Edit: Fri, 05 March 2010, 19:55:09 by MANISH7 »

Offline MANISH7

  • Thread Starter
  • Posts: 155
how to write windows key AHK script?
« Reply #3 on: Fri, 05 March 2010, 19:54:07 »
i apologize! windows key works, right mouse click works, pause button for mute works too! sorry i didn't set it up right the first time! thanks a lot!

Offline MANISH7

  • Thread Starter
  • Posts: 155
how to write windows key AHK script?
« Reply #4 on: Fri, 05 March 2010, 21:07:34 »
well everything seems to work fine. i think ahk is a little buggy on windows 7 for now. the left control + down arrow lowers the volume. left control + up arrow will not increase the volume. however, right control + up arrow will increase the volume. right control + down arrow does not lower the volume. so i mix and match and it works.

i will back up this script for future uses.

thanks so much for your help. i'm all set. i really appreciate it.

Offline Rajagra

  • Posts: 1930
how to write windows key AHK script?
« Reply #5 on: Fri, 05 March 2010, 22:40:12 »
Maybe I read your original post too literally. You can change the places where it says LCtrl or RCtrl to simply Ctrl where you want either control key to work.

Like this:

Code: [Select]
;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT
; Author:         A.N.Other <myemail@nowhere.com>
;
; Script Function:
; Template script (you can customize this template by editing &quot;ShellNew\Template.ahk&quot; in your Windows folder)
;

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.


RAlt::LWin
RCtrl::Rbutton

Pause::
  Send {Volume_Mute}
  SoundGet, master_mute, , mute
  if(master_mute = &quot;on&quot;)
  {
  Tooltip, Mute On
  }else
  {
  Tooltip, Mute Off
  }
  SetTimer, RemoveToolTip, 2000
return

Ctrl & Down::
  SoundSet -5
  SoundGet, master_volume
  voltip := Round(master_volume)
  Tooltip, Vol: %voltip%`%
  SetTimer, RemoveToolTip, 2000
return

Ctrl & Up::
  SoundSet +5
  SoundGet, master_volume
  voltip := Round(master_volume)
  Tooltip, Vol: %voltip%`%
  SetTimer, RemoveToolTip, 2000
return

RemoveToolTip:
  SetTimer, RemoveToolTip, Off
  ToolTip
return

Offline MANISH7

  • Thread Starter
  • Posts: 155
how to write windows key AHK script?
« Reply #6 on: Sat, 06 March 2010, 08:37:47 »
hey thanks so much. sorry about that - i did not realize that i had miswritten my original post. i made the corrections you suggested and everything is now working flawlessly! i'm glad you took my post literally - that is how i always mean them. i just made a typo. yesterday i had a long day :)

thanks to your mod there's nothing more i could want from my cherry keyboard. it's excellent. it's got the windows keys & media buttons that i needed. i really appreciate it! you've resolved for me everything.
« Last Edit: Sat, 06 March 2010, 08:53:25 by MANISH7 »