Author Topic: Post your keyboard related autohotkey scripts  (Read 2717 times)

0 Members and 1 Guest are viewing this topic.

Offline MrFex

  • Thread Starter
  • Posts: 112
  • Location: NL
Post your keyboard related autohotkey scripts
« on: Sun, 16 November 2014, 17:45:31 »
Hi -


I've searched these forums for a autohotkey topic that is not specific and only contains a list of autohotkey scripts for keyboard enthusiasts. I've been lurking around and I have found great resources but I haven't found a topic that lists them all. Do you know of such a topic?

Otherwise use this one!

« Last Edit: Mon, 17 November 2014, 15:56:23 by MrFex »

Offline MrFex

  • Thread Starter
  • Posts: 112
  • Location: NL
Re: Post your keyboard related autohotkey scripts
« Reply #1 on: Sun, 16 November 2014, 17:48:30 »
The following script can be used to adjust screen brightness in Windows (using Gamma, not actual monitor / display driver).

I'm using this on my ducky which has keys for mute, vol up, vol down and calc.

Press CTRL+one of the keys above.


Code: [Select]
; Screendimmer.ahk

;----------------------------------------------------------
; Author    : Appbyfex
; Date      : 2014-11-10
;----------------------------------------------------------

MinValue = -100
MaxValue = 128
Value := 64

Menu, Tray, Icon, Shell32.dll, 44
Menu, Tray, Add, Show Dimmer, ShowWindow
Menu, Tray, Default, Show Dimmer
Menu, Tray, Click, 1

Gui +AlwaysOnTop
Gui, Add, Text, vDim x0 y0, 0`%
Gui, Add, Text, vBright x0 y0, 100`%
Options := "Range-100-128 NoTicks Buddy1Dim Buddy2Bright vMySlider gDimmer"
Gui, Add, Slider, W235 x25 y5 AltSubmit Tooltip Reverse %options% , %Value%
Gui, Add, StatusBar, , Default Brightness 64
Gui, Show, W300 Hide, Screen Brightness

DisplaySetBrightness(Value)

^Volume_Mute::Off()
^Volume_Down::Decrease()
^Volume_Up::Increase()
^Launch_App2::Reset()

Off() {
global Value
Value := -100
UpdateUI()
}

Reset() {
global Value, MaxValue
Value := MaxValue
UpdateUI()
}

Decrease() {
   global Value, MinValue
   Value -= 10

  if (Value < MinValue)
    Value := MinValue

UpdateUI()
}

Increase() {
Global Value, MaxValue
   Value += 10

if (Value > MaxValue)
Value := MaxValue

UpdateUI()
}

UpdateUI() {
global Value

DisplaySetBrightness(Value)
GuiControl, , MySlider, %Value%
SB_SetText("Brightness level is " . Value)
}

DisplaySetBrightness( Br=128 ) {
 Loop, % VarSetCapacity( GR,1536 ) / 6
   NumPut( ( n := (Br+128)*(A_Index-1)) > 65535 ? 65535 : n, GR, 2*(A_Index-1), "UShort" )

 DllCall( "RtlMoveMemory", UInt,&GR+512,  UInt,&GR, UInt,512 )
 DllCall( "RtlMoveMemory", UInt,&GR+1024, UInt,&GR, UInt,512 )
 Return DllCall( "SetDeviceGammaRamp", UInt, hDC := DllCall( "GetDC", UInt,0 ), UInt,&GR ),
DllCall( "ReleaseDC", UInt,0, UInt,hDC )
}

Dimmer:
  DisplaySetBrightness( MySlider )
  Value = MySlider
  SB_SetText("Brightness level is " . %Value%)
Return

ShowWindow:
 DetectHiddenWindows, on
 WinRestore, Screen Brightness
 WinActivate, Screen Brightness
Return

« Last Edit: Mon, 17 November 2014, 15:55:14 by MrFex »

Offline MrFex

  • Thread Starter
  • Posts: 112
  • Location: NL
Re: Post your keyboard related autohotkey scripts
« Reply #2 on: Sun, 16 November 2014, 17:51:08 »
The following scripts can be used to move a Window to another monitor.

I'm using this on my ducky which has keys for mute, vol up and vol down.

Press Win+on of the keys above to activate

Code: [Select]
; WindowMover.ahk

;----------------------------------------------------------
; Author    : Appbyfex
; Date      : 2014-11-10
;----------------------------------------------------------
;#NoEnv
;#SingleInstance

Menu, Tray, Icon, ImageRes.dll, 236

; Define monitors
MonitorLeft := 3
MonitorCenter := 1
MonitorRight := 2

; Bind to keys
#Volume_Mute UP::MonitorInfo(MonitorLeft)
#Volume_Down UP::MonitorInfo(MonitorCenter)
#Volume_Up UP::MonitorInfo(MonitorRight)

