I made this script and it works ok.
But there should be a better way.
This is what it does:
If your mouse position is above the text it changes the text color(like in a menu or button).
And the text functions as a buttons.
Code:
Gui +LastFound -Caption Border
Gui, Color, Black, Black
Gui, Font, S10 cWhite, Comic Sans MS
Gui, Add, Text, gReload x2 y2 w80 h20 , Reload
Gui, Add, Text, gPauze x2 y22 w80 h20 , Pauze
Gui, Add, Text, gSuspend x2 y42 w80 h20 , Suspend
Gui, Show, w80 h63, MenuOptions
GoSub Position
Return
Position:
if WinActive("ahk_class AutoHotkeyGUI")
CoordMode, Mouse, Relative ;get mouse position
Loop
{
; get the position of the text
MouseGetPos, VarX, VarY
;-------------------------
If VarX between 2 and 80
TempX = 1
Else
TempX = 0
;--------------
If VarY between 2 and 21
TempY = 1
Else if VarY between 22 and 41
TempY = 2
Else if VarY between 42 and 62
TempY = 3
Else
TempY = 0
;-------------------------
If (TempX = 1 and TempY = 1)
{
Gosub TReload ; mouse is above the text Reload
}
Else if (TempX = 1 and TempY = 2)
{
Gosub TPauze ; mouse is above the text Pauze
}
Else if (TempX = 1 and TempY = 3)
{
Gosub TSuspend ; mouse is above the text Suspend
}
Else
{
Gosub TOutside ; mouse is not above any text (only usefull if there are other things in the gui)
}
}
Return
TReload:
Gui, Font, S10 cYellow, Comic Sans MS
GuiControl, Font, Reload ;change color yellow
Gui, Font, S10 cWhite, Comic Sans MS
GuiControl, Font, Pauze ;change color white
Gui, Font, S10 cWhite, Comic Sans MS
GuiControl, Font, Suspend ;change color white
Return
TPauze:
Gui, Font, S10 cYellow, Comic Sans MS
GuiControl, Font, Pauze
Gui, Font, S10 cWhite, Comic Sans MS
GuiControl, Font, Suspend
Gui, Font, S10 cWhite, Comic Sans MS
GuiControl, Font, Reload
Return
TSuspend:
Gui, Font, S10 cYellow, Comic Sans MS
GuiControl, Font, Suspend
Gui, Font, S10 cWhite, Comic Sans MS
GuiControl, Font, Pauze
Gui, Font, S10 cWhite, Comic Sans MS
GuiControl, Font, Reload
Return
TOutside:
Gui, Font, S10 cWhite, Comic Sans MS
GuiControl, Font, Suspend
Gui, Font, S10 cWhite, Comic Sans MS
GuiControl, Font, Pauze
Gui, Font, S10 cWhite, Comic Sans MS
GuiControl, Font, Reload
Return
Reload:
Reload
Return
Suspend:
Suspend
Return
Pauze:
Pause
Return
So my question is how can i make the code shorter and less noobish?
Ideas or example's are welcome.