geekhack

geekhack Community => Keyboards => Topic started by: Zet on Fri, 13 May 2011, 12:35:04

Title: AutoHotKey: Share your Scripts!
Post by: Zet on Fri, 13 May 2011, 12:35:04
Hi there guys,

I don't know if there's already a section or a thread about this, but I wanted to start this so we share our tweaks with AutoHotKey and other Scripts.

First off, for those who don't know; AutoHotKey is a program that allows you to achieve multiple things with your keyboard and mouse. You can do things like remapping keys to more advanced or complex ones like making macros, lunching aplications, setting up key combinations for media controls, etc.

After I found this option/solution, it didn't no longer matter for me if a keyboard had media keys, keys to lunch applications and lately I don't care that much about the layout (since I speak spanish, I used to use 105 key layout with the big enter key).

A couple of days ago I got amazed while reading the tutorials of the program and what you can do with it, so fellow GeekHackers that already use AutoHotKeys, what scripts do you have?

Feel free to share them here!

Regards,
Zet

PS: right now, I only have altgr+, to"<" and altgr+. to ">" which both symbols I can't normally do if I use a 104 US layout keyboard config~ as a 105 keyboard, since those are the symbols I can't get because of the missing key.
Title: AutoHotKey: Share your Scripts!
Post by: Dox on Fri, 13 May 2011, 12:57:39
Scroll your mouse wheel over your windows taskbar and change your volume!

Code: [Select]
#If MouseIsOver(&quot;ahk_class Shell_TrayWnd&quot;)
WheelUp::Send {Volume_Up}
WheelDown::Send {Volume_Down}

MouseIsOver(WinTitle)
{
    MouseGetPos,,, Win
    return WinExist(WinTitle . &quot; ahk_id &quot; . Win)
}
Title: AutoHotKey: Share your Scripts!
Post by: alaricljs on Fri, 13 May 2011, 13:13:09
Because that's 3 characters and the use of {} is for sending 1 key/character.

Code: [Select]
#F7::
{
Send &#3232;_&#3232;
}
return
Title: AutoHotKey: Share your Scripts!
Post by: Dox on Fri, 13 May 2011, 13:13:29
Quote from: ripster;345802
OK AutoHotkey whizzes - why can't I get this one to work?
Code: [Select]

