Code: Select all
#singleinstance,force
#include ShinsOverlayClass.ahk ;assumes you download the class file to this directory
overlay := new ShinsOverlayClass(500,500,200,130,0,0,0) ;x,y,w,h,alwaysontop,vsync,clickthrough
OnMessage(0x200,"WM_MOUSEMOVE")
OnMessage(0x201,"WM_LBUTTONDOWN")
OnMessage(0x14, "WM_ERASEBKGND")
overlay.data.update := 1 ;controls when the gui should be redrawn
overlay.data.count := 0 ;the count of 1 presses
;create some custom buttons
overlay.data.buttons := []
overlay.data.buttons.push(new buttonClass(overlay,10,overlay.height-40,80,30,"Save","Save"))
overlay.data.buttons.push(new buttonClass(overlay,overlay.width-90,overlay.height-40,80,30,"Reset","Reset"))
loop {
if (overlay.data.update) {
Draw(overlay)
}
sleep 10
}
return
~1::
overlay.data.count++
overlay.data.update := 1 ;tells the overlay to redraw
return
save:
msgbox save
return
reset:
overlay.data.count := 0
overlay.data.update := 1
return
f9::reload
f8::exitapp
Draw(overlay) {
overlay.data.update := 0
if (overlay.BeginDraw()) {
overlay.FillRectangle(0,0,overlay.Width,overlay.Height,0xAA000000)
overlay.DrawRectangle(1,1,overlay.Width-1,overlay.Height-1,0xFF888888)
overlay.DrawText(overlay.data.count,0,18,48,0xFFFFFFFF,"Arial","acenter w" overlay.width)
for k,v in overlay.data.buttons
v.draw()
overlay.EndDraw()
}
}
WM_LBUTTONDOWN(a,b) {
global overlay
mx := b & 0xFFFF
my := b >> 16
for k,v in overlay.data.buttons
{
if (v.Hover(mx,my)) { ;if hovering a button call it's label and return
label := v.label
settimer,%label%,-1
return
}
}
PostMessage, 0xA1, 2
}
WM_MOUSEMOVE(a,b) {
global overlay
mx := b & 0xFFFF
my := b >> 16
for k,v in overlay.data.buttons
{
if (v.Hover(mx,my)) {
if (!v.state) {
v.state := 1
overlay.data.update := 1
}
} else if (v.state) {
v.state := 0
overlay.data.update := 1
}
}
}
WM_ERASEBKGND() {
return 0
}
class buttonClass {
__New(overlay,x,y,w,h,text,label) {
this.overlay := overlay
this.x := x
this.y := y
this.x2 := x+w
this.y2 := y+h
this.w := w
this.h := h
this.text := text
this.label := label
this.state := 0
}
Hover(mx,my) {
return (mx >= this.x and my >= this.y and mx <= this.x2 and my <= this.y2)
}
Draw() {
if (this.state) {
this.overlay.FillRectangle(this.x,this.y,this.w,this.h,0xFFFFFFFF)
this.overlay.FillRectangle(this.x+1,this.y+1,this.w-2,this.h-2,0xFF999999)
this.overlay.DrawText(this.text,this.x,this.y,24,0xFF000000,"Arial","acenter w" this.w)
} else {
this.overlay.FillRectangle(this.x,this.y,this.w,this.h,0xFFFFFFFF)
this.overlay.FillRectangle(this.x+1,this.y+1,this.w-2,this.h-2,0xFF222222)
this.overlay.DrawText(this.text,this.x,this.y,24,0xFFFFFFFF,"Arial","acenter w" this.w)
}
}
}