; Main function that moves the active window
MonitorInfo(Index)
{
; Get the X, Y, Width and Height of the Active window
WinGetPos, ActWin_X, ActWin_Y, ActWin_W, ActWin_H, A
if !ActWin_W
Return "Error"

SysGet, Monitor, Monitor, %Index%
SysGet, MonitorWorkArea, MonitorWorkArea, %Index%

MonitorWidth := Abs(MonitorWorkAreaRight - MonitorWorkAreaLeft)
MonitorHeight := Abs(MonitorWorkAreaBottom - MonitorWorkAreaTop)

Left := MonitorLeft
Top := MonitorTop
Width := ActWin_W
Height := ActWin_H

if (Width > MonitorWidth)
  Width := MonitorWidth
    else
  Left += (MonitorWidth - Width) / 2

if (Height > MonitorHeight)
  Height := MonitorHeight
    else
  Top += (MonitorHeight - Height) / 2

WinMove, A,, %Left%, %Top%, %Width%, %Height%
}
« Last Edit: Mon, 17 November 2014, 15:54:30 by MrFex »

Offline Coreda

  • Posts: 776
Re: Post your keyboard related autohotkey scripts
« Reply #3 on: Sun, 16 November 2014, 18:04:42 »
Nice idea  :thumb: One suggestion: you may want to place the AHK code within [code] tags wrapped in [more] tags so they collapse and can be expanded if wanted. It also provides a neat 'select all' button.


Eg:

More
Code: [Select]
Example

Offline epzy

  • HHKB Fiend
  • Posts: 2061
  • Location: Norway
  • ded
Re: Post your keyboard related autohotkey scripts
« Reply #4 on: Sun, 16 November 2014, 18:15:06 »
LAlt & w::Send {Up}
LAlt & a::Send {Left}
LAlt & s::Send {Down}
LAlt & d::Send {Right}

|::'
'::|
FaceW ~ Duck Viper ~ Kishsaver ~ HHKB Pro 2 Cherry G81-3000SAU ~ Filco Majestouch 2 ~ GON NS NerD 60 HHKB ~ 360 Corsa (jk skam) ~ KMAC Happy (jk skam) ~ JD40 (jk skam)

Offline MrFex

  • Thread Starter
  • Posts: 112
  • Location: NL
Re: Post your keyboard related autohotkey scripts
« Reply #5 on: Mon, 17 November 2014, 15:58:30 »
|::'
'::|

Thanks for sharing, if you have more please.

Also, what does the code above do? Does that swap single quote with pipe? Why would do you prefer that?

Offline epzy

  • HHKB Fiend
  • Posts: 2061
  • Location: Norway
  • ded
Re: Post your keyboard related autohotkey scripts
« Reply #6 on: Mon, 17 November 2014, 16:20:04 »
|::'
'::|

Thanks for sharing, if you have more please.

Also, what does the code above do? Does that swap single quote with pipe? Why would do you prefer that?

yeah it simply swaps ' and |

I swap those two because I prefer having ' directly above backspace on my HHKB. it just makes it easier not to miss it

also I set the keyboard language to Norwegian in my OS which makes the layout a bit different
FaceW ~ Duck Viper ~ Kishsaver ~ HHKB Pro 2 Cherry G81-3000SAU ~ Filco Majestouch 2 ~ GON NS NerD 60 HHKB ~ 360 Corsa (jk skam) ~ KMAC Happy (jk skam) ~ JD40 (jk skam)

Offline MrFex

  • Thread Starter
  • Posts: 112
  • Location: NL
Re: Post your keyboard related autohotkey scripts
« Reply #7 on: Mon, 17 November 2014, 17:19:21 »
The following scripts can be used to move a Window to another monitor.

I'm using this on my ducky which has keys for mute, vol up and vol down.

Press Win+one of the keys above to activate

Code: [Select]
; WindowMover.ahk

;----------------------------------------------------------
; Author    : Appbyfex
; Date      : 2014-11-10
;----------------------------------------------------------
;#NoEnv
;#SingleInstance

Menu, Tray, Icon, ImageRes.dll, 236

; Define monitors
MonitorLeft := 3
MonitorCenter := 1
MonitorRight := 2

; Bind to keys
#Volume_Mute UP::MonitorInfo(MonitorLeft)
#Volume_Down UP::MonitorInfo(MonitorCenter)
#Volume_Up UP::MonitorInfo(MonitorRight)

; Main function that moves the active window
MonitorInfo(Index)
{
; Get the X, Y, Width and Height of the Active window
WinGetPos, ActWin_X, ActWin_Y, ActWin_W, ActWin_H, A
if !ActWin_W
Return "Error"

SysGet, Monitor, Monitor, %Index%
SysGet, MonitorWorkArea, MonitorWorkArea, %Index%

MonitorWidth := Abs(MonitorWorkAreaRight - MonitorWorkAreaLeft)
MonitorHeight := Abs(MonitorWorkAreaBottom - MonitorWorkAreaTop)

Left := MonitorLeft
Top := MonitorTop
Width := ActWin_W
Height := ActWin_H

if (Width > MonitorWidth)
  Width := MonitorWidth
    else
  Left += (MonitorWidth - Width) / 2

if (Height > MonitorHeight)
  Height := MonitorHeight
    else
  Top += (MonitorHeight - Height) / 2

WinMove, A,, %Left%, %Top%, %Width%, %Height%
}