#F7::
{
SendInput {&#3232;_&#3232;}
}
return


Current AHK build.  Works with other unicodes.

ಠ_ಠ

 
This one works fine with me.
Code: [Select]
F6::send ಠ_ಠ
ಠ_ಠ
You just can't make it in notepad as it doesn't support those ಠ characters.

I've done it in VS2010.
Title: AutoHotKey: Share your Scripts!
Post by: elef on Fri, 13 May 2011, 15:40:15
Quote from: Dox;345798
Scroll your mouse wheel over your windows taskbar and change your volume!

Code: [Select]
#If MouseIsOver(&quot;ahk_class Shell_TrayWnd&quot;)
WheelUp::Send {Volume_Up}
WheelDown::Send {Volume_Down}

MouseIsOver(WinTitle)
{
    MouseGetPos,,, Win
    return WinExist(WinTitle . &quot; ahk_id &quot; . Win)
}

That's impressive and useful, thanks!
Title: AutoHotKey: Share your Scripts!
Post by: alaricljs on Fri, 13 May 2011, 15:47:41
Well, since Win-L is lock, I set shift-Win-L to logout:
Code: [Select]
#+L::
  Shutdown 0
return

Inhibit CapsLock, but Win-Caps is lock if I need it, also have CapsLock as a modifier for a bunch of other keys
Code: [Select]
CapsLock::
*+CapsLock::
*!CapsLock::
*^CapsLock::

return

#CapsLock::
  getkeystate,caps,capslock,t
  if caps = D
    setcapslockstate,off
  else
    setcapslockstate,on
  return
return

Sleep button (Win-Pause):
Code: [Select]
#Pause::
  DllCall("PowrProf\SetSuspendState", "int", 0, "int", 0, "int", 0)
return


Also have a hack of a script available from the AHK forums that does volume on my mouse wheel (with Win-key) with an OSD.
Title: AutoHotKey: Share your Scripts!
Post by: Dox on Fri, 13 May 2011, 16:37:12
Quote from: ripster;345884
It's like the Windows key is "stuck" without a break.  H won't type until I hit the Windows key (took a while to figure this one out - thought Webwit gave me a virus).
I had this problem too I think it depends on your release order of the keys.
Something I've done that seem to help is to add "send {RWin Up} | send {LWin Up}" at the end of your script.
Title: AutoHotKey: Share your Scripts!
Post by: kpeezy on Fri, 13 May 2011, 16:56:43
Quote from: Dox;345798
Scroll your mouse wheel over your windows taskbar and change your volume!

Code: [Select]
#If MouseIsOver(&quot;ahk_class Shell_TrayWnd&quot;)
WheelUp::Send {Volume_Up}
WheelDown::Send {Volume_Down}

MouseIsOver(WinTitle)
{
    MouseGetPos,,, Win
    return WinExist(WinTitle . &quot; ahk_id &quot; . Win)
}

We should post the OS we're using. I tested this on a VM and confirmed it only works in Windows XP. Doesn't work in W7. I really like this script though.
Title: AutoHotKey: Share your Scripts!
Post by: alaricljs on Fri, 13 May 2011, 16:59:09
Quote from: ripster;345884

This one gives me an odd behaviour.  
Code: [Select]
;Win+F6 to send RipOmeter url
#F6::Send [url=http://geekhack.org/showwiki.php?title=Island:6189]RipOmeter[/h]
return

It's like the Windows key is "stuck" without a break.  H won't type until I hit the Windows key (took a while to figure this one out - thought Webwit gave me a virus).


That is strange, my arrow keys get stuck, but all my alpha keys work.  What's even weirder is what fixed it:

Code: [Select]
#F6::
Send [url=http://geekhack.org/showwiki.php
Send ?title=Island:6189]RipOmeter[/h]
return
Title: AutoHotKey: Share your Scripts!
Post by: alaricljs on Fri, 13 May 2011, 17:00:47
Quote from: kpeezy;345899
We should post the OS we're using. I tested this on a VM and confirmed it only works in Windows XP. Doesn't work in W7. I really like this script though.

Win7 Volume control is very complicated.  When I get some time I'll post the stripped down script, but it involves downloading a library or 2 depending on which version of AHK you're using.
Title: AutoHotKey: Share your Scripts!
Post by: Brodie337 on Fri, 13 May 2011, 17:25:17
I dont have issues with volume control. Here's mine:
Code: [Select]
+Pause::Send {Media_Next}
return

+PrintScreen::Send {Media_Prev}
return

+ScrollLock::Send {Media_Play_Pause}
return

!WheelDown::Send {Volume_Down}

!WheelUp::Send {Volume_Up}

!Mbutton::Send {Volume_Mute}

^!LControl::Suspend ;Some games need capslock

capslock::Lcontrol

!+WheelDown::Send {Media_Next}
return

!+WheelUp::Send {Media_Prev}
return

!+Mbutton::Send {Media_Play_Pause}
return


I've got two extra buttons on my G700 mouse set to Alt and Alt + Shift.

EDIT: This is on Windows 7, 64 bit.
Title: AutoHotKey: Share your Scripts!
Post by: Dox on Fri, 13 May 2011, 18:12:50
Quote from: kpeezy;345899
We should post the OS we're using. I tested this on a VM and confirmed it only works in Windows XP. Doesn't work in W7. I really like this script though.

I'm running this script on Win 7 Ultimate x64 and XP x86 and it works fine on both machine.
Title: AutoHotKey: Share your Scripts!
Post by: Ich on Fri, 13 May 2011, 18:43:25
Quote from: ripster;345884

This one gives me an odd behaviour.  
Code: [Select]

;Win+F6 to send RipOmeter url
#F6::Send [url=http://geekhack.org/showwiki.php?title=Island:6189]RipOmeter[/h]
return


It's like the Windows key is "stuck" without a break.  H won't type until I hit the Windows key (took a while to figure this one out - thought Webwit gave me a virus).


I don't have issues with this (Win XP).
But the Windows key isn't the best modifier key.
("Win (Windows logo key). In v1.0.48.01+, for Windows Vista and later, hotkeys that include the Windows key (e.g. #a) will wait for the Windows key to be released before sending any text containing an "L" keystroke. This prevents the Send within such a hotkey from locking the PC. This behavior applies to all sending modes except SendPlay (which doesn't need it) and blind mode.")

I would use the clipboard for such long things:

Code: [Select]
#F6::
 Clipboard = [url=http://geekhack.org/showwiki.php?title=Island:6189]RipOmeter[/h]
 Send ^v
return
Title: AutoHotKey: Share your Scripts!
Post by: alaricljs on Fri, 13 May 2011, 19:47:36
Quote from: Ich;345934
I would use the clipboard for such long things:

Code: [Select]
#F6::
 Clipboard = [url=http://geekhack.org/showwiki.php?title=Island:6189]RipOmeter[/h]
 Send ^v
return

Extra points if you save the previous clipboard contents and put them back when you're done.
Title: AutoHotKey: Share your Scripts!
Post by: kpeezy on Fri, 13 May 2011, 19:53:23
Quote from: Dox;345925
I'm running this script on Win 7 Ultimate x64 and XP x86 and it works fine on both machine.

Hmm, it works on my W7 box at home but not at work. The image at work doesn't have anything unusual so I'm not sure what's going on. Thanks.

edit: my work machine isn't 64 bit so maybe that is the issue.
Title: AutoHotKey: Share your Scripts!
Post by: daerid on Fri, 13 May 2011, 19:55:25
AHK rocks. Right now I'm only using it for launching specific programs with Win+Alt combinations.
Title: AutoHotKey: Share your Scripts!
Post by: Ich on Sat, 14 May 2011, 00:35:09
Quote from: alaricljs;345944
Extra points if you save the previous clipboard contents and put them back when you're done.


Yes, this could be done too (if someone needs this):
Code: [Select]
#F6::
 ClipSaved := ClipboardAll
 Clipboard = [url=http://geekhack.org/showwiki.php?title=Island:6189]RipOmeter[/h]
 Send ^v
 Clipboard := ClipSaved
 ClipSaved =
return
Title: AutoHotKey: Share your Scripts!
Post by: daerid on Sat, 14 May 2011, 01:40:17
From what I can tell, that would allow you to automatically paste in the RipOMeter URL without thrashing your current clipboard.

Although, it seems a fairly roundabout way of doing that considering you can just have AHK send the keystrokes directly.
Title: AutoHotKey: Share your Scripts!
Post by: daerid on Sat, 14 May 2011, 01:48:11
Ok, I see why it was done that way.... using Send/SendRaw is WAAAAY slower.
Title: AutoHotKey: Share your Scripts!
Post by: niz on Sat, 14 May 2011, 02:36:39
Have always found this one quite useful...and simple!
Code: [Select]
PRINTSCREEN::
Run C:\Windows\Sysnative\SnippingTool.exe
return

**w/ Win7
Title: AutoHotKey: Share your Scripts!
Post by: daerid on Sat, 14 May 2011, 03:18:35
Quote from: niz;346057
Have always found this one quite useful...and simple!
Code: [Select]
PRINTSCREEN::
Run C:\Windows\Sysnative\SnippingTool.exe
return

**w/ Win7

Okay, that's just damned awesome
Title: AutoHotKey: Share your Scripts!
Post by: sinani206 on Sat, 14 May 2011, 09:56:46
I made AltGr+G to ㅈ because I play StarCraft II and I'm super gosu cool.
gg -> ㅈㅈ ftw
Title: AutoHotKey: Share your Scripts!
Post by: NimbleRabit on Sat, 14 May 2011, 11:07:14
I'm using this script (http://www.autohotkey.com/forum/topic49219.html) for volume in windows 7, I love having the little display.

Thanks for the printscreen -> SnippingTool idea, that's pretty slick.
Title: AutoHotKey: Share your Scripts!
Post by: alaricljs on Sat, 14 May 2011, 11:49:39
Quote from: NimbleRabit;346164
I'm using this script (http://www.autohotkey.com/forum/topic49219.html) for volume in windows 7, I love having the little display.

Thanks for the printscreen -> SnippingTool idea, that's pretty slick.

That's the volume script I'm using modified to the Win+mousewheel and win+0/-/=  (mute/down/up)

Snippingtool... lived so long with printscreen/ctrl-printscreen and irfanview that I never knew that existed.  Think I still like the irfanview route better.
Title: AutoHotKey: Share your Scripts!
Post by: Zet on Sat, 14 May 2011, 23:18:58
Quote from: daerid;345949
AHK rocks. Right now I'm only using it for launching specific programs with Win+Alt combinations.

Well between all the uses for autohotkey, to be honest, the less useful is that IMO, since you can already config win7 to do something similar.

You can achieve this in two ways.
Have them on your taskbar, so that way, win+#  depending on their position on the taskbar will determine their number.
Have an icon on your desktop, right click it, properties and configure the short key combination there, but this ones If I'm not wrong only will work for ctrl+alt+# where # can be a letter, symbol or number. That way you don't have to get a script running.


=====

Also, can someone please share the scripts code to have a key combo set for the "stop" loading on the web browsers? I don't know which one that would be...
Title: AutoHotKey: Share your Scripts!
Post by: Bear715 on Thu, 19 May 2011, 12:43:43
Do any of you have a good numpad replacement setup for a tenkeyless?  I realize that I do miss it sometimes.
I tried using
#i::Numpad7
#o::Numpad8
#p::Numpad9
#k::Numpad4
#l::Numpad5
#;::Numpad6
#,::Numpad1
#.::Numpad2
#/::Numpad3

but windows key and L will try to lock the computer and doesnt seem to want to override.  I am not in love with this replacement layout, either, so Im open to suggestions. Complete noob in autohotkey btw
Title: AutoHotKey: Share your Scripts!
Post by: alaricljs on Thu, 19 May 2011, 13:45:46
If you don't use the stock windows Win-key hotkeys (M is minimize all, D is desktop, L is lock, R is Run... and so on) then you can disable them...  google for it cuz I'm working and lazy at the same time.

Once they are disabled in windows AHK will work with those combos.
Title: AutoHotKey: Share your Scripts!
Post by: Zet on Thu, 19 May 2011, 14:15:25
another option you have is to use a different modifier than the windows key :) try shift+alt, ctrl+alt, altgr....
Title: AutoHotKey: Share your Scripts!
Post by: NimbleRabit on Thu, 19 May 2011, 14:20:33
I think if you use the SEND command it works better with the windows keybinds, at least I've had that experience.

Like:

#l::SEND {Numpad5}

Give it a shot and see if that works.  I don't know why but that has fixed problems for me before.
Title: AutoHotKey: Share your Scripts!
Post by: Bear715 on Thu, 19 May 2011, 14:48:16
Quote from: harrison;348573
I'm working on mashing a few scripts that create a new 'tenlock' function, which results in flashing both the scroll and caps LEDs when it's enabled.

I eagerly await your script.  Sounds interesting
I combined help from nimble and zet to make something work for now.  I don't know if ill like it or if somethign better will come up but it works for my purposes for now.  Thanks nimble and zet =)

^!i::SEND {Numpad7}
^!o::SEND {Numpad8}
^!p::SEND {Numpad9}
^!k::SEND {Numpad4}
^!l::SEND {Numpad5}
^!;::SEND {Numpad6}
^!,::SEND {Numpad1}
^!.::SEND {Numpad2}
^!/::SEND {Numpad3}
^!space::SEND {Numpad0}
Title: AutoHotKey: Share your Scripts!
Post by: Zet on Thu, 19 May 2011, 14:57:59
No problem bro, I'm glad that I was of help.
By the way, this lead me to think how this would work if the "keypad" keys were to be set on a different place than regular, i.e. 123, qwe, asd, zxc also it's interesting to have the option to have specific mods for the scripts, since I tend to use only the left side alt, ctrl, shift, perhaps using the right ones would be a improve to avoid errors...
Title: AutoHotKey: Share your Scripts!
Post by: litster on Thu, 19 May 2011, 15:55:36
Quote from: alaricljs;345876
Also have a hack of a script available from the AHK forums that does volume on my mouse wheel (with Win-key) with an OSD.

 
alaricljs, where can I find your mouse wheel volume script with OSD?  Thanks.
Title: AutoHotKey: Share your Scripts!
Post by: alaricljs on Thu, 19 May 2011, 18:02:04
Quote from: NimbleRabit;346164
I'm using this script (http://www.autohotkey.com/forum/topic49219.html) for volume in windows 7, I love having the little display.
Quote from: alaricljs;346182
That's the volume script I'm using modified to the Win+mousewheel and win+0/-/=  (mute/down/up)
Quote from: litster;348676
alaricljs, where can I find your mouse wheel volume script with OSD?  Thanks.

Ok, so that link above is to the original source at AHK, it requires this library (http://www.autohotkey.com/forum/topic23792.html).  And here's my hacked up version that includes win-mousewheel and some other mods.  Note also the Win-o/p/[/]/\ media controls.

Code: [Select]
#NoEnv
#SingleInstance force
SendMode Input

;SetFormat, float, 0.0
;SetBatchLines 10ms
SetBatchLines -1
SetTitleMatchMode 2
DetectHiddenWindows On
CoordMode Mouse, Screen

;COM_Init()
vol_Master := VA_GetMasterVolume()

; The percentage by which to raise or lower the volume each time
vol_Step = 3
; How long to display the volume level bar graphs (in milliseconds)
vol_DisplayTime = 1000
; Transparency of window (0-255)
vol_TransValue = 255
; Transparent background (1/0/true/false) (takes precedence over Window trans,
;   can have only 1 or other, not both)
vol_TransBack = 0
; Bar's background colour
vol_CW = Black  
vol_Width = 200  ; width of bar
vol_Thick = 20   ; thickness of bar
; Bar's screen position
;vol_PosX := A_ScreenWidth - vol_Width - 50
;vol_PosY := A_ScreenHeight - vol_Thick - 100
vol_PosX := 250
vol_PosY := A_ScreenHeight - vol_Thick - 100
; --------------------
; END OF CONFIGURATION
; --------------------
vol_BarOptionsMaster = 1:B ZH%vol_Thick% ZX8 ZY4 W%vol_Width% X%vol_PosX% Y%vol_PosY% CW%vol_CW%
vol_MuteChange = 0
return


;------------ End if initialization section ----------------

;Exit


$Volume_Down::
#WheelDown::
#-::
  If vol_Master > .01
    VA_SetMasterVolume(vol_Master-=vol_Step)
  Gosub, vol_ShowBars

return

$Volume_Up::
#WheelUp::
#=::
  If vol_Master <= 99
    VA_SetMasterVolume(vol_Master+=vol_Step)
  Gosub, vol_ShowBars

return

Volume_Mute::
#MButton::
#0::
  If ( VA_GetMasterMute() ) {
    VA_SetMasterMute(False)
    vol_MuteChange = 1
  } Else {
    VA_SetMasterMute(True)
    vol_MuteChange = 1
  }
  Gosub, vol_ShowBars

return


#o::
  Send {Media_Stop}
return

#p::
  Send {Media_Play_Pause}
return

#[::
  Send {Media_Prev}
return

#]::
  Send {Media_Next}
return


;  Start Winamp or Open Music Folder
;  Player Window
;  M:\

#\::
Launch_Media::
  IfWinExist Player Window
    IfWinExist M:\
      IfWinActive M:\
        WinClose
      else
        WinActivate
    else
      Run M:\
  else
    Run C:\Program Files (x86)\Winamp\winamp.exe

return

;------------------- Start Volume display ------------------------
vol_ShowBars:
; Get volumes in case the user or an external program changed them:
vol_Master := VA_GetMasterVolume()
vol_Mute := VA_GetMasterMute()
if (vol_Mute)
{
  vol_Colour = Red    
  vol_Text = Volume (muted)
}
else
{
  vol_Colour = Green  
  vol_Text = Volume
}
; To prevent the &quot;flashing&quot; effect, only create the bar window if it doesn't already exist:
NED := 0
IfWinNotExist, VolumeOSDxyz
  NED := 1
If (vol_MuteChange or NED)
{
    Progress, %vol_BarOptionsMaster% CB%vol_Colour% CT%vol_Colour%, , %vol_Text%, VolumeOSDxyz
    WinSet, Transparent, %vol_TransValue%, VolumeOSDxyz
    if (vol_TransBack)
      WinSet, TransColor, %vol_CW%, VolumeOSDxyz

  vol_MuteChange = 0
}
Progress, 1:%vol_Master%, , %vol_Text%
SetTimer, vol_BarOff, %vol_DisplayTime%
return


vol_BarOff:
SetTimer, vol_BarOff, off
Progress, 1:Off
return

;-------------------- End Volume display -------------------------

Title: AutoHotKey: Share your Scripts!
Post by: Zet on Thu, 19 May 2011, 18:13:08
alaricljs I'm loving that idea, I'll use it I think, if somehow I can't get it to work, I'll contact you.
Thanks for the input on this!!!
Title: AutoHotKey: Share your Scripts!
Post by: litster on Thu, 19 May 2011, 18:57:34
Thanks for the script.  It wouldn't run until also copied and pasted VA.ahk into the same script file.  But it works now.  Now I really want the Topre 87U with the right Windows key because sometimes I use my left hand for mouse.  Yes, I switch mouse left and right to share wrist pain across both hands.

Thanks!
Title: AutoHotKey: Share your Scripts!
Post by: litster on Sun, 22 May 2011, 23:15:06
I figured it out.  The VA.ahk needs to go to C:\Program Files (x86)\AutoHotkey\Lib.  Thanks.
Title: AutoHotKey: Share your Scripts!
Post by: Zet on Sun, 22 May 2011, 23:43:42
Woah it took me long to get it to work, what really helped me was adding the VA code into the script that was posted. Then I left it on my desktop and ran it flawlessly :D

Also, I upgraded to AHK_L and added /lib folder with VA21 and COM_L libs, just for the record.

I'm really liking this scripts and stuff, I'll really look more into it, I love programing :)

An idea just came up to my head, for a script to block my keyboard and avoid in another way, people using it to unlock my session at work (other programers, really childish ones willing to bother); lets say you want to go lunch and you fear someone saw or knows your password... so they could unlock the session and get on your desktop...
but you could remap all your keys to, lets say 'a' and have the script terminate itself or remaps again properly only when a certain key combination is pressed down ;)

I don't know, there's so many other scripts that could be handy depending situations... ^_^
Title: AutoHotKey: Share your Scripts!
Post by: Zet on Wed, 01 June 2011, 23:12:50
Quote from: alaricljs;348717
Ok, so that link above is to the original source at AHK, it requires this library (http://www.autohotkey.com/forum/topic23792.html).  And here's my hacked up version that includes win-mousewheel and some other mods.  Note also the Win-o/p/[/]/\ media controls.

Code: [Select]

#NoEnv
#SingleInstance force
SendMode Input

;SetFormat, float, 0.0
;SetBatchLines 10ms
SetBatchLines -1
SetTitleMatchMode 2
DetectHiddenWindows On
CoordMode Mouse, Screen

;COM_Init()
vol_Master := VA_GetMasterVolume()

; The percentage by which to raise or lower the volume each time
vol_Step = 3
; How long to display the volume level bar graphs (in milliseconds)
vol_DisplayTime = 1000
; Transparency of window (0-255)
vol_TransValue = 255
; Transparent background (1/0/true/false) (takes precedence over Window trans,
;   can have only 1 or other, not both)
vol_TransBack = 0
; Bar's background colour
vol_CW = Black  
vol_Width = 200  ; width of bar
vol_Thick = 20   ; thickness of bar
; Bar's screen position
;vol_PosX := A_ScreenWidth - vol_Width - 50
;vol_PosY := A_ScreenHeight - vol_Thick - 100
vol_PosX := 250
vol_PosY := A_ScreenHeight - vol_Thick - 100
; --------------------
; END OF CONFIGURATION
; --------------------
vol_BarOptionsMaster = 1:B ZH%vol_Thick% ZX8 ZY4 W%vol_Width% X%vol_PosX% Y%vol_PosY% CW%vol_CW%
vol_MuteChange = 0
return


;------------ End if initialization section ----------------

;Exit


$Volume_Down::
#WheelDown::
#-::
  If vol_Master > .01
    VA_SetMasterVolume(vol_Master-=vol_Step)
  Gosub, vol_ShowBars

return

$Volume_Up::
#WheelUp::
#=::
  If vol_Master <= 99
    VA_SetMasterVolume(vol_Master+=vol_Step)
  Gosub, vol_ShowBars

return

Volume_Mute::
#MButton::
#0::
  If ( VA_GetMasterMute() ) {
    VA_SetMasterMute(False)
    vol_MuteChange = 1
  } Else {
    VA_SetMasterMute(True)
    vol_MuteChange = 1
  }
  Gosub, vol_ShowBars

return


#o::
  Send {Media_Stop}
return

#p::
  Send {Media_Play_Pause}
return

#[::
  Send {Media_Prev}
return

#]::
  Send {Media_Next}
return


;  Start Winamp or Open Music Folder
;  Player Window
;  M:\

#\::
Launch_Media::
  IfWinExist Player Window
    IfWinExist M:\
      IfWinActive M:\
        WinClose
      else
        WinActivate
    else
      Run M:\
  else
    Run C:\Program Files (x86)\Winamp\winamp.exe

return

;------------------- Start Volume display ------------------------
vol_ShowBars:
; Get volumes in case the user or an external program changed them:
vol_Master := VA_GetMasterVolume()
vol_Mute := VA_GetMasterMute()
if (vol_Mute)
{
  vol_Colour = Red    
  vol_Text = Volume (muted)
}
else
{
  vol_Colour = Green  
  vol_Text = Volume
}
; To prevent the &quot;flashing&quot; effect, only create the bar window if it doesn't already exist:
NED := 0
IfWinNotExist, VolumeOSDxyz
  NED := 1
If (vol_MuteChange or NED)
{
    Progress, %vol_BarOptionsMaster% CB%vol_Colour% CT%vol_Colour%, , %vol_Text%, VolumeOSDxyz
    WinSet, Transparent, %vol_TransValue%, VolumeOSDxyz
    if (vol_TransBack)
      WinSet, TransColor, %vol_CW%, VolumeOSDxyz

  vol_MuteChange = 0
}
Progress, 1:%vol_Master%, , %vol_Text%
SetTimer, vol_BarOff, %vol_DisplayTime%
return


vol_BarOff:
SetTimer, vol_BarOff, off
Progress, 1:Off
return

;-------------------- End Volume display -------------------------


 

Hey bro, I can't get the win=o,p,[,] to work, could this be due to the fact that I use vlc as media player? also I mod~ the address of winamp on the script to the one where the vlc is, for the win+\, but it's also not required for me since I have vlc on my taskbar and I usually win+number it, but would the script do, if I have a partition set to M: it would open it, instead of opening vlc, right? and I suppose that M:\ is where my music folder would be?

Thanks in advance for your help!
Title: AutoHotKey: Share your Scripts!
Post by: alaricljs on Thu, 02 June 2011, 12:05:42
I don't recall if it's required to disable the default Win7 win-key combos.  I disabled them quite a while before coming up with this media key layout.  Other than that you have to make sure that whatever media player you are using knows to latch onto the standard media key events.  Never used VLC.

Yes, the 'Launch_Media' is setup to start winamp (you'll have to dig the window details for VLC with Window Spy) if it's not running and to handle the Media Folder if it is running.  My M: drive is a mapping of my server's music storage.  You can change M: to anything you want really, it just needs to be what is in the window title.
Title: AutoHotKey: Share your Scripts!
Post by: Zet on Thu, 02 June 2011, 15:12:52
Yes, thanks, I got it to lunch VLC instead winamp, which I don't use. Will now try to have it working for my music directory.
By the way I recommend you try VLC, is really good. The only thing I don't like that much is the library management it's easier with other programs.

I'll continue my journeys into the AutoHotKey forums, since I'm really into getting some nice scripts for my keyboard, if I find something awesome, I'll come to share it with you guys here.
Title: AutoHotKey: Share your Scripts!
Post by: alaricljs on Thu, 02 June 2011, 15:39:29
All my audio management is via the organization of my folders (artist\albums\tracks).  Winamp is just the pretty display and the transport.  I run it window shaded and tuck it down at the bottom, there's a pic in the 'desktop clutter' thread...

Here (http://geekhack.org/showthread.php?10667-How-cluttered-is-your-desktop&p=350680&viewfull=1#post350680) we go.
Title: AutoHotKey: Share your Scripts!
Post by: looserboy on Thu, 02 June 2011, 16:05:37
very informative thread, thank you guys for this one, rly, now i could make { and } on my capslock :D
{ = only press capslock and alt gr + capslock = }

never heard about autohotkey^^ so i am very happy right now :)
Title: AutoHotKey: Share your Scripts!
Post by: Zet on Thu, 02 June 2011, 16:09:05
I'm glad this was of help. Perhaps I'll add this to the wiki, make a list of the scripts and such, for others to have a look, and try them in a easy way. We could even upload the compiled versions of the scripts for others to download and use, that way easy.

eh? how do that sounds now?
Title: AutoHotKey: Share your Scripts!
Post by: litster on Thu, 02 June 2011, 16:49:51
That would be awesome!
Title: AutoHotKey: Share your Scripts!
Post by: Tony on Fri, 03 June 2011, 09:32:51
I experienced that AHK keyboard scripts won't work if you type fast enough, around 50 wpm.
Title: AutoHotKey: Share your Scripts!
Post by: daerid on Fri, 03 June 2011, 10:33:10
Quote from: Tony;355173
I experienced that AHK keyboard scripts won't work if you type fast enough, around 50 wpm.

Never had a problem with it, and I type regularly at around 80-90wpm
Title: AutoHotKey: Share your Scripts!
Post by: Collective on Sun, 05 June 2011, 01:50:15
my script #include(s) chord.ahk, located at http://www.autohotkey.com/forum/topic44399.html
I have it set so that LMB + XButton1 results in sending Alt Space M arrow right, grabbing the window and moving it without needing to hold down a mouse button, and so that LMB + XButton2 results in alt+space , S, down right, which results in grabbing the bottom right corner for resizing without holding down a button.
Title: AutoHotKey: Share your Scripts!
Post by: Zet on Thu, 05 January 2012, 11:33:04
Hey everyone,

I was enjoying the good life with the volume script that alaricljs posted earlier. I didn't want to update iTunes, but I had to format my computer. So I reinstalled Windows 7, on a new disk I have, and when tried to make the script work... BAM, the forward and backwards song, the win+p for play functions no longer work!

So I thought it was due the fact I installed the wrong version of AHK, or skipped adding the libs VA and COM to the AHK installation place. But I still can't manage to make it work :(

Can someone advice on this?

Thanks!
Title: AutoHotKey: Share your Scripts!
Post by: alaricljs on Thu, 05 January 2012, 13:09:03
You mention that you are using iTunes however your earlier post says you got it working with VLC.  So did you later get it working with iTunes prior to this re-install?

The thing to remember about this AHK script and forward/back/play/pause is that all the script does is send a different key press to the OS.  You have to make sure that the OS and/or your media software know that they are what needs to interpret the 'Media Keys', in Winamp this is done with 'Global Hotkeys'.  Just google Media Keys and your software of choice and you should get what you're looking for.
Title: AutoHotKey: Share your Scripts!
Post by: Zet on Sat, 07 January 2012, 09:02:04
Yes, later on, I stopped using VLC and started using iTunes, as far as I remember, I had installed the last version and was working OK, then re-installed Windows-7 64bits, I took my script(compiled) and the only part working was the volume up, down, mute, and win+\ to open winamp

I'm thinking I did something wrong, when I installed AHK, perhaps the wrong AHK, not _L, maybe I have the wrong libraries installed on a wrong place, or something...

I would really really appreciate if you guide me through this, since I love the script so much I never felt the urge of getting a keyboard with media keys due this.

Thanks in advance alaricljs!
Title: AutoHotKey: Share your Scripts!
Post by: alaricljs on Sat, 07 January 2012, 17:40:07
For the functions you are saying do not work, all that is happening with the script is that it is taking your key press combination  and translating it to the related media key press that could be found on any keyboard claiming to have media keys.  It is up to iTunes to tell the OS that when media keys are pressed they should be forwarded on to iTunes.  I've never used iTunes so I have zero familiarity with it.  With Winamp it's a specific setting inside the Global Hotkeys screen.  On Windows XP there was a Control Panel that allowed you to fiddle with that stuff as well.  I have not found the same control panel in Win7.
Title: AutoHotKey: Share your Scripts!
Post by: 1uckyNumb3r7 on Sun, 22 January 2012, 23:30:36
I have a question for the AHK vets on here....

I am running this line in a script because I am using a Model M and want to have a Windows key for some volume and media function scripts that need that key.

Code: [Select]
RControl::LWin

The key works like it is supposed to, so if I hit RControl+Up then the volume goes up.

My problem is that when I release the RControl after hitting Up then the start menu pops up and I have to hit RControl again in order to make it go away. Is there a way to make it act like a normal LWin key and not pop up on the release of RControl?
Title: AutoHotKey: Share your Scripts!
Post by: slueth on Sun, 22 January 2012, 23:34:37
i think you can get the windows key by hitting the shift and cntrl or some combo like that.
Title: AutoHotKey: Share your Scripts!
Post by: 1uckyNumb3r7 on Sun, 22 January 2012, 23:59:25
Quote from: slueth;496578
i think you can get the windows key by hitting the shift and cntrl or some combo like that.


You might be thinking of Ctrl + Esc? It will bring up the start menu but that is it.

If I were to hit Ctrl+Esc+Up it wouldn't behave the same as Win+Up

Edit: I forgot to mention that if I plug in my other keyboard and try the Win+Up combo the volume goes up and the start menu doesn't pop up.

Edit 2: I found a solution, but it does not involve the use of AutoHotKey unfortunately. http://www.jonlee.ca/remap-capslock-the-most-useless-key/ (http://www.jonlee.ca/remap-capslock-the-most-useless-key/)

Quote
How to remap Caps Lock to another key
For Linux users (on an X environment like KDE, Gnome), it’s pretty easy to remap keys using the xmodmap command.

For Windows users, there are programs that will remap keys for you but if you’re not afraid to tinker with your registry, you can do this manually and it only requires adding one registry value:

    Go to Start->Run and type in ‘regedit’ to open the registry editor.
    Navigate to:

        HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout
        Note: Keyboard Layout, not Keyboard Layouts!

    Go to Edit->New->Binary Value and name it ‘Scancode Map’
    Now double-click and edit the value to the following, replacing ## ## with the scan code of the key you wish to map caps lock to.

        00 00 00 00 00 00 00 00 02 00 00 00 ## ## 3a 00 00 00 00 00

    The scan code for Windows Key is 5B E0, Esc is 01 00, Ctrl is 1D 00. Full list of scan codes and a more detailed tutorial is here.
    Reboot your computer and say goodbye to caps lock!
Title: AutoHotKey: Share your Scripts!
Post by: Hamblet on Mon, 23 January 2012, 00:30:20
Quote from: 1uckyNumb3r7;496577
...My problem is that when I release the RControl after hitting Up then the start menu pops up and I have to hit RControl again in order to make it go away. Is there a way to make it act like a normal LWin key and not pop up on the release of RControl?


Try this code, It works fine with me (I am AHK_Basic and Vista 32)
Hotkey:: Sendplay {LWin}{Up}
Title: AutoHotKey: Share your Scripts!
Post by: Shogunner on Tue, 24 January 2012, 21:32:30
Man.. respect you guys.

I've been trying to do a script that does what I want for the past few hours and it's been nothing but frustration. I just ended up using my Belkin n52te to control my media player. :P
Title: AutoHotKey: Share your Scripts!
Post by: guilleguillaume on Thu, 26 January 2012, 16:22:15
I ended up using Ripster's code from the first page since mine was causing some problems, very useful.


Quote
; Caps Lock becomes Ctrl, Win+LShift becomes Caps Lock
CapsLock::Ctrl
#Lshift::Capslock

Anyone knows how can I learn wich keycode send each key of the keyboard? I want to remap 5 of the Japanese keys I have left that right now don't have any use.
Title: AutoHotKey: Share your Scripts!
Post by: alaricljs on Thu, 26 January 2012, 16:25:28
PassMark KeyboardTest (http://www.passmark.com/products/keytest.htm) might be able to pull it off.
Title: AutoHotKey: Share your Scripts!
Post by: pyro on Thu, 26 January 2012, 16:36:22
Right click on the Autohotkey icon in the notification area
click Open
an Autohotkey window will open, click 'view' >> 'key history and script info' in the menu bar
press any series of keys and then hit F5
Title: AutoHotKey: Share your Scripts!
Post by: no_mates on Sat, 18 February 2012, 18:26:11
Can some someone please help I need to map the side button (#7) on my CM Spawn to the shift key for BF3.  There appears to be a bug with the Spawn where some modifier keys don't work even though the software say's they're mapped?
Title: AutoHotKey: Share your Scripts!
Post by: shogrran on Sun, 19 February 2012, 09:43:04
EDIT: Comment removed. I get it now thankee!
Title: Re: AutoHotKey: Share your Scripts!
Post by: BiNiaRiS on Sat, 29 June 2013, 04:28:10
Scroll your mouse wheel over your windows taskbar and change your volume!

Code: [Select]
#If MouseIsOver(&quot;ahk_class Shell_TrayWnd&quot;)
WheelUp::Send {Volume_Up}
WheelDown::Send {Volume_Down}

MouseIsOver(WinTitle)
{
    MouseGetPos,,, Win
    return WinExist(WinTitle . &quot; ahk_id &quot; . Win)
}

Necroing the **** out of this thread to post a fixed version of this. Looks like no matter what, semicolons cannot be used for anything but comments. I couldn't get this to work until i replaced all the &quot; with "

Running this on Win8 64 bit with no issues. Best script ever :D

Title: Re: AutoHotKey: Share your Scripts!
Post by: The_Beast on Sat, 29 June 2013, 04:35:11
Not a bad thread to necro

Code: [Select]
;; Auto-Reload If Changes Are Made
{
SetTimer,UPDATEDSCRIPT,1000

UPDATEDSCRIPT:
FileGetAttrib,attribs,%A_ScriptFullPath%
IfInString,attribs,A
{
FileSetAttrib,-A,%A_ScriptFullPath%
SplashTextOn,,,Updated script,
Sleep,500
Reload
}
Return
}

Capslock::
Gui, 99:+ToolWindow
Gui, 99:Show, x-1 y-1 +NoActivate, Dummy IJKL to Arrow Keys
Keywait, Capslock
If A_ThisHotkey != Capslock
   Gui, 99:Destroy
else Gui, 99:Show, x-1 y-1 +NoActivate, Dummy IJKL to Arrow Keys +CapsToCancel
return
#IfWinExist, Dummy IJKL to Arrow Keys +CapsToCancel
Capslock::return
CapsLock Up::Gui, 99:Destroy
#IfWinExist, Dummy IJKL to Arrow Keys
w::Up
a::Left
s::Down
d::Right
#IfWinExist

The top of the code is a simple updater. If you save an edit while the script is running, it autoupdates

The bottom is something to make the caps lock a 2nd layer. The cool thing about it is that if you press the caps lock, it locks the layer in. If you hold the caps lock then it doesn't lock and once you release it, it returns to the first layer


I didn't write either of these, but they are cool enough to share.
Title: Re: AutoHotKey: Share your Scripts!
Post by: TheProfosist on Sat, 29 June 2013, 06:01:51
Anyone have any idea how to make the sleep button on my windows media center remote do alt+f4 instead of sleep?
Title: Re: AutoHotKey: Share your Scripts!
Post by: BiNiaRiS on Sat, 29 June 2013, 12:38:19
Anyone have any idea how to make the sleep button on my windows media center remote do alt+f4 instead of sleep?

I wouldn't even have the slightest clue. I'd be willing to bet you can't remap that button though. But if it had a scancode attached you'd be good to go.
Title: Re: AutoHotKey: Share your Scripts!
Post by: TheProfosist on Sat, 29 June 2013, 17:36:09
Anyone have any idea how to make the sleep button on my windows media center remote do alt+f4 instead of sleep?

I wouldn't even have the slightest clue. I'd be willing to bet you can't remap that button though. But if it had a scancode attached you'd be good to go.
it should have scamcode just like play pause or any of those other special keys. How would I figure it out? Would aqua key test do?
Title: Re: AutoHotKey: Share your Scripts!
Post by: Topre on Sat, 29 June 2013, 17:52:37
Anyone have any idea how to make the sleep button on my windows media center remote do alt+f4 instead of sleep?

I wouldn't even have the slightest clue. I'd be willing to bet you can't remap that button though. But if it had a scancode attached you'd be good to go.
it should have scamcode just like play pause or any of those other special keys. How would I figure it out? Would aqua key test do?

Open the Autohotkey script by right clicking it on the taskbar then click Ctrl+K or go under View and click the option "Key history and script info."
Title: Re: AutoHotKey: Share your Scripts!
Post by: TheProfosist on Sat, 29 June 2013, 22:23:42
Anyone have any idea how to make the sleep button on my windows media center remote do alt+f4 instead of sleep?

I wouldn't even have the slightest clue. I'd be willing to bet you can't remap that button though. But if it had a scancode attached you'd be good to go.
it should have scamcode just like play pause or any of those other special keys. How would I figure it out? Would aqua key test do?

Open the Autohotkey script by right clicking it on the taskbar then click Ctrl+K or go under View and click the option "Key history and script info."

alright ill get AutoHotkey on it and try it out i think i should probably disable sleep on the system temporarily as well so it doesnt enter sleep when i hit if you know what I mean.
Title: Re: AutoHotKey: Share your Scripts!
Post by: The_Beast on Sat, 29 June 2013, 22:37:22
Code: [Select]
f1::
Run, firefox.exe http://geekhack.org/index.php?action=pm
return

f2::
Run, firefox.exe http://geekhack.org/index.php?topic=38471.0
return


You should try this script TheProfosist. They're direct links to your PMs and to the GB thread. Hope this halps!
Title: Re: AutoHotKey: Share your Scripts!
Post by: laffindude on Sun, 30 June 2013, 00:53:15
Scroll your mouse wheel over your windows taskbar and change your volume!

Code: [Select]
#If MouseIsOver(&quot;ahk_class Shell_TrayWnd&quot;)
WheelUp::Send {Volume_Up}
WheelDown::Send {Volume_Down}

MouseIsOver(WinTitle)
{
    MouseGetPos,,, Win
    return WinExist(WinTitle . &quot; ahk_id &quot; . Win)
}

Necroing the **** out of this thread to post a fixed version of this. Looks like no matter what, semicolons cannot be used for anything but comments. I couldn't get this to work until i replaced all the &quot; with "

Running this on Win8 64 bit with no issues. Best script ever :D
you need an escape char for semi colon. `; will work. (that's a grave accent).
Title: Re: AutoHotKey: Share your Scripts!
Post by: alrgeez on Mon, 11 November 2013, 16:56:56
can someone help me with a script? would like alt+wheel up = volume up, alt+wheel down = volume down.

need to be able to control master volume control while gaming with my headphones.
Title: Re: AutoHotKey: Share your Scripts!
Post by: Neal on Mon, 11 November 2013, 17:34:57
can someone help me with a script? would like alt+wheel up = volume up, alt+wheel down = volume down.

need to be able to control master volume control while gaming with my headphones.
I'm pretty noobish at AHK, but this will do what you want:
Code: [Select]
LAlt & WheelUp::
SoundSet +1
Return

LAlt & WheelDown::
Soundset -1
Return

This is a script a friend made, it allows you to resize windows and puts them in a corner of the screen if you want to.
As you can see I use it for some random things. Mainly setting windows to  1920x1080, I use 2560x1440 res and I like to have most windows at 1920x1080
Code: [Select]
RCtrl & F5::
 ResizeWin(773,567,1)
return

RCtrl & F6::
 ResizeWin(720,480,1)
return

RCtrl & F7::
 ResizeWin(1280,720,1)
return

RCtrl & F8::
 ResizeWin(1920,1080,1)
return


ResizeWin(CW=0,CH=0,SnapToCorner=0)
{
WinGetPos,X,Y,W,H,A
If %CW% = 0
  CW := W
  If %CH% = 0
  CH := H
  If SnapToCorner = 1
  {
  CX := A_ScreenWidth-CW
  CY := A_ScreenHeight-CH
  }
  Else If SnapToCorner = 2
  {
CX := 62
CY := A_ScreenHeight-CH
  }
  Else
  {
  CX := X
  CY := Y
}
 

  WinMove,A,,%CX%,%CY%,%CW%,%CH%
}
Title: Re: AutoHotKey: Share your Scripts!
Post by: C5Allroad on Mon, 11 November 2013, 18:29:39
Media keys on my shine 3.

Code: [Select]
SC121::Media_Stop
sc16b::Media_Prev
sc16c::Media_Play_Pause
sc132::Media_Next
Title: Re: AutoHotKey: Share your Scripts!
Post by: kolonelkadat on Mon, 11 November 2013, 21:00:38
Anyone have any idea how to make the sleep button on my windows media center remote do alt+f4 instead of sleep?

I no longer have that button, but iirc when I had it, I had to disable it in the control panel - maybe under power options - in order to keep the computer from sleeping. It seemed to send the sleep command before the key press would get picked up by AHK or whatever I was using.
Title: Re: AutoHotKey: Share your Scripts!
Post by: alrgeez on Tue, 12 November 2013, 14:24:49
I'm pretty noobish at AHK, but this will do what you want:
Code: [Select]
LAlt & WheelUp::
SoundSet +1
Return

LAlt & WheelDown::
Soundset -1
Return

thanks Neal! it worked awesome but it ended up cycling through my weapons in game. so i changed the wheel up/down to the arrow keys.

Title: Re: AutoHotKey: Share your Scripts!
Post by: Pacifist on Wed, 27 November 2013, 21:16:18
Does anyone know the ahk code for my keycool 84's fn layer

specifically F1(which opens computer)
F2---google.com
F3 calculator
F4 music
?

the aquakeytest windows code is
182(0XB6)E
172(0XAC)E
183(0XB7)E
181(0XB5)E

thanks
Title: Re: AutoHotKey: Share your Scripts!
Post by: dustinhxc on Wed, 27 November 2013, 22:02:52
RAlt::RCtrl or whatever it is lol I'm on my phone. I use right alt as control :-)
Title: Re: AutoHotKey: Share your Scripts!
Post by: atlas3686 on Thu, 28 November 2013, 00:57:12
Put this together, it makes alt+F2 open the selected file in Photoshop.

Quote
!F2::

ClipSaved := ClipboardAll

Clipboard =

ValidFiletypes = jpg png gif jpeg bmp tif pdf

Send ^c

ClipWait

FullPath := Clipboard



Loop, parse, FullPath, `n, `r

{

    IfNotExist, %A_Loopfield%

        continue

    SplitPath, A_Loopfield ,,, OutExt,

    IfInString, ValidFiletypes, %OutExt%

        run, photoshop.exe %A_LoopField%

}

Clipboard := ClipSaved

OutExt =

ClipSaved =

return   
Title: Re: AutoHotKey: Share your Scripts!
Post by: Senbei on Fri, 29 November 2013, 07:22:29
Hello folks,
my script is for using AltGr _instead_ of the Fn keys on my 60% Filco Minila.
(I would like, eventually, to replace the small space bar with a bigger one, thus I won't have the Fn anymore)
Code: [Select]
SendMode Input

; function keys
*<^>!SC002:: Send {Blind}{RAlt up}{F1}{RAlt down}
*<^>!SC003:: Send {Blind}{RAlt up}{F2}{RAlt down}
*<^>!SC004:: Send {Blind}{RAlt up}{F3}{RAlt down}
*<^>!SC005:: Send {Blind}{RAlt up}{F4}{RAlt down}
*<^>!SC006:: Send {Blind}{RAlt up}{F5}{RAlt down}
*<^>!SC007:: Send {Blind}{RAlt up}{F6}{RAlt down}
*<^>!SC008:: Send {Blind}{RAlt up}{F7}{RAlt down}
*<^>!SC009:: Send {Blind}{RAlt up}{F8}{RAlt down}
*<^>!SC00A:: Send {Blind}{RAlt up}{F9}{RAlt down}
*<^>!SC00B:: Send {Blind}{RAlt up}{F10}{RAlt down}
*<^>!SC00C:: Send {Blind}{RAlt up}{F11}{RAlt down}
*<^>!SC00D:: Send {Blind}{RAlt up}{F12}{RAlt down}
*<^>!SC02B:: Send {Blind}{RAlt up}{PrintScreen}{RAlt down}
*<^>!SC00E:: Send {Blind}{RAlt up}{ScrollLock}{RAlt down}
*<^>!SC001::
Send {Blind}{RAlt up}
GetKeyState, state, Ctrl
if state = D
Send {Blind}{CtrlBreak}
else
Send {Blind}{Pause}
Send {Blind}{RAlt down}
return

; cursor block
*<^>!Up:: Send {Blind}{RAlt up}{PgUp}{RAlt down}
*<^>!Down:: Send {Blind}{RAlt up}{PgDn}{RAlt down}
*<^>!Left:: Send {Blind}{RAlt up}{Home}{RAlt down}
*<^>!Right:: Send {Blind}{RAlt up}{End}{RAlt down}
*<^>!Del:: Send {Blind}{RAlt up}{Ins}{RAlt down}

; tilde on dot
*<^>!SC034:: Send {Blind}{RAlt up}{SC029}{RAlt down}
Title: Re: AutoHotKey: Share your Scripts!
Post by: dustinhxc on Sat, 30 November 2013, 13:09:20
Put this together, it makes alt+F2 open the selected file in Photoshop.

Quote
!F2::

ClipSaved := ClipboardAll

Clipboard =

ValidFiletypes = jpg png gif jpeg bmp tif pdf

Send ^c

ClipWait

FullPath := Clipboard



Loop, parse, FullPath, `n, `r

{

    IfNotExist, %A_Loopfield%

        continue

    SplitPath, A_Loopfield ,,, OutExt,

    IfInString, ValidFiletypes, %OutExt%

        run, photoshop.exe %A_LoopField%

}

Clipboard := ClipSaved

OutExt =

ClipSaved =

return   

Now that's a cool idea!!!
Title: Re: AutoHotKey: Share your Scripts!
Post by: atlas3686 on Tue, 03 December 2013, 02:16:56
Thanks ,I right click, open with, so often that it just makes so much sense. Need to figure out how to do the same thing on my Macbook now.
Title: Re: AutoHotKey: Share your Scripts!
Post by: dustinhxc on Tue, 03 December 2013, 02:55:22
Any way to auto load the program at start up? Thanks !
Title: Re: AutoHotKey: Share your Scripts!
Post by: CeeSA on Tue, 03 December 2013, 07:27:45
do you mean in windows? A Link in "Autostart" could be the solution....
Title: Re: AutoHotKey: Share your Scripts!
Post by: atlas3686 on Tue, 03 December 2013, 08:21:44
Any way to auto load the program at start up? Thanks !

Yup I have done it, there is a little program that comes with Autohotkey that turns your script into an exe then you just set that exe to run at startup.
Title: Re: AutoHotKey: Share your Scripts!
Post by: thegagne on Tue, 03 December 2013, 08:36:25
I need some suggestions on what to do with the 24 Fkeys on my Cherry 8113. :rolleyes:

Maybe changing audio output device?
Maybe speed up / slow down case fans?
Maybe League of Legends macro to buy champ-specific starting items?
That accounts for maybe 4...
What else?
Title: Re: AutoHotKey: Share your Scripts!
Post by: dustinhxc on Tue, 03 December 2013, 10:04:27
Any way to auto load the program at start up? Thanks !

Yup I have done it, there is a little program that comes with Autohotkey that turns your script into an exe then you just set that exe to run at startup.

Thank you very much! I use quick start.
Title: Re: AutoHotKey: Share your Scripts!
Post by: Neo.X on Tue, 03 December 2013, 13:15:34
Mine is very simple, Press a key to hide the active browser window, save my *** when boss come by.  ;)


!`::
  DetectHiddenWindows, on


     if WinExist("ahk_class IEFrame")
        {
               WinHide
         }

  DetectHiddenWindows, off
  return

   

!1::

     DetectHiddenWindows, on
    if WinExist("ahk_class IEFrame")
        {
               WinShow
         }
     DetectHiddenWindows, off

  return

Title: Re: AutoHotKey: Share your Scripts!
Post by: Frenir on Wed, 25 June 2014, 08:39:07
I made this simple script for HHKB users in Nordic countries. It adds backslash and Less/Greater than symbols.
Code: [Select]
; --------------------------------------------------------------------
; Nordic HHKB Function - Less/Greater Than "<" ">"

; Left Alt + Z = "<"
!z::
{
SendInput {<}
}
return

; Left Alt + Shift + Z = ">"
+!z::
{
SendInput {>}
}
return

; --------------------------------------------------------------------
; Nordic HHKB Function - Backslash "\"

; Right Alt + Z = "\"
<^>!z::
{
SendInput {\}
}
return
Also, sorry for necro - I just wanted to share in case someone would find it useful.
Title: Re: AutoHotKey: Share your Scripts!
Post by: lakiozoon on Mon, 14 July 2014, 12:12:35
Anyone with a script that remaps keys while scroll-lock is on?
I'dd like to remap jkl area as a numpad while using scroll-lock.

Various scripts i've dug up googling don't work properly:(
Title: Re: AutoHotKey: Share your Scripts!
Post by: Neo.X on Mon, 14 July 2014, 13:37:56
What I am using now for number pad replacement.

!j::Send 1
!k::Send 2
!l::Send 3h
!u::Send 4
!i::Send 5
!o::Send 6
!7::Send 7
!8::Send 8
!9::Send 9
!m::Send 0
!.::Send .
Title: Re: AutoHotKey: Share your Scripts!
Post by: lakiozoon on Mon, 14 July 2014, 16:41:20
That one will come in handy, thanks!
I would like to have a workaround with scroll lock tho, all solutions i've tried produced errors of some kind.

Again, thanks for the effort.
Title: Re: AutoHotKey: Share your Scripts!
Post by: s0hei on Wed, 16 July 2014, 11:11:43
does anyone have a script for changing capslock -> fn? sorry for the stupid question
Title: Re: AutoHotKey: Share your Scripts!
Post by: Phenix on Sat, 02 January 2016, 04:01:59
rarher use Foobar2000 for music and audiobooks than winamp.Way more customizable
Title: Re: AutoHotKey: Share your Scripts!
Post by: Coreda on Sat, 02 January 2016, 04:19:14
I keep a bunch in a collective mega-script.

A few examples (stripped of the standard top-of-script stuff like #NoEnv, etc) :

Auto-expand the Volume mixer panel window (credit: GeekDude):

More
Code: [Select]
Title = ahk_class #32770 ahk_exe sndvol.exe

Loop
{
    ; ToolTip, Searching
    WinWait, %Title%
    ; ToolTip, Found
    Winmove, %Title%,,,,900,
    WinWaitClose, %Title%
}


Minimize windows by middle-clicking on their titlebar (once you try it you'll never go back, source (http://www.autohotkey.com/board/topic/82066-minimize-by-right-click-titlebar-close-by-middle-click/)):

More
Code: [Select]
#If MouseIsOverTitlebar()
MButton::WinMinimize
+MButton::WinClose

MouseIsOverTitlebar() {
    static WM_NCHITTEST := 0x84, HTCAPTION := 2
    CoordMode Mouse, Screen
    MouseGetPos x, y, w
    if WinExist("ahk_class Shell_TrayWnd ahk_id " w)  ; Exclude taskbar.
        return false
    SendMessage WM_NCHITTEST,, x | (y << 16),, ahk_id %w%
    WinExist("ahk_id " w)  ; Set Last Found Window for convenience.
    return ErrorLevel = HTCAPTION
}


Send clipboard to the command prompt / PowerShell using Ctrl+V:

More
Code: [Select]
#IfWinActive ahk_class ConsoleWindowClass
^V::
SendInput {Raw}%clipboard%
return
#IfWinActive


Paste clipboard contents as plaintext in Wordpad using Ctrl+Shift+V (source (https://gist.github.com/davejamesmiller/1965840)):

More
Code: [Select]
#IfWinActive, ahk_class WordPadClass            ; WordPad
^+v::
Clip0 = %ClipBoardAll%
ClipBoard = %ClipBoard% ; Convert to plain text
Send ^v
Sleep 1000
ClipBoard = %Clip0%
VarSetCapacity(Clip0, 0) ; Free memory
Return
Title: Re: AutoHotKey: Share your Scripts!
Post by: Lunatique on Sat, 09 January 2016, 04:02:38
For those of you who experience stability issues with AHK and don't need complex scripts, a much more stable and intuitive alternative is TouchCursor (although it is much simpler). But if TouchCursor can do all the things you want already, then definitely use it over AHK.
Title: Re: AutoHotKey: Share your Scripts!
Post by: Questengine on Thu, 26 May 2016, 12:01:15
Here's a couple cool ones for coders. 

Type an "if" condition, like "somevar = 2" then hit alt-i and it builds an if statement around that, comments the condition after the closing brace, and puts the cursor in the body of the "if" after a tab

e.g. 
type: "somevar = true"
hit alt-i
get:
Code: [Select]
if(somevar=true){//

}//end if--somevar=true
And then alt-e does the same thing but for an if/else statement

Code: [Select]
;;do "if"
!i::
;;save what's currently on the clipboard
varClipSaved :=ClipboardAll
Sleep, 133
Send {Shift down}{Home}{Shift up}^c
Sleep, 133
Send if`(
Send %Clipboard%
Send `){{}{/ 2}{Enter 2}{}}{End}{/ 2}end if--
Send %Clipboard%
Send {Up }{End}{Tab}
;;restore what was originally on the clipboard
Clipboard := varClipSaved
;;empty that temp clipboard variable, to free that memory (in case you had a lot of crap there)
varClipSaved := 
return


;;do "if/else",
!e::
;;save what's currently on the clipboard
varClipSaved :=ClipboardAll
Sleep, 133
Send {Shift down}{Home}{Shift up}^c
  Sleep, 133
Send if`(
Send %Clipboard%
Send `){{}{/ 2}{Enter 2}{}}{End}{/ 2}end if--
Send %Clipboard%
Send {Enter}else{{}{Enter}{Tab}{Enter}{}}{/ 2}end else--
Send %Clipboard%
Send {Home}{Up 4}{Tab}
;;restore what was originally on the clipboard
Clipboard := varClipSaved
;;empty that temp clipboard variable, to free that memory (in case you had a lot of crap there)
varClipSaved := 
return

And a couple expansions that are obvious, but you probably aren't using.  Why type 6 characters when you can type 2?
Code: [Select]
::fff::function   
::sss::select * from
::pv::private
::pb::public
::pt::protected

And a couple just for Unity and/or 3D programming:
Code: [Select]

::vv::Vector3
::vz::Vector3.zero
::vd::Vector3.Distance(){Left}
::qqq::Quaternion   
::gg::gameObject  ;; gg doesn't come up too often naturally
::pp::transform.position  ;;similarly, pp is pretty safe
::rrt::transform.rotation  ;; tr, rt, and rot, are to common for this, so rrt has to suffice.