geekhack
geekhack Community => Other Geeky Stuff => Topic started by: MrFex 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!
-
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.
; 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
-
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
; 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%
}
-
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
Example
-
LAlt & w::Send {Up}
LAlt & a::Send {Left}
LAlt & s::Send {Down}
LAlt & d::Send {Right}
|::'
'::|
-
|::'
'::|
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?
-
|::'
'::|
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
-
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
; 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%
}