By Roland. Contributions by Adde @ 2+2 forums. The corresponding thread on 2+2 is here.
AHK Tilt Blocker
Use Win+Space to open a new Tilt Blocker box (Gui). Right-click box for more commands (Duplicate, Resize, Close, etc).
Optinally, you can configure a couple of settings in the script code (Hotkey, Color, Auto-start, Default Width/Height, etc).
This script needs RolandsFunctions.
; AHK tilt blocker v 1.04
; 8:47 AM Monday, August 06, 2007
; by Roland
; Contributions by Adde
; --------------------- EDIT THESE SETTINGS
; Set what hotkey should open a new tilt blocker box
; LINK: http://www.autohotkey.com/docs/KeyList.htm
hotkey_open_one := "#Space" ; ^Space
hotkey_open_default := "^Space" ; ^Space
; Change to your favorite color
; LINK: http://www.w3schools.com/html/html_colors.asp
default_color = FF0000
; Set default width/height of tilt blocker box
default_width = 110
default_height = 45
; Set if new blockers should have a resize border (1) or not (0)
default_resize = 0
; Set if one new tilt blocker box should open at startup (1) or not (0)
; Set if all default tilt blocker boxes (see settings below) should open at startup (1) or not (0)
open_one_at_startup = 1
open_default_at_startup = 0
; Set x/y/w/h for all blocker boxes that should be opened by default.
default_boxes_x := "5, 139, 806, 946, 5, 139, 806, 946"
default_boxes_y := "495, 514, 495, 514, 1065, 1085, 1065, 1085"
default_boxes_w := "141, 141, 141, 141, 141, 141, 141, 141"
default_boxes_h := "74, 55, 74, 55, 74, 55, 74, 55"
; Set default transparancy.
default_trans = 255
; --------------------- DO NOT EDIT BELOW
; #NoTrayIcon
#NoEnv
#SingleInstance force
#Include %a_scriptDir%
#Include Functions.ahk
#SingleInstance force
SetWorkingDir %a_scriptDir%
OnMessage(0x201, "WM_LBUTTONDOWN")
OnMessage(0x204, "WM_RBUTTONDOWN")
;OnMessage(0x207, "WM_MBUTTONDOWN")
IsCompiled()
CheckAHKVersion("1.0.44.08")
Menu, ctxt, Add, &Color, Color
Menu, ctxt, Add, Color &All, ColorAll
Menu, ctxt, Add
Menu, ctxt, Add, Show Resize Border, ShowResizeBorder
Menu, ctxt, Add, Hide Resize Border, HideResizeBorder
Menu, ctxt, Add
Menu, ctxt, Add, Duplicate, Duplicate
Menu, ctxt, Add
Menu, ctxt, Add, Close This, CloseThis
Menu, ctxt, Add, Close All, CloseAll
Menu, ctxt, Add
Menu, ctxt, Add, Show Coordinates, ShowCoordinates
Menu, ctxt, Add
Menu, ctxt, Add, &Help, Help
Menu, ctxt, Add
Menu, ctxt, Add, E&xit, Exit
Hotkey, %hotkey_open_one%, OpenOne, UseErrorLevel
Hotkey, %hotkey_open_default%, OpenDefault, UseErrorLevel
Loop 99
guiList := AddToList(guiList, a_index)
StringSplit, default_boxes_x_list, default_boxes_x, `,
StringSplit, default_boxes_y_list, default_boxes_y, `,
StringSplit, default_boxes_w_list, default_boxes_w, `,
StringSplit, default_boxes_h_list, default_boxes_h, `,
if (open_one_at_startup)
NewGui()
if (open_default_at_startup)
OpenDefault()
return
;------- end of auto-execute section --------
OpenDefault:
OpenDefault()
return
OpenDefault()
{
local n
Loop, %default_boxes_x_list0%
{
n := a_index
NewGui(default_boxes_x_list%n%, default_boxes_y_list%n%, default_boxes_w_list%n%, default_boxes_h_list%n%, "", 0)
}
}
;---- new gui ----
OpenOne:
NewGui()
return
; #Space::NewGui()
NewGui(x="", y="", w="", h="", color="", resize="")
{
global
n := ExFromList(guiList,1)
guiList := RemoveFromList(guiList, n)
Gui %n%:Default
Gui +Lastfound +Toolwindow -Caption +0x800000 +AlwaysOnTop
Gui -Caption
if (resize = "")
resize := default_resize
if (color = "")
color := default_color
if (w = "")
w := default_width
if (h = "")
h := default_height
id := WinExist()
num%id% = %n%
this_color%n% = %color%
this_resize%n% = %resize%
Gui, Color, %color%
WinSet, Transparent, %default_trans%
if (resize)
Gui +Resize
if (x <> "")
Gui Show, w%w% h%h% x%x% y%y%
else
Gui Show, w%w% h%h%
this_active%n% = 1
}
;----- context menu ----
WM_RBUTTONDOWN() {
global
lastGui = %a_gui%
WinGetActiveStats, a_title, a_w, a_h, a_X, a_Y
SysGet, a_border, 32
Menu, ctxt, Show
}
Color:
n := ExFromList(guiList,1)
guiList := RemoveFromList(guiList, n)
c := ColorPicker("","",-1,n)
guiList := AddToList(guiList, g)
If ( c )
{
Gui, %lastGui%: Color, % c
this_color%lastGui% = %c%
}
return
ColorAll:
n++
c := ColorPicker("","",-1,n)
n--
If ( ! c )
return
Loop % n
{
Gui, %a_index%: Color, % c
this_color%a_index% = %c%
}
return
Help:
h =
(
Win + Space: New Gui
Left mouse button: Move
Ctrl + Left mouse button: Size
Middle mouse button: Close
)
Msgbox(h, "IconI bold BackgroundWhite -Owner","Help")
return
Exit:
ExitApp
ShowResizeBorder:
Gui, %lastGui%: +Resize
Gui, %lastGui%: Show
this_resize%lastGui% = 1
return
HideResizeBorder:
Gui, %lastGui%: -Resize
Gui, %lastGui%: Show
this_resize%lastGui% = 0
return
Duplicate:
if (this_resize%lastGui%)
border := a_border + 2
else
border := 0
NewGUI("", "", a_w-border, a_h-border, color%lastGui%, this_resize%lastGui%)
return
CloseThis:
Gui %lastGui%: destroy
guiList := AddToList(guiList, lastGui)
return
CloseAll:
Loop 99
if (this_active%a_index%)
{
Gui %a_index%: destroy
guiList := AddToList(guiList, a_index)
}
return
ShowCoordinates:
WinGetActiveStats, title, w, h, X, Y
Msgbox x=%x%`ny=%y%`nwidth=%w%`nheight=%h%
return
;-------- move --------
Move() {
SetBatchLines -1
WinGetPos, wx, wy, ww, wh
MouseMove, ww, wh
CoordMode Mouse, Screen
Loop {
If ! GetKeyState("LButton","P")
break
MouseGetPos, x, y
x -= wx
y -= wy
If ( x < 10 )
x = 10
If ( y < 10 )
y = 10
WinMove,,,,, x, y
}
}
WM_LBUTTONDOWN() {
If GetKeyState("Ctrl")
Move()
else
PostMessage, 0xA1, 2
}
;------- close ------
WM_MBUTTONDOWN() {
global
id := WinExist()
g := num%id%
Gui %g%: destroy
guiList := AddToList(guiList, g)
this_active%g% = 0
}
