Code: Select all
SetBatchlines -1
SetControlDelay, -1
#SingleInstance force
#NoEnv
if !FileExist("background.png")
UrlDownloadToFile, http://www.auto-hotkey.com/boards/styles/subsilver2/imageset/ahk_logo.png, background.png
OnMessage(WM_LBUTTONUP := 0x202, "OnClickUp")
OnMessage(WM_MOUSEMOVE := 0x200, "OnMouseMove")
SuperButton("test1", "background.png", 50, 50)
SuperButton("test2", "background.png", 200, 200)
SuperButton("test3", "background.png", 50, 200)
Gui, Show, w640 h480, TEST
SetTimer, check, 50
return
check:
CoordMode, Mouse, Client
MouseGetPos, mx, my, mw, mc, 0
tooltip % mx "`n" my "`n" mw "`n" mc, 0, 0, 3
return
ControlMove:
tooltip, % a_guicontrol, 100, 0, 2
mode := a_guicontrol
CoordMode, Mouse, Client
MouseGetPos, mx, my
GuiControlGet, %a_guicontrol%, Pos
mx0 := mx-%a_guicontrol%x
my0 := my-%a_guicontrol%y
return
OnClickUp(){
global
if InStr(mode, "Text")
{
;DllCall("SetWindowPos", UInt,WinExist("ahk_id " %mode0%), Int,1, Int,0, Int,0, Int,0, Int,0, UInt,0x13)
;DllCall("SetWindowPos", UInt,WinExist("ahk_id " %mode%), Int,1, Int,0, Int,0, Int,0, Int,0, UInt,0x13)
WinSet, Bottom, , % "ahk_id " %mode0%
WinSet, Bottom, , % "ahk_id " %mode%
}
else
{
;DllCall("SetWindowPos", UInt,WinExist("ahk_id " %mode%), Int,1, Int,0, Int,0, Int,0, Int,0, UInt,0x13)
;DllCall("SetWindowPos", UInt,WinExist("ahk_id " %mode0%), Int,1, Int,0, Int,0, Int,0, Int,0, UInt,0x13)
WinSet, Bottom, , % "ahk_id " %mode%
WinSet, Bottom, , % "ahk_id " %mode0%
}
mode := "static"
WinSet, redraw, , A
return
}
OnMouseMove()
{
global
if (mode != "static")
{
CoordMode, Mouse, Client
MouseGetPos, mx, my
if InStr(mode, "Text")
{
mode0 := RegExReplace(mode, "Text", "Background")
GuiControl, Move, % mode0, % "x" mx-mx0 " y" my-my0
GuiControl, Move, % mode, % "x" mx-mx0 " y" my-my0
WinSet, redraw, , % "ahk_id " %mode0%
WinSet, redraw, , % "ahk_id " %mode%
}
else
{
mode0 := RegExReplace(mode, "Background", "Text")
GuiControl, Move, % mode, % "x" mx-mx0 " y" my-my0
GuiControl, Move, % mode0, % "x" mx-mx0 " y" my-my0
WinSet, redraw, , % "ahk_id " %mode%
WinSet, redraw, , % "ahk_id " %mode0%
}
}
}
esc::
guiclose:
exitapp
SuperButton(text, picture, x, y) {
Global
Static id := 0
id += 1
Gui, Add, Picture, x%x% y%y% w300 h-1 gControlMove vBackground%id% hwndBackground%id%, % picture
Gui, Add, Text, x%x% y%y% w100 h30 +0x201 +Border gControlMove vText%id% hwndText%id% +Backgroundtrans, % text
return
}
/*
DllCall("SetWindowPos", UInt,WinExist("ahk_id " %mode0%), Int,1, Int,0, Int,0, Int,0, Int,0, UInt,0x13)
#define SWP_NOSIZE 0x0001
#define SWP_NOMOVE 0x0002
#define SWP_NOZORDER 0x0004
#define SWP_NOREDRAW 0x0008
#define SWP_NOACTIVATE 0x0010
#define SWP_FRAMECHANGED 0x0020 /* The frame changed: send WM_NCCALCSIZE */
#define SWP_SHOWWINDOW 0x0040
#define SWP_HIDEWINDOW 0x0080
#define SWP_NOCOPYBITS 0x0100
#define SWP_NOOWNERZORDER 0x0200 /* Don't do owner Z ordering */
#define SWP_NOSENDCHANGING 0x0400 /* Don't send WM_WINDOWPOSCHANGING */
#define SWP_DRAWFRAME SWP_FRAMECHANGED
#define SWP_NOREPOSITION SWP_NOOWNERZORDER
#if(WINVER >= 0x0400)
#define SWP_DEFERERASE 0x2000
#define SWP_ASYNCWINDOWPOS 0x4000
#endif /* WINVER >= 0x0400 */
#define HWND_TOP 0
#define HWND_BOTTOM 1
#define HWND_TOPMOST -1
#define HWND_NOTOPMOST -2
*/