Great Script.
I customised v2, so you can specify how many icons you want, and can define them at the start.
I found that I didnt always require 8 icons.
If you think it is a good idea, please add it.
Thanks again.
I have messed around with the button sizes though, so I wouldnt recommend using mine as is.
Number = 5 ; Number of Icons
TextSize = 8 ; Item's text size Once when you get used to your radial menu, you will remember item's positions, and text size won't be so important to you. So you will select items by position in your mind, not by reading item's text.
TextColor = black ; Item's text color
Font = Calibri ; Item's font
BuildDelay = 170 ; menu will start to show itself after %BuildDelay% miliseconds. To show it instantly, set 0. This delay gives you opportunity to send normal RButton click without annoying menu showing. THE BEST THING TO DO is to change hotkey to XButton1 or XButton1 (if you have them - I don't) and use BuildDelay = 0. MButton is also good idea.
BuildEffect = 50 ; menu items will show themself, one by one, in interval of %BuildEffect% ms. To show them all instantly, set 0.
ItemBounce = 1 ; 1 means: items will bounce when you select them. 0 means: items will not bounce.
SoundOnSelect = 1 ; 1 means: play sound when item is selected. 0 means: don't play sound. Of course, you can change sound...
; SoundOnShow ; Play with effects: you can easily add this by slightly modifying script...
; SoundOnDestroy
Color = Black ; this is alternative background color, if script can't load picture (button picture).
ButtonBack = Button3.png ; button's background
Item1 = Calc
Item2 = NotePad
Item3 = Explorer
Item4 = About
Item5 =
Item6 =
Item7 =
Item8 =
;===Auto-execute======================================================================
StringTrimRight, Sname, A_ScriptName, 4
Menu, Tray, Tip, %Sname%
Loop, %Number% ; load item's background (fake button), set altenative background and font
{
; If you want to change item's background, try to use 50x50 images. Some other backgrounds are available on:
; http://www.autohotkey.net/~Learning one/Radial Menu
; Play with effects: small deviations in Add, Picture options have interesting effect:
; x0 y-1 w69 h69 ; small shadow
; x0 y-1 w71 h71 ; no shadow
Gui 9%A_Index%:Add, Picture, x0 y0 w32 h32 , %A_scriptdir%\%ButtonBack%
Gui 9%A_Index%:Font, s%TextSize%, %Font%
Gui, Color, EEAA99
Gui +LastFound ; Make the GUI window the last found window for use by the line below.
WinSet, TransColor, EEAA99
}
;======Set item names======
; This is just example. Build your own menu! You don't need to manually reposition item's text (like in Radial menu v1).
; Play with effects: Remove BackgroundTrans in GuiTextOptions and set Color = 757500 (GUI's color)
GuiTextOptions = x2 y28 w32 h32 c%TextColor% BackgroundTrans
Loop, %Number%
{
current := Item%A_Index%
Gui 9%A_Index%:Add, Text, %GuiTextOptions% , %current% ; Auto build items 1-5
}
;==========================
;===Hotkey==============================================================================
RButton:: ; Press & hold to show menu. Touch items with mouse to select them. Release RButton to hide menu. THE BEST THING TO DO is to change hotkey to XButton1 or XButton1 if you have them ( I don't :( )
PressedTime = 0
CoordMode, mouse, Screen
MouseGetPos, mx1, my1
SetTimer, RadialMenuClose, 35
Loop, %Number% ; Draw items (GUIs) at exact positions --> 50x50 buttons
{
if A_index = 1
{
RMx := mx1-25
RMy := my1-95
if BuildDelay
{
Sleep , %BuildDelay% ; menu will start to show itself after %BuildDelay% ms
if not (GetKeyState("RButton","p"))
Return
}
}
Else if A_index = 2
{
RMx := mx1+25
RMy := my1-75
}
Else if A_index = 3
{
RMx := mx1+45
RMy := my1-25
}
Else if A_index = 4
{
RMx := mx1+25
RMy := my1+25
}
Else if A_index = 5
{
RMx := mx1-25
RMy := my1+45
}
Else if A_index = 6
{
RMx := mx1-75
RMy := my1+25
}
Else if A_index = 7
{
RMx := mx1-95
RMy := my1-25
}
Else if A_index = 8
{
RMx := mx1-75
RMy := my1-75
}
Gui 9%A_Index%: +AlwaysOnTop +ToolWindow -caption +LastFound
;WinSet, Region, 1-0 W50 H50 R25-25
Gui 9%A_Index%: Show, x%RMx% y%RMy% h40 w48, Item%A_Index%
WinSet, Transparent, 255, Item%A_Index%
Sleep, %BuildEffect%
if not (GetKeyState("RButton","p"))
Return
}
SetTimer, GetSelectedItem, 15
Return
;===Subroutines=========================================================================
GetSelectedItem: ; menu items are identified by GUI's title!
MouseGetPos, , , WinID
WinGetTitle, Item, ahk_id %WinID%
if Item contains Item ; This is just example. Build your own menu!
{
CoordMode, mouse, Screen
MouseMove, %mx1%, %my1%
if Item = Item8 ; About Radial menu
{
if ItemBounce = 1
Gosub, ItemBounceOnSel
MsgBox, 64, About, Title:%A_Tab%Radial menu v2`nAuthor:%A_Tab%Boris Mudrinic (Learning one on AHK forum)`nContact:%A_Tab%boris-mudrinic@net.hr`n`nLicence:`nFree for non-commercial use.`nFor commercial use, e-mail me please.`n`nIf you will use Radial menu in your free software,`nmention author's name and contact.
Return
}
else if Item = Item7 ; Runs Windows Explorer
{
if SoundOnSelect = 1
SoundPlay, *-1 ; plays simple beep.
Run, %A_WinDir%\explorer.exe
if ItemBounce = 1
Gosub, ItemBounceOnSel
Return
}
else if Item = Item6 ; Runs Notepad
{
if SoundOnSelect = 1
SoundPlay, *-1 ; plays simple beep.
Run, notepad
if ItemBounce = 1
Gosub, ItemBounceOnSel
Return
}
else if Item = Item5 ; Runs Calculator
{
if SoundOnSelect = 1
SoundPlay, *-1 ; plays simple beep.
Run, %A_WinDir%\system32\calc.exe
if ItemBounce = 1
Gosub, ItemBounceOnSel
Return
}
else
{
if ItemBounce = 1
Gosub, ItemBounceOnSel
MsgBox,, You selected:, %Item%,1
}
}
Return
RadialMenuClose:
PressedTime++
if not (GetKeyState("RButton","p"))
{
if (PressedTime < 7) ; if user holded RButton for less than 210ms ...
SendInput, {RButton} ; ... script will send normal RButton click
SetTimer, GetSelectedItem, off
SetTimer, RadialMenuClose, off
; Fade out effect
InitialTrans = 255
Loop, 17
{
Loop, %Number%
WinSet, Transparent, %InitialTrans%, Item%A_Index%
InitialTrans -= 15
Sleep, 25 ; change fade out speed if you wish
}
Loop, %Number%
Gui 9%A_index%: Hide
Return
}
Return
ItemBounceOnSel: ; bounce effect
Critical
WinGetPos, XBounce, YBounce,,, %Item%
SetTimer, RadialMenuClose, off
SetTimer, GetSelectedItem, off
SetWinDelay, 5 ; bounce speed
if Item = Item1
{
Loop, %Number%
{
if A_Index <= 4
YBounce -= 4 ; bounce lenght
Else
YBounce += 4
WinMove, %Item%, , %XBounce%, %YBounce%
}
}
else if Item = Item2
{
Loop, %Number%
{
if A_Index <= 4
{
XBounce += 4
YBounce -= 4
}
Else
{
XBounce -= 4
YBounce += 4
}
WinMove, %Item%, , %XBounce%, %YBounce%
}
}
else if Item = Item3
{
Loop, %Number%
{
if A_Index <= 4
XBounce += 4
Else
XBounce -= 4
WinMove, %Item%, , %XBounce%, %YBounce%
}
}
else if Item = Item4
{
Loop, %Number%
{
if A_Index <= 4
{
XBounce += 4
YBounce += 4
}
Else
{
XBounce -= 4
YBounce -= 4
}
WinMove, %Item%, , %XBounce%, %YBounce%
}
}
else if Item = Item5
{
Loop, %Number%
{
if A_Index <= 4
YBounce += 4
Else
YBounce -= 4
WinMove, %Item%, , %XBounce%, %YBounce%
}
}
else if Item = Item6
{
Loop, %Number%
{
if A_Index <= 4
{
XBounce -= 4
YBounce += 4
}
Else
{
XBounce += 4
YBounce -= 4
}
WinMove, %Item%, , %XBounce%, %YBounce%
}
}
else if Item = Item7
{
Loop, %Number%
{
if A_Index <= 4
XBounce -= 4
Else
XBounce += 4
WinMove, %Item%, , %XBounce%, %YBounce%
}
}
else if Item = Item8
{
Loop, %Number%
{
if A_Index <= 4
{
XBounce -= 4
YBounce -= 4
}
Else
{
XBounce += 4
YBounce += 4
}
WinMove, %Item%, , %XBounce%, %YBounce%
}
}
SetWinDelay, 100 ; default
SetTimer, GetSelectedItem, on
SetTimer, RadialMenuClose, on
Return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ExitApp
Pause::
Suspend
Pause,,1
return
Escape::
Suspend
ExitApp
Return
F7::Reload
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;