AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

RADIAL MENU scripts - updates - 29.01.2012.
Goto page Previous  1, 2, 3 ... 12, 13, 14 ... 46, 47, 48  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
bmn_
Guest





PostPosted: Sun Mar 07, 2010 6:46 pm    Post subject: Reply with quote

hey, is there a way to disable RM for some time by mysub? cause sometimes i want to drag things around with right mouse (then it shows some options what do do) but at the same time i like rm on right mouse
Back to top
bmn_
Guest





PostPosted: Sun Mar 07, 2010 7:37 pm    Post subject: Reply with quote

as you wanted us to work on that issue with disapearing icons:

when showing background make it disable
e.g.
when showing Menu background
Code:
Gui, 99: Show, NA x%RMBX% y%RMBY%,RMBackground
add
Code:
Gui, 99: +Disabled

all in all it should be gui 99, 97, 96, is that all?

also added posibility to use 2 different show keys because i want to drag with right mouse (=> middle mouse to show) but also use touchpad.
on interest just ask
Back to top
LiquidGravity



Joined: 26 Jan 2009
Posts: 145

PostPosted: Sun Mar 07, 2010 7:50 pm    Post subject: Reply with quote

Boris, I think this is an awesome application. Please keep up the good work!

I find it very cool. Like I said before my only suggestions are to make more modular. I (and others I'm sure) would like to create some skins for it but with out skins and effects being modular its harder for people to apply them.

When you have decided you have a locked solid version we must suggest to Lifehacker and other customizing sites. They will all go crazy for it.
Back to top
View user's profile Send private message
bmn_
Guest





PostPosted: Sun Mar 07, 2010 8:14 pm    Post subject: Reply with quote

i think skins itself is difficult. everyone wants to have other aplications/functions. But maybe i will make a skineditor where people can add there code and others can use it without having to getinto the inis.
Back to top
bmn_
Guest





PostPosted: Sun Mar 07, 2010 9:43 pm    Post subject: Reply with quote

so for everyone who is anoyed by the hiding icons, or who just wants to be able to set 2 different show keys (second one will be set by RMShowHotkey2 = in the ini)

Code:


;===WARNING=========================================================================
; You are not allowed to look at and study the code and solutions/ideas in it,
; if you haven't agreed on all licence and authorship terms!
;===================================================================================

; If somebody wants to undertake further RM development, or suggest collaborative development, contact me.
; (Licence can be changed, including my minimal share in authorship clause)




;===Description=========================================================================
/*
RADIAL MENU v3.1708
Author:                  Boris Mudrinic (Learning one on AHK forum)
Contact:               boris-mudrinic@net.hr
Thanks:                 Chris Mallett, Tic (Tariq Porter), TomXIII, Patchen, SpeedY, Preston, and others...
AHK forum location:     http://www.autohotkey.com/forum/viewtopic.php?p=308352#308352

SHORT DESCRIPTION:
This script shows radial menu around your mouse pointer  when you press & hold specified button (RButton by default) for specified amount of time
(220 miliseconds by default). Release RButton above subitem to select it, or anywhere else to hide menu.
Item that has its own submenu is marked with two tiny stars near the top of the button. Click it with LButton (by default) to show its submenu.
Release RButton above subitem to select it, or anywhere else to hide submenu and main menu. Click with LButton in the center of showed submenu to close it.
Note that Radial menu is displayed only while your hotkey is down (RButton by default)

You can  customize RM to fit your needs by editing .ini files. (RM means radial menu.)

LICENCE:
Expression "Radial menu" here means Radial menu code and program itself, and any part of whole Radial menu package except files not created
by me; Gdip.ahk and some files mentioned in Image sources.txt and Sound sources.txt. As the author of Radial menu, I'm reserving all my rights,
but I'm temporary allowing that Radial menu can use any person that agrees on all terms in this licence.

Radial menu is free for non-commercial, personal use under some conditions.

You are not allowed to (re)distribute, sell or rent Radial menu, or use it on any commercial way, or have any profit from it in general, without my
written permission! You are also not allowed to have any profit from giving information where Radial menu can be obtained. I'm not responsible for
any damages arising from the use of Radial menu. Everyone is encouraged to improve Radial menu, but no matter how much anyone improve it,
my share in authorship will always be minimum 81%. Everyone can create another program based on Radial menu (derived program) under
following conditions: 1) my share in authorship in derived program will always be minimum 51%, 2) author of derived program has to mention my
name and contact in it and mark me as the major author, 3) he has to inform me about his program, 4) he can not (re)distribute, sell or rent it
without my written permission! This licence is only temporary, I can change it whenever I want, on any way I want. On issues not mentioned in this
licence Croatian laws apply. In the case of litigation, Croatian laws and language apply and Municipal court in Zagreb has jurisdiction. If you don't
agree on all terms in this licence, you must exit Radial menu and delete it from computer and any other device that can store electronic data
immediately! (You are even not allowed just to take a look at Radial menu, especially the codes).
If you are unsure what you are allowed or not allowed to do, contact me.

HOW DOES IT WORK? It simply draws carefully positioned & shaped GUIs and threats them as menu items.
Menu items are identified by GUI's title. GUI's titles are RMItem1, RMItem2 etc.


DEFAULT HOTKEYS:
RButton      ; press & hold to show main menu after %ShowDelay% miliseconds.
LButton      ; press to show/hide submenus.


CODE STRUCTURE:
- Warning
- Description
- Auto-execute start
- Functions
- Load settings
- Prepare menu
- Main menu show Hotkey
- Submenu show Hotkey
- Subroutines
*/

;===Auto-execute start==================================================================
SetBatchLines, -1
#SingleInstance force
CoordMode, mouse, Screen
OnExit, Exit
SetTitleMatchMode, 3        ; exact match

Menu, Tray, Icon, %A_ScriptDir%\RMdata\RMTrayIcon.ico
Menu, Tray, Tip, Radial menu v3.17

AboutRadialMenu =
(
Radial menu v3.17
Author:%A_Tab%Boris Mudrinic (Learning one on AHK forum)
Contact:%A_Tab%boris-mudrinic@net.hr
Thanks:%A_Tab%Chris Mallett, Tic (Tariq Porter), TomXIII, Patchen, SpeedY, Preston, and others...

Licence:
Expression "Radial menu" here means Radial menu code and program itself, and any part of whole Radial menu package except files not created
by me; Gdip.ahk and some files mentioned in Image sources.txt and Sound sources.txt. As the author of Radial menu, I'm reserving all my rights,
but I'm temporary allowing that Radial menu can use any person that agrees on all terms in this licence.

Radial menu is free for non-commercial, personal use under some conditions.

You are not allowed to (re)distribute, sell or rent Radial menu, or use it on any commercial way, or have any profit from it in general, without my
written permission! You are also not allowed to have any profit from giving information where Radial menu can be obtained. I'm not responsible for
any damages arising from the use of Radial menu. Everyone is encouraged to improve Radial menu, but no matter how much anyone improve it,
my share in authorship will always be minimum 81`%. Everyone can create another program based on Radial menu (derived program) under
following conditions: 1) my share in authorship in derived program will always be minimum 51`%, 2) author of derived program has to mention my
name and contact in it and mark me as the major author, 3) he has to inform me about his program, 4) he can not (re)distribute, sell or rent it
without my written permission! This licence is only temporary, I can change it whenever I want, on any way I want. On issues not mentioned in this
licence Croatian laws apply. In the case of litigation, Croatian laws and language apply and Municipal court in Zagreb has jurisdiction. If you don't
agree on all terms in this licence, you must exit Radial menu and delete it from computer and any other device that can store electronic data
immediately! (You are even not allowed just to take a look at Radial menu, especially the codes).
If you are unsure what you are allowed or not allowed to do, contact me.
)

;===LicenceAgreement===
IniRead, LicenceAgreement, %A_ScriptDir%\RM settings.ini, General, LicenceAgreement
if !(LicenceAgreement = 1)
{
   MsgBox,324, Welcome to Radial menu, %AboutRadialMenu%`n`nDo you agree on all terms mentioned above?`n(If you agree, this message will never show again.)
   IfMsgBox, Yes
   IniWrite, 1, %A_ScriptDir%\RM settings.ini, General, LicenceAgreement
   Else
   {
      MsgBox, 48, Radial menu - if you do not agree on all licence terms..., Please delete whole Radial menu package from computer and any other device that can store electronic data immediately!`nYou are even not allowed just to take a look at any file in Radial menu package!      ; auto delete is too aggressive
      ExitApp
   }
}


;===Start loading RM===
;Progress, m2 b fs13 zh0 WMn700, `nPlease wait...`n

;===Set script's process priority===
IniRead, RMProcessPriority , %A_ScriptDir%\RM settings.ini, General, RMProcessPriority
if (RMProcessPriority = "AboveNormal" or RMProcessPriority = "High")
Process, Priority,, %RMProcessPriority%
Else
Process, Priority,, Normal

;===Run Sound players===
Run, RMSoundOnShow.ahk, %A_ScriptDir%\RMdata\SoundPlayers
Run, RMSoundOnSubShow.ahk, %A_ScriptDir%\RMdata\SoundPlayers
Run, RMSoundOnSubHide.ahk, %A_ScriptDir%\RMdata\SoundPlayers



;===Create shortcut===
IfNotExist, %A_ScriptDir%\Radial menu.lnk
{
   FileCreateShortcut, %A_ScriptDir%\Radial menu v3.17.ahk
   , %A_ScriptDir%\Radial menu.lnk,,,
   , %A_ScriptDir%\RMdata\RMv3Icon.ico 
}

;===Function to call when RM receives WM_COPYDATA message===
OnMessage(0x4a, "Receive_WM_COPYDATA")



;===Functions===========================================================================
#Include %A_ScriptDir%\RMdata\Gdip.ahk  ; by Tic (Thank you)

Send_WM_COPYDATA(ByRef StringToSend, ByRef TargetScriptTitle)
{
   VarSetCapacity(CopyDataStruct, 12, 0)
   NumPut(StrLen(StringToSend) + 1, CopyDataStruct, 4)
   NumPut(&StringToSend, CopyDataStruct, 8)
   Prev_DetectHiddenWindows := A_DetectHiddenWindows
   Prev_TitleMatchMode := A_TitleMatchMode
   DetectHiddenWindows On
   SetTitleMatchMode 3  ; 2 is original in AHK help file
   SendMessage, 0x4a, 0, &CopyDataStruct,, %TargetScriptTitle%
   DetectHiddenWindows %Prev_DetectHiddenWindows%
   SetTitleMatchMode %Prev_TitleMatchMode%
   return
}

Receive_WM_COPYDATA(wParam, lParam)
{
   Global CopyOfData
   StringAddress := NumGet(lParam + 8)
   StringLength := DllCall("lstrlen", UInt, StringAddress)
   VarSetCapacity(CopyOfData, StringLength)
   DllCall("lstrcpy", "str", CopyOfData, "uint", StringAddress)
   Gosub, Instructions
   Return
}

ImprovedRun(FullPath)      ;  by Learning one   v1.2
{
   While (SubStr(FullPath,1,1) = A_Tab or SubStr(FullPath,1,1) = A_Space)
   StringTrimLeft, FullPath, FullPath, 1
   Transform, FullPath, Deref, %FullPath%   ; suggestion by Maxmax14 (Thanks!)
   if (RegExMatch(FullPath, "i)^(properties|find|explore|edit|open|print)\s*([a-z]{1}:\\|::\{)", SysVerb) = 1)   ; with SysVerb
   {
      StringReplace, SysVerb, SysVerb, %A_Space%, , all
      StringTrimRight, SysVerb, SysVerb, 3
      SysVerbLength := StrLen(SysVerb)   
      StringTrimLeft, FullPath, FullPath, SysVerbLength+1
      While (SubStr(FullPath,1,1) = A_Space)
      StringTrimLeft, FullPath, FullPath, 1
      if (SubStr(FullPath, 1, 3) = "::{")   ; CLSID folders
      {
         Run, %SysVerb% %FullPath%
         Return
      }
      SplitPath, FullPath, file, dir
      While (SubStr(file,0,1) = A_Space)
      StringTrimRight, file, file, 1
      if file =
      {
         Run, %SysVerb%, %dir%
         Return
      }
      FileWithSysVerb := SysVerb A_Space file
      Run, %FileWithSysVerb%, %dir%
      Return
   }
   Else      ; without SysVerb
   {
      if (SubStr(FullPath, 1, 3) = "::{")   ; CLSID folders
      {
         Run, %FullPath%
         Return
      }
      if FullPath contains "   
      {                         
         Run, %FullPath%
         Return
      }
     
      SplitPath, FullPath, file, dir
      While (SubStr(file,1,1) = A_Space)
      StringTrimLeft, file, file, 1
      While (SubStr(dir,1,1) = A_Space)
      StringTrimLeft, dir, dir, 1
      if file =
      {
         Run, %dir%
         Return
      }
      if dir =
      {
         Run, %file%
         Return
      }
      Run, %file%, %dir%
      Return
   }
}

ScaleTransform(Value, InputScaleMax=255, OutputScaleMax=1)  ; by Learning one
{   
   Return Value*OutputScaleMax/InputScaleMax    ; 255 --> 1
}

IsInCircle(Xstart, Ystart, Xend, Yend, radius)   ; by Learning one (adapted Pythagoras' theorem)
{
   a := Abs(Xend-Xstart), b := Abs(Yend-Ystart), c := Sqrt(a*a+b*b)
   Return c<radius ? 1:0   ; if released in circle returns 1, else 0
}




;===Load settings=======================================================================

;===Count items in main menu - MMTotalButtons===
Loop, 40        ; 39 max
{
   IniRead, I%A_Index%Name, %A_ScriptDir%\RM settings.ini, Item%A_Index%, Name
   if  I%A_Index%Name = ERROR   ; item Section and Key does not exist at all
   {
      MMTotalButtons := A_Index - 1 
      Break
   }
   Else if (I%A_Index%Name = "" )     ;  Blank name
   {
      IniRead, I%A_Index%Icon, %A_ScriptDir%\RM settings.ini, Item%A_Index%, Icon
      if I%A_Index%Icon =   ;  Blank Icon
      {
         MMTotalButtons := A_Index - 1        ; Auto set MMTotalButtons
         Break
      }
   }
}
if MMTotalButtons =
MMTotalButtons = 39
LastMMItem := MMTotalButtons    ; last main menu item


;===General===
IniRead, RMShowHotkey, %A_ScriptDir%\RM settings.ini, General, RMShowHotkey
IniRead, RMShowHotkey2, %A_ScriptDir%\RM settings.ini, General, RMShowHotkey2
IniRead, ShowDelay, %A_ScriptDir%\RM settings.ini, General, ShowDelay
IniRead, RSMShowHotkey, %A_ScriptDir%\RM settings.ini, General, RSMShowHotkey

IniRead, SecondRingRadius  , %A_ScriptDir%\RM settings.ini, General, SecondRingRadius
 
IniRead, MenuBackground, %A_ScriptDir%\RM settings.ini, General, MenuBackground
IniRead, MenuBackgroundTrans, %A_ScriptDir%\RM settings.ini, General, MenuBackgroundTrans
IniRead, MenuBackgroundWidth, %A_ScriptDir%\RM settings.ini, General, MenuBackgroundWidth
IniRead, MenuBackgroundHeight, %A_ScriptDir%\RM settings.ini, General, MenuBackgroundHeight

IniRead, ButtonBackground, %A_ScriptDir%\RM settings.ini, General, ButtonBackground
IniRead, ButtonSize, %A_ScriptDir%\RM settings.ini, General, ButtonSize
IniRead, ButtonTrans, %A_ScriptDir%\RM settings.ini, General, ButtonTrans
IniRead, ButtonPositioning , %A_ScriptDir%\RM settings.ini, General, ButtonPositioning
IniRead, ShadowHeight, %A_ScriptDir%\RM settings.ini, General, ShadowHeight

IniRead, ButtonForeground , %A_ScriptDir%\RM settings.ini, General, ButtonForeground
IniRead, ButtonForegroundTrans , %A_ScriptDir%\RM settings.ini, General, ButtonForegroundTrans

IniRead, GenIconShrink, %A_ScriptDir%\RM settings.ini, General, GenIconShrink
IniRead, IconTrans, %A_ScriptDir%\RM settings.ini, General, IconTrans

IniRead, Sounds, %A_ScriptDir%\RM settings.ini, General, Sounds
IniRead, SoundOnShow, %A_ScriptDir%\RM settings.ini, General, SoundOnShow
IniRead, SoundOnHover, %A_ScriptDir%\RM settings.ini, General, SoundOnHover
IniRead, SoundOnSelect, %A_ScriptDir%\RM settings.ini, General, SoundOnSelect
IniRead, SoundOnHide, %A_ScriptDir%\RM settings.ini, General, SoundOnHide
IniRead, SoundOnSubShow, %A_ScriptDir%\RM settings.ini, General, SoundOnSubShow
IniRead, SoundOnSubHide, %A_ScriptDir%\RM settings.ini, General, SoundOnSubHide

IniRead, SelectEffect , %A_ScriptDir%\RM settings.ini, General, SelectEffect
IniRead, DestroyDelay, %A_ScriptDir%\RM settings.ini, General, DestroyDelay
IniRead, RMCloseDirection, %A_ScriptDir%\RM settings.ini, General, RMCloseDirection

IniRead, Font, %A_ScriptDir%\RM settings.ini, General, Font
IniRead, TextSize, %A_ScriptDir%\RM settings.ini, General, TextSize
IniRead, TextColor, %A_ScriptDir%\RM settings.ini, General, TextColor
IniRead, TextAntialias, %A_ScriptDir%\RM settings.ini, General, TextAntialias
IniRead, TextTrans, %A_ScriptDir%\RM settings.ini, General, TextTrans

IniRead, Shadow, %A_ScriptDir%\RM settings.ini, General, Shadow
IniRead, ShadowColor, %A_ScriptDir%\RM settings.ini, General, ShadowColor
IniRead, ShadowOffset, %A_ScriptDir%\RM settings.ini, General, ShadowOffset

IniRead, MinWheelRadius, %A_ScriptDir%\RM settings.ini, General, MinWheelRadius
IniRead, ItemGlowType, %A_ScriptDir%\RM settings.ini, General, ItemGlowType

IniRead, SubMenuSBackground , %A_ScriptDir%\RM settings.ini, General, SubMenuSBackground
IniRead, SubMenuSSizeTune , %A_ScriptDir%\RM settings.ini, General, SubMenuSSizeTune

IniRead, SubMenuLBackground , %A_ScriptDir%\RM settings.ini, General, SubMenuLBackground
IniRead, SubMenuLSizeTune , %A_ScriptDir%\RM settings.ini, General, SubMenuLSizeTune

IniRead, SubMenuBackTrans , %A_ScriptDir%\RM settings.ini, General, SubMenuBackTrans

IniRead, AutoSubmenuMarking , %A_ScriptDir%\RM settings.ini, General, AutoSubmenuMarking
 


;===Default===
if ButtonTrans not between 1 and 255
ButtonTrans = 255

;===Items===
Loop, %MMTotalButtons%
{
   ;=== Main menu items===
   IniRead, I%A_Index%Icon, %A_ScriptDir%\RM settings.ini, Item%A_Index%, Icon
   IniRead, I%A_Index%Action, %A_ScriptDir%\RM settings.ini, Item%A_Index%, Action
   IniRead, I%A_Index%IconShrink, %A_ScriptDir%\RM settings.ini, Item%A_Index%, IconShrink
   IniRead, I%A_Index%Tooltip, %A_ScriptDir%\RM settings.ini, Item%A_Index%, Tooltip        ; Tooltips are TomXIII's idea (Thanks!)
   IniRead, I%A_Index%SpecialButtonBack , %A_ScriptDir%\RM settings.ini, Item%A_Index%, SpecialButtonBack
   
   IniRead, I%A_Index%ItemTransparency , %A_ScriptDir%\RM settings.ini, Item%A_Index%, ItemTransparency
   if (I%A_Index%ItemTransparency = "" or I%A_Index%ItemTransparency = "error")
   I%A_Index%ItemTransparency := ButtonTrans
   
   IniRead, I%A_Index%Child , %A_ScriptDir%\RM settings.ini, Item%A_Index%, Child
   
   ;===load submenu items and define submenus===
   if (FileExist(A_ScriptDir "\Submenus\" I%A_Index%Child ".ini") = "" or I%A_Index%Name = "Separator") ; submenu is not defined | Separator can't have child
   I%A_Index%Child =
   
   if !(I%A_Index%Child = "" or I%A_Index%Child = "error")      ; load submenu items
   {
      CurMMItemName = I%A_Index%Child       ; Current Main menu item's name
      CurChild := I%A_Index%Child           ; Current Main menu item's child value
         
      Loop, 19        ; 19 items per one submenu max
      {
         LastMMItem += 1    ; begins from last item in main menu!
         IniRead, I%LastMMItem%Name, %A_ScriptDir%\Submenus\%CurChild%.ini, Item%A_Index%, Name
         if  I%LastMMItem%Name = ERROR   ; item Section and Key does not exist at all
         {
            LastMMItem -= 1 
            Break
         }
         Else if (I%LastMMItem%Name = "")     ;  Blank name
         {
            IniRead, I%LastMMItem%Icon, %A_ScriptDir%\Submenus\%CurChild%.ini, Item%A_Index%, Icon
            if I%LastMMItem%Icon =   ;  Blank Icon
            {
               LastMMItem -= 1       
               Break
            }
         }
         
         if A_Index = 1
         FirstSubItem := LastMMItem
         
         IniRead, I%LastMMItem%Icon, %A_ScriptDir%\Submenus\%CurChild%.ini, Item%A_Index%, Icon
         IniRead, I%LastMMItem%Action, %A_ScriptDir%\Submenus\%CurChild%.ini, Item%A_Index%, Action
         IniRead, I%LastMMItem%IconShrink, %A_ScriptDir%\Submenus\%CurChild%.ini, Item%A_Index%, IconShrink
         IniRead, I%LastMMItem%Tooltip, %A_ScriptDir%\Submenus\%CurChild%.ini, Item%A_Index%, Tooltip        ; Tooltips are TomXIII's idea (Thanks!)
         IniRead, I%LastMMItem%SpecialButtonBack , %A_ScriptDir%\Submenus\%CurChild%.ini, Item%A_Index%, SpecialButtonBack
         IniRead, I%LastMMItem%ItemTransparency , %A_ScriptDir%\Submenus\%CurChild%.ini, Item%A_Index%, ItemTransparency
         
         if  I%LastMMItem%Name = separator
         {
            I%LastMMItem%Name =
            I%LastMMItem%Icon =
            I%LastMMItem%SpecialButtonBack = separator
         }
           
         if (I%LastMMItem%ItemTransparency = "" or I%LastMMItem%ItemTransparency = "error")
         I%LastMMItem%ItemTransparency := ButtonTrans
         
         if (I%LastMMItem%IconShrink = "" or I%LastMMItem%IconShrink = "ERROR")
         I%LastMMItem%IconShrink = %GenIconShrink%
     
         LastSubItem := LastMMItem
      }
     
      %CurMMItemName% := FirstSubItem "," LastSubItem "," CurChild  ; stores first and last item number and submenu name
  }

if LastSubItem =
TotalButtons := MMTotalButtons
Else
TotalButtons := LastSubItem     ; TotalButtons = all items in main menu + all items in all submenus
}

;===Limits, defaults, adjustments===
if !(ButtonPositioning = "dynamic")        ; suggestion by occasional ahk'er (Thanks!)
ButtonPositioning = static
if MenuBackgroundTrans  not between 0 and 255
MenuBackgroundTrans = 255
if (ShadowHeight = "" or ShadowHeight = "error")
ShadowHeight = 0
if (ItemGlowType = "" or ItemGlowType = "error" or FileExist(A_ScriptDir "\RMdata\" ItemGlowType) = "" )
ItemGlowType = General glow.png

;===Ring radius===
pi :=4*Atan(1)
PiDiv180 := pi/180
picRadius := ButtonSize/2

if SecondRingRadius not between 0 and 3
SecondRingRadius = 1
SecondRingRadius += 10

FirstRingRadius = 6
if SecondRingRadius = 13
ThirdRingRadius = 20
Else if SecondRingRadius = 12
ThirdRingRadius = 18
Else if SecondRingRadius = 11
ThirdRingRadius = 16
Else if SecondRingRadius = 10
ThirdRingRadius = 14

FirstRingRadius :=  ButtonSize/(2*Sin(pi/FirstRingRadius))     ; Auto WheelRadius formula by TomXIII (Thanks!)
SecondRingRadius := ButtonSize/(2*Sin(pi/SecondRingRadius))    ; Auto WheelRadius formula by TomXIII (Thanks!)
ThirdRingRadius := ButtonSize/(2*Sin(pi/ThirdRingRadius))      ; Auto WheelRadius formula by TomXIII (Thanks!)

if (FirstRingRadius < MinWheelRadius)
FirstRingRadius := MinWheelRadius

if (ShadowOffset > 2)       ; limit
ShadowOffset = 2
if (ButtonSize > 130)       ; limit
ButtonSize = 130
if (SubMenuBackTrans = "" or SubMenuBackTrans = "error")
SubMenuBackTrans = 255


;===GDI+ Matrix===  ; red, green, blue, alpha, dummy
if IconTrans not between 0 and 255
IconTrans = 255
IconTrans := ScaleTransform(IconTrans)
IconTransMatrix =
(
[1,0,0,0,0]
[0,1,0,0,0]
[0,0,1,0,0]
[0,0,0,%IconTrans%,0]
[0,0,0,0,1]
)

if ButtonForegroundTrans not between 0 and 255
ButtonForegroundTrans = 255
ButtonForegroundTrans := ScaleTransform(ButtonForegroundTrans)
ButtonForegroundMatrix =
(
[1,0,0,0,0]
[0,1,0,0,0]
[0,0,1,0,0]
[0,0,0,%ButtonForegroundTrans%,0]
[0,0,0,0,1]
)


;===Other stuff===
Loop, %MMTotalButtons%        ; set separators
{
   
   IniRead, I%A_Index%Name, %A_ScriptDir%\RM settings.ini, Item%A_Index%, Name
   if  I%A_Index%Name = separator
   {
      I%A_Index%Name =
      I%A_Index%Icon =
      I%A_Index%SpecialButtonBack = separator
   }
}

if TextAntialias = 1
TextRen = 4
if TextAntialias = 0
TextRen = 1
if DestroyDelay = 0
RMCloseDirection  = CW      ; performs better

if Sounds = 0   ; sounds off
{
   SoundOnShow =
   SoundOnHover =
   SoundOnSelect =
   SoundOnHide =
   SoundOnSubShow =
   SoundOnSubHide =
}

Menu, tray, NoStandard   
Menu, tray, add, About, AboutRM
Menu, tray, add, Open RM folder, OpenRMF
Menu, tray, add, Edit MySubroutines, EditMySubroutines
Menu, tray, add, Settings, RMSettings
Menu, tray, add, Reload, ReloadRM
Menu, tray, add, Exit, ExitRM

;===Set item's tooltip if not specified===
Loop, %TotalButtons%
{
   if I%A_Index%Tooltip =       ; custom tooltip (if specified) has precedence over auto tooltip (item's name or icon's file name without extension)
   {
      if I%A_Index%Name =
      {
         I%A_Index%Tooltip := I%A_Index%icon
         StringTrimRight, I%A_Index%Tooltip, I%A_Index%Tooltip, 4   ; remove extension
      }
      Else
      {
         I%A_Index%Tooltip := I%A_Index%Name
         CurLoop := A_Index
         Loop   ; Auto trim spaces inside tooltip
         {
            IfInString, I%CurLoop%Tooltip, %A_Space%%A_Space%
            StringReplace, I%CurLoop%Tooltip, I%CurLoop%Tooltip, %A_Space%%A_Space%, %A_Space%, All
            Else
            Break
         }
      }
   }
}

;===Enable multi-row tooltips `n ===
Loop, %TotalButtons%
{
   TransformTT := I%A_Index%Tooltip
   Transform, I%A_Index%Tooltip, Deref, %TransformTT%
}

;===Set IconShrink if not specified===
Loop, %MMTotalButtons%
{
   if (I%A_Index%IconShrink = "" or I%A_Index%IconShrink = "ERROR")
   I%A_Index%IconShrink = %GenIconShrink%
}



;===Prepare menu=======================================================================
Gdip_Startup()

;===Prepare small Sub menu background===     ; Gui, 97 is Radial sub menu's small background
Gui, 97: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs +Disabled
Gui, 97: Show, hide               ; Gui, 97 is Radial sub menu's small background
hwnd1 := WinExist()

SubMenuS := FirstRingRadius*2+ButtonSize
if !(SubMenuSSizeTune = "")
SubMenuS += SubMenuSSizeTune*2

CurMenuBackground = %A_ScriptDir%\Images\Menu backgrounds\%SubMenuSBackground%
pBitmap := Gdip_CreateBitmapFromFile(CurMenuBackground)
RMBWidth := Gdip_GetImageWidth(pBitmap), RMBHeight := Gdip_GetImageHeight(pBitmap)
hbm := CreateDIBSection(RMBWidth, RMBHeight)
hdc := CreateCompatibleDC()
obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc)
Gdip_SetInterpolationMode(G, 7)

if (SubMenuS > RMBWidth)         ; automatic & limit
SubMenuS := RMBWidth
if (SubMenuS > RMBHeight)      ; automatic & limit
SubMenuS := RMBHeight

Gdip_DrawImage(G, pBitmap, 0, 0, SubMenuS, SubMenuS, 0, 0, RMBWidth, RMBHeight)
UpdateLayeredWindow(hwnd1, hdc, 0, 0, RMBWidth, RMBHeight, SubMenuBackTrans)

SelectObject(hdc, obm)
DeleteObject(hbm)
DeleteDC(hdc)
Gdip_DeleteGraphics(G)
Gdip_DisposeImage(pBitmap)


;===Prepare large Sub menu background===     ; Gui, 96 is Radial sub menu's large background
Gui, 96: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs +Disabled
Gui, 96: Show, hide               ; Gui, 96 is Radial sub menu's large background
hwnd1 := WinExist()

SubMenuL := SecondRingRadius*2+ButtonSize
if !(SubMenuLSizeTune = "")
SubMenuL += SubMenuLSizeTune*2

CurMenuBackground = %A_ScriptDir%\Images\Menu backgrounds\%SubMenuLBackground%
pBitmap := Gdip_CreateBitmapFromFile(CurMenuBackground)
RMBWidth := Gdip_GetImageWidth(pBitmap), RMBHeight := Gdip_GetImageHeight(pBitmap)
hbm := CreateDIBSection(RMBWidth, RMBHeight)
hdc := CreateCompatibleDC()
obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc)
Gdip_SetInterpolationMode(G, 7)

if (SubMenuL > RMBWidth)         ; automatic & limit
SubMenuL := RMBWidth
if (SubMenuL > RMBHeight)      ; automatic & limit
SubMenuL := RMBHeight

Gdip_DrawImage(G, pBitmap, 0, 0, SubMenuL, SubMenuL, 0, 0, RMBWidth, RMBHeight)
UpdateLayeredWindow(hwnd1, hdc, 0, 0, RMBWidth, RMBHeight, SubMenuBackTrans)

SelectObject(hdc, obm)
DeleteObject(hbm)
DeleteDC(hdc)
Gdip_DeleteGraphics(G)
Gdip_DisposeImage(pBitmap)


;===Prepare Main menu background===     ; Gui, 99 is Radial Main menu's background
Gui, 99: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs +Disabled
Gui, 99: Show, hide
hwnd1 := WinExist()
 
CurMenuBackground = %A_ScriptDir%\Images\Menu backgrounds\%MenuBackground%
pBitmap := Gdip_CreateBitmapFromFile(CurMenuBackground)
RMBWidth := Gdip_GetImageWidth(pBitmap), RMBHeight := Gdip_GetImageHeight(pBitmap)
hbm := CreateDIBSection(RMBWidth, RMBHeight)
hdc := CreateCompatibleDC()
obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc)
Gdip_SetInterpolationMode(G, 7)

if MenuBackgroundWidth =
MenuBackgroundWidth := RMBWidth
if MenuBackgroundHeight =
MenuBackgroundHeight := RMBHeight

if (MenuBackgroundWidth > RMBWidth)         ; automatic & limit
MenuBackgroundWidth := RMBWidth
if (MenuBackgroundHeight > RMBHeight)      ; automatic & limit
MenuBackgroundHeight := RMBWidth

Gdip_DrawImage(G, pBitmap, 0, 0, MenuBackgroundWidth, MenuBackgroundHeight, 0, 0, RMBWidth, RMBHeight)
UpdateLayeredWindow(hwnd1, hdc, 0, 0, RMBWidth, RMBHeight, MenuBackgroundTrans)

SelectObject(hdc, obm)
DeleteObject(hbm)
DeleteDC(hdc)
Gdip_DeleteGraphics(G)
Gdip_DisposeImage(pBitmap)


;===Prepare MouseOnItem===     ; Gui, 98 is MouseOnItem glow
Gui, 98: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
Gui, 98: Show, hide, MouseOnItem
hwnd1 := WinExist()
 
MouseOnItemImage = %A_ScriptDir%\RMdata\%ItemGlowType%
pBitmap := Gdip_CreateBitmapFromFile(MouseOnItemImage)

Width := Gdip_GetImageWidth(pBitmap), Height := Gdip_GetImageHeight(pBitmap)

hbm := CreateDIBSection(Width, Height)
hdc := CreateCompatibleDC()
obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc)
Gdip_SetInterpolationMode(G, 7)
Gdip_DrawImage(G, pBitmap, 0, 0, ButtonSize, ButtonSize, 0, 0, Width, Width)
UpdateLayeredWindow(hwnd1, hdc, 0, 0, ButtonSize, ButtonSize)
SelectObject(hdc, obm)
DeleteObject(hbm)
DeleteDC(hdc)
Gdip_DeleteGraphics(G)
Gdip_DisposeImage(pBitmap)


;===Prepare buttons===
Loop, %TotalButtons%
{   
   Gui, %A_Index%: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
   Gui, %A_Index%: Show, hide x%A_Index% y%A_Index% w%ButtonSize% h%ButtonSize%, RMItem%A_Index%
   
   ;===Gdi+ prepare===
   hwnd1 := WinExist()
   hbm := CreateDIBSection(ButtonSize, ButtonSize)
   hdc := CreateCompatibleDC()
   obm := SelectObject(hdc, hbm)
   G := Gdip_GraphicsFromHDC(hdc)
   Gdip_SetInterpolationMode(G, 7)

   ;===CreateBitmapFromFile===
   
   ;=Background=
   if  (I%A_Index%SpecialButtonBack  = "" or I%A_Index%SpecialButtonBack  = "ERROR")        ; blank or error
   CurItemBackground = %A_ScriptDir%\Images\Item backgrounds\%ButtonBackground%
   Else if (I%A_Index%SpecialButtonBack  = "no background")                                 ; no background
   CurItemBackground := A_ScriptDir "\RMdata\no background.png"
   Else if (I%A_Index%SpecialButtonBack  = "separator")                                     ; separator
   CurItemBackground := A_ScriptDir "\RMdata\separator.png"
   Else                                                                                     ; else
   CurItemBackground := A_ScriptDir "\Images\Item backgrounds\" I%A_Index%SpecialButtonBack
   
   pBitmapBackground := Gdip_CreateBitmapFromFile(CurItemBackground)
   
   ;=Icon=
   CurIcon := A_ScriptDir "\Images\Icons\" I%A_Index%Icon
   pBitmapIcon := Gdip_CreateBitmapFromFile(CurIcon)


   ;===Prepare item background and icon===
   BackgroundWidth := Gdip_GetImageWidth(pBitmapBackground), BackgroundHeight := Gdip_GetImageHeight(pBitmapBackground)
   Gdip_DrawImage(G, pBitmapBackground, 0, 0, ButtonSize, ButtonSize, 0, 0, BackgroundWidth, BackgroundHeight)          ; Background
   
   tempShadowHeight := ShadowHeight/2
   if (I%A_Index%SpecialButtonBack = "no background")
   tempShadowHeight := 0
   
   CurISX := I%A_Index%IconShrink
   CurISY := I%A_Index%IconShrink - tempShadowHeight
   IconWidth := Gdip_GetImageWidth(pBitmapIcon), IconHeight := Gdip_GetImageHeight(pBitmapIcon)
   Gdip_DrawImage(G, pBitmapIcon, CurISX, CurISY, ButtonSize-CurISX*2, ButtonSize-CurISX*2, 0, 0, IconWidth, IconHeight, IconTransMatrix)       ; Icon

   ;===Set item Text name and position===
   CurIName := I%A_Index%Name
   
   ;===Prepare item's text and Shadow===   
   if  !(Shadow = 0)    ; Shadows on
   {
      Gdip_FontFamilyCreate(Font)
      Options = Center Vcenter cFE%ShadowColor% r%TextRen% s%TextSize%
       
      Loop       ; fix shadow displacement
      {
         ShadowMeasures := Gdip_TextToGraphics(G, CurIName, Options, Font, ButtonSize+ShadowOffset*2 , ButtonSize+ShadowOffset*2-ShadowHeight, 1)
         Loop, parse, ShadowMeasures, |       ; res 11.455078|15.000000|41.091797|29.097656|12|2
         {
            if A_Index = 3  ; Shadow's textW
            {
               if (A_LoopField > ButtonSize)  ; if textW > ButtonSize insert more spaces between words
               StringReplace, CurIName, CurIName, %A_Space%, %A_Space%%A_Space%, all
               Else
               Goto, ShadowFixed
            }
            Else if (A_Index > 3)
            Break
         }
         if (A_Index > 3)   ; too long single word --> for now, just ignore, don't fix
         {
            ; to do: auto split too long single word
            Break
         }
         
      }
      ShadowFixed:
     
      Gdip_TextToGraphics(G, CurIName, Options, Font, ButtonSize+ShadowOffset*2, ButtonSize+ShadowOffset*2-ShadowHeight)   ; Shadow
     
      Options = Center Vcenter c%TextTrans%%TextColor% r%TextRen% s%TextSize%
      Gdip_TextToGraphics(G, CurIName, Options, Font, ButtonSize, ButtonSize-ShadowHeight)      ; text
      Gdip_TextToGraphics(G, CurIName, Options, Font, ButtonSize, ButtonSize-ShadowHeight)      ; text
   }
   
   ;===Prepare just item's Text=== ; 2 times! I think that this gives better antialias results when TextAntialias = 1
   Else     ; Shadows off
   {
   Gdip_FontFamilyCreate(Font)
   Options = Center Vcenter c%TextTrans%%TextColor% r%TextRen% s%TextSize%
   Gdip_TextToGraphics(G, CurIName, Options, Font, ButtonSize, ButtonSize-ShadowHeight)
   Gdip_TextToGraphics(G, CurIName, Options, Font, ButtonSize, ButtonSize-ShadowHeight)
   }
   
   ;===Automatic submenu marking===         
   if (I%A_Index%Child <> "" and AutoSubmenuMarking = 1)
   {
      AutoSubMarkPosX := ButtonSize/2-7    ; 5 7 9 | 1 2 3
      if not (Shadow = 0)
      {
         AutoSubMarkPosX += 1
         Options = x%AutoSubMarkPosX% y3 cFE%ShadowColor% r%TextRen% s13
         Gdip_TextToGraphics(G, "**", Options, "Arial")
         AutoSubMarkPosX -= 1
      }
      Options = x%AutoSubMarkPosX% y2 c%TextTrans%%TextColor% r%TextRen% s13
      Gdip_TextToGraphics(G, "**", Options, "Arial")
      Gdip_TextToGraphics(G, "**", Options, "Arial")
   }
   
   ;===Item Foreground===   
   if (ButtonForeground and I%A_Index%SpecialButtonBack <> "Separator")
   {
      CurButtonForeground = %A_ScriptDir%\Images\Item backgrounds\%ButtonForeground%
      pBitmapForeground := Gdip_CreateBitmapFromFile(CurButtonForeground)
      ForegroundWidth := Gdip_GetImageWidth(pBitmapForeground), ForegroundHeight := Gdip_GetImageHeight(pBitmapForeground)
      Gdip_DrawImage(G, pBitmapForeground, 0, 0, ButtonSize, ButtonSize, 0, 0, ForegroundWidth, ForegroundHeight, ButtonForegroundMatrix)  ; Foreground
   }
   
   ;===Update button-window===
   if I%A_Index%ItemTransparency =
   UpdateLayeredWindow(hwnd1, hdc, 0, 0, ButtonSize, ButtonSize, ButtonTrans)
   Else
   UpdateLayeredWindow(hwnd1, hdc, 0, 0, ButtonSize, ButtonSize, I%A_Index%ItemTransparency)
   
   ;===Select and delete===
   SelectObject(hdc, obm)
   DeleteObject(hbm)
   DeleteDC(hdc)
   Gdip_DeleteGraphics(G)
   Gdip_DisposeImage(pBitmapBackground)
   Gdip_DisposeImage(pBitmapIcon)
   Gdip_DisposeImage(pBitmapForeground)
}

;===Security1===
If (RMShowHotkey = "LButton" and ShowDelay < 200) ; specifying this (especially ShowDelay = 0) + Radial menu shortcut in startup may be very dangerous.
{
  Security1 =
(
For your security, specifying
RMShowHotkey = LButton and ShowDelay lesser than 200
is not allowed.

Radial menu will automatically set:
RMShowHotkey = RButton
ShowDelay = 220
RSMShowHotkey =   LButton
)
   Progress, off
   MsgBox, 48, Radial menu - user security, %Security1%, 25
   RMShowHotkey = RButton
   ShowDelay = 220
   RSMShowHotkey = LButton
   
   IniWrite, %RMShowHotkey%, %A_ScriptDir%\RM settings.ini, General, RMShowHotkey
   IniWrite, %ShowDelay%, %A_ScriptDir%\RM settings.ini, General, ShowDelay
   IniWrite, %RSMShowHotkey%, %A_ScriptDir%\RM settings.ini, General, RSMShowHotkey
   Security1 =
}   

#Include *i %A_ScriptDir%\Utilities\BlackList.ahk
Hotkey, IfWinNotActive, ahk_group BlackList
Hotkey, %RMShowHotkey%, RMShowHotkey
Hotkey, %RMShowHotkey2%, RMShowHotkey2
Hotkey, IfWinNotActive

Hotkey, IfWinExist, RMItem1     ; at least 1 item in main menu must be shown to enable Radial submenu show Hotkey
Hotkey, %RSMShowHotkey%, RSMShowHotkey
Hotkey, IfWinExist

Progress, off
Return                                                      ;===Auto-execute ends here===


;===Main menu show Hotkey========================================================================
RMShowHotkey:
hk =
gosub next
return
RMShowHotkey2:
hk = 2
next:
IsSubmenuShown = 0
QuitRMShow = 0
deg = 0
MouseGetPos, mx1, my1, OrigWinID
WinGetTitle, OrigWinTitle, ahk_id %OrigWinID%
SetTimer, QuitRMShow, 20   

;===Prepare background postiton===
RMBX := mx1-MenuBackgroundWidth/2, RMBY := my1-MenuBackgroundHeight/2
Gui, 99: Show, hide x%RMBX% y%RMBY%, RMBackground        ; RMBackground
Gui, 99: +Disabled

;===Prepare buttons postitons===
Loop, %MMTotalButtons%
{   
   if A_Index between 1 and 6    ; 1. ring --> 6 buttons
   {
      if A_Index = 1
      deg =
      if (MMTotalButtons >= 6)
      CurRingTotalButtons = 6
      Else
      CurRingTotalButtons := MMTotalButtons
     
      WheelRadius := FirstRingRadius
      Gosub, CalcPos
   }
   Else if A_Index between 7 and 19   ; 2. ring --> 13 buttons
   {
      if A_Index = 7
      deg =
      if ButtonPositioning = static
      CurRingTotalButtons :=  13
      else
      {
         if (MMTotalButtons >= 19)
         CurRingTotalButtons = 13
         Else
         CurRingTotalButtons := MMTotalButtons - 6
      }
     
      WheelRadius := SecondRingRadius
      Gosub, CalcPos
   }
   Else if A_Index between 20 and 39    ; 3. ring --> 20 buttons
   {
      if A_Index = 20
      deg =
      if ButtonPositioning = static
      CurRingTotalButtons :=  20
      else
      CurRingTotalButtons := MMTotalButtons - 19
     
      WheelRadius := ThirdRingRadius
      Gosub, CalcPos
   }
   
   Gui, %A_Index%: Show, hide x%itemX% y%itemY%
   
   if QuitRMShow = 1
   Return
}
While (A_TimeSinceThisHotkey < ShowDelay)       ; ShowDelay sleep...
Sleep, 10

SetTimer, QuitRMShow, off
if QuitRMShow = 1
Return

;===If RMShowHotkey is still down - show prepared menu===
if SoundOnShow
{
   StringToSend = PlaySoundOnShow
   TargetScriptTitle = RMSoundOnShow
   Send_WM_COPYDATA(StringToSend, TargetScriptTitle)
}

Gui, 99: Show, NA x%RMBX% y%RMBY%,RMBackground      ; RMBackground
Gui, 99: +Disabled
Loop, %MMTotalButtons%                            ; RMItem (s)
Gui, %A_Index%: Show, NA     

SetTimer, ItemTooltip, 20
if SoundOnHover
SetTimer, SoundOnHover, 20

if(hk = 2)
   KeyWait, %RMShowHotkey2%, u      ; waits RMShowHotkey to be released
else
   KeyWait, %RMShowHotkey%, u      ; waits RMShowHotkey to be released
LastRMItemNum =

;===When user releases RMShowHotkey===
SetTimer, ItemTooltip, off
Gui, 98: Hide   ; MouseOnItem
SetTimer, SoundOnHover, off
ToolTip
; if problems with run occur (if Gui, 98 is still not hidden), put a short sleep here
MouseGetPos, , , WinID
WinGetTitle, WinTitle, ahk_id %WinID%
if WinTitle contains RMItem     ; RMShowHotkey released on item
{
   
   ; =situation when user has opened submenu but releases mouse on main menu item --> don't launch it.
   If (IsSubmenuShown = 1 and JustNum <= MMTotalButtons)     ; JustNum provided in ItemTooltip sub
   {
      if SoundOnHide
      {
         SoundPlay, %A_ScriptDir%\Sounds\%SoundOnHide%
         
         StringToSend = StopPlaying
         TargetScriptTitle = RMSoundOnShow
         Send_WM_COPYDATA(StringToSend, TargetScriptTitle)
      }
      Gosub, RadialMenuClose
      Return
   }
   
   MouseMove, %mx1%, %my1%      ; back to original position
   Gosub, MutualActions
   
   if IsSubmenuShown = 1
   {
      TCurSubMenMin := CurSubMenMax - CurSubMenuLoop +1
      TCurSubMenMax := CurSubMenMax
      TCurSubMenuLoop := CurSubMenuLoop
     
      Gosub, RadialMenuClose
     
      Loop, %TCurSubMenuLoop%         ; determine what to run
      {
         if !(A_index = 1)
         TCurSubMenMin++
         
         if (WinTitle = "RMItem" . TCurSubMenMin)
         {
            CurAction := I%TCurSubMenMin%Action
            if (CurAction = "Error" or CurAction = "")
            Break
            Else
            {
               If CurAction = Mysub                            ; specifying Mysub tells script to execute subroutine in MySubroutines
               {
                  FunctionName := CurSubMenChildText A_index
                  if !(IsFunc(FunctionName) = 0)
                  %FunctionName%()
                  Break
               }
               Else
               ImprovedRun(CurAction)
            }
         }
      }
      Return
   }
   
   
   Gosub, RadialMenuClose
   Loop, %MMTotalButtons%         ; determine what to run
   {
      if (WinTitle = "RMItem" . A_Index)
      {
         CurAction := I%A_Index%Action
         if (CurAction = "Error" or CurAction = "")
         Break
         Else
         {
            If CurAction = Mysub                            ; specifying Mysub tells script to execute subroutine in MySubroutines
            {
               FunctionName := "Main" A_index
               if !(IsFunc(FunctionName) = 0)
               %FunctionName%()
               Break
            }
            Else
            ImprovedRun(CurAction)
         }
      }
   }
   Return
}
else                            ; RMShowHotkey not released on item - just close menu
{
   if SoundOnHide
   {
      SoundPlay, %A_ScriptDir%\Sounds\%SoundOnHide%
     
      StringToSend = StopPlaying
      TargetScriptTitle = RMSoundOnShow
      Send_WM_COPYDATA(StringToSend, TargetScriptTitle)
   }
   Gosub, RadialMenuClose
}
Return





;===Submenu show hotkey==========================================================
RSMShowHotkey:              ; toggle open/close submenu
if IsSubmenuShown = 1       ; if submenu is shown, close submenu
{
   MouseGetPos, Xend, Yend
   IsInCircle := IsInCircle(smx1, smy1, Xend, Yend, ButtonSize/2)
   if IsInCircle
   {
      if SoundOnSubHide
      {
         StringToSend = PlaySoundOnSubHide
         TargetScriptTitle = RMSoundOnSubHide
         Send_WM_COPYDATA(StringToSend, TargetScriptTitle)
      }
      Gosub, CloseSubmenu
   }
   Return
}

CurSubMenMin =
CurSubMenMax =
CurSubMenuLoop =
CurSubMenChildText =
deg =

if (I%LastRMItemNum%Child = "" or  I%LastRMItemNum%Child = "error" )
Return

IsSubmenuShown = 1

SetTimer, ItemTooltip, off
if SoundOnHover
SetTimer, SoundOnHover, off

if SoundOnSubShow
{
   StringToSend = PlaySoundOnSubShow
   TargetScriptTitle = RMSoundOnSubShow
   Send_WM_COPYDATA(StringToSend, TargetScriptTitle)
}

Loop, parse, I%LastRMItemNum%Child, `,  ; parse submenu info
{
   if A_index = 1
   CurSubMenMin := A_LoopField
   Else if A_index = 2
   CurSubMenMax := A_LoopField
   Else if A_index = 3
   CurSubMenChildText := A_LoopField
}

CurSubMenuLoop := CurSubMenMax - CurSubMenMin + 1

smx1 := ActiveItemX+(ButtonSize/2), smy1 := ActiveItemY+(ButtonSize/2) - ShadowHeight

;===Prepare submenu background postiton===
if (CurSubMenuLoop < 7)     ; small background
{
   RSMBX := smx1-SubmenuS/2, RSMBY := smy1-SubmenuS/2     
   Gui, 97: Show, NA  x%RSMBX% y%RSMBY%, RSMBackground        ; RSMBackground
   Gui, 97: +Disabled
}
Else     ; large background
{
   RSMBX := smx1-SubmenuL/2, RSMBY := smy1-SubmenuL/2     
   Gui, 96: Show, NA  x%RSMBX% y%RSMBY%, RSMBackground        ; RSMBackground
   Gui, 96: +Disabled
}


;===Calculate positions and show buttons===
Loop, %CurSubMenuLoop%
{   
   If !(a_index = 1)
   CurSubMenMin++
   
   if (a_index < 7)        ; 1. ring --> 6 buttons
   {
      if A_Index = 1
      deg =
      if (CurSubMenuLoop >= 6)
      CurRingTotalButtons = 6
      Else
      CurRingTotalButtons := CurSubMenuLoop
     
      WheelRadius := FirstRingRadius
      Gosub, CalcPos
   }
   Else                    ; 2. ring --> 13 buttons
   {
      if A_Index = 7
      deg =
      if ButtonPositioning = static
      CurRingTotalButtons :=  13
      else
      CurRingTotalButtons := CurSubMenuLoop - 6
     
      WheelRadius := SecondRingRadius
      Gosub, CalcPos
   }   
   
   Gui, %CurSubMenMin%: Show, NA  x%itemX% y%itemY%
}

ToolTip
SetTimer, ItemTooltip, 20
if SoundOnHover
SetTimer, SoundOnHover, 20
Return



;===Subroutines=========================================================================
CalcPos:    ; extracted from TomXIII's work (Thank you)
deg := deg ? deg+(360/CurRingTotalButtons): (360/CurRingTotalButtons)+90
rad := deg*PiDiv180
xOffset := WheelRadius*(-1*Cos(rad))-picRadius, yOffset := WheelRadius*(-1*Sin(rad))-picRadius
if IsSubmenuShown = 1
itemX := smx1 + xOffset, itemY := smy1 + yOffset
Else
itemX := mx1 + xOffset, itemY := my1 + yOffset
Return


CloseSubmenu:
Gui, 98: Hide                ; MouseOnItem glow

CurSubMenMin -= CurSubMenuLoop-1
Loop, %CurSubMenuLoop%
{
   If not (a_index = 1)
   CurSubMenMin++
   Gui %CurSubMenMin%: Hide
   
   Sleep, %DestroyDelay%
}

Gui, 97: Hide                ; small submenu background
Gui, 96: Hide                ; large submenu background
IsSubmenuShown = 0
IsInCircle =
smx1 =
smy1 =
Return


QuitRMShow:
if not (GetKeyState(RMShowHotkey,"p"))
{
if not (GetKeyState(RMShowHotkey2,"p"))
   {
      SetTimer, QuitRMShow, off
      QuitRMShow = 1
      ;if(hk=2)
      ;   SendInput, {%RMShowHotkey2%}
      ;else
      ;   SendInput, {%RMShowHotkey%}
   }
}
Return


ItemTooltip:     ; + MouseOnItem glow
Critical
MouseGetPos, , , WinID
WinGetTitle, WinTitle, ahk_id %WinID%

if WinTitle = MouseOnItem
{
   PlaySOHSound = 0
   ToolTip,  %CurToolTip%
   Return
}

Else if WinTitle contains RMItem     ; if mouse over RMItem
{
   PlaySOHSound = 1
   Gui, 98: Hide
   ToolTip
   
   StringTrimLeft, JustNum, WinTitle, 6
   If (IsSubmenuShown = 1 and JustNum > MMTotalButtons)
   {
      TCurSubMenMin := CurSubMenMax - CurSubMenuLoop
     
      Loop, %CurSubMenuLoop%
      {
         ttsubname := TCurSubMenMin + A_Index
         if (WinTitle = "RMItem" . ttsubname)
         {
            LastRMItemNum := ttsubname
            CurToolTip := I%ttsubname%ToolTip
            ToolTip,  %CurToolTip%
            Break
         }
      }
   }
   
   Else
   {
      Loop, %MMTotalButtons%
      {
         if (WinTitle = "RMItem" . A_Index)
         {
            LastRMItemNum := A_Index
            CurToolTip := I%A_Index%ToolTip
            ToolTip,  %CurToolTip%
            Break
         }
      }
   }
   
   WinGetPos, ActiveItemX, ActiveItemY, , ,%WinTitle%
   Gui, 98: Show, x%ActiveItemX% y%ActiveItemY% NA, MouseOnItem      ; MouseOnItem
}
Else
{
   LastRMItemNum =  ; empty it so I%LastRMItemNum%Child will be blank - for submenu.
   PlaySOHSound = 0
   Gui, 98: Hide
   ToolTip
}
Return


SoundOnHover:
if PlaySOHSound = 1
SoundPlay, %A_ScriptDir%\Sounds\%SoundOnHover%, wait
Return


Exit:
Gdip_Shutdown(pToken)

;===Close SoundPlayers===
StringToSend = ExitApp
Loop, 3
{
   if A_index = 1
   TargetScriptTitle = RMSoundOnShow
   Else if A_index = 2
   TargetScriptTitle = RMSoundOnSubShow
   Else if A_index = 3
   TargetScriptTitle = RMSoundOnSubHide

   Send_WM_COPYDATA(StringToSend, TargetScriptTitle)
}
;===

ExitApp
Return


RadialMenuClose:
if IsSubmenuShown = 1
Gosub, CloseSubmenu
Gui, 98: Hide                   
if RMCloseDirection = CW        ; clockwise
{
   Loop, %MMTotalButtons%
   {
         Gui %A_index%: Hide
         Sleep, %DestroyDelay%
   }
}
Else if RMCloseDirection = CCW  ; counter-clockwise
{
   TempTB := MMTotalButtons
   Loop, %MMTotalButtons%
   {
         Gui %TempTB%: Hide
         TempTB --
         Sleep, %DestroyDelay%
   }
}
Gui, 99: Hide
Return


MutualActions:
Critical
if SoundOnSelect
SoundPlay, %A_ScriptDir%\Sounds\%SoundOnSelect%
if !SelectEffect       ; Select Effects disabled
Return

;===SelectEffects===    ; if you want fastes performance, just disable Select Effects by setting blank SelectEffect variable in .ini file --> SelectEffect =
WinGetPos, XEff, YEff,,, %WinTitle%

;==Shake effect==
if SelectEffect = Shake       
{
   SetWinDelay, 35          ; Shake speed
   Loop, 5
   {
      ; Set Shake intensity. X axis shake looks better than Y axis shake
      if A_index = 1    ; 2 pixels
      XEff -= 2
      Else if A_index = 2    ; 2 pixels
      XEff += 4
      Else if A_index = 3    ; 1 pixel
      XEff -= 3
      Else if A_index = 4    ; 1 pixel
      XEff += 2
      Else if A_index = 5    ; back to initial position
      XEff -= 1
      WinMove, %WinTitle%,, %XEff%, %YEff%
   }
}
SetWinDelay, 100        ; default
Return


OpenRMF:
Run, explore %A_ScriptDir%
Return

~#!^F5::
ReloadRM:
msgbox,,, Radial Menu will reload now,2
Reload
Return


RMSettings:
Run, %A_ScriptDir%\RM settings.ini
Return


AboutRM:
MsgBox, 64, About Radial menu, %AboutRadialMenu%
Return


ExitRM:
ExitApp
Return


EditMySubroutines:
Run, edit %A_ScriptDir%\Utilities\MySubroutines.ahk
Return


Instructions:       ; inter script communication
if CopyOfData = ReloadRM        ; orders from skin changer
Reload
Return

;===MySubroutines=== ; in fact, MyFunctions
#Include %A_ScriptDir%\Utilities\MySubroutines.ahk

;Escape::ExitApp     ; while developing RM
Back to top
Learning one



Joined: 04 Apr 2009
Posts: 1001
Location: Croatia

PostPosted: Mon Mar 08, 2010 4:10 pm    Post subject: Reply with quote

@LiquidGravity: Thanks. You wrote: "modular", "skins" --> I agree. I'll code skin manager when I find some time.

@bmn_:
1. you can disable RM hotkeys with a)Black list.ahk, b)custom subroutine c) right click on tray icon --> suspend hotkeys. Read RM help file.
2. Gui +Disabled works better than my solution so I implemented your solution in RM v3.18. Thanks! I currently don't have enough time to
test 2 different show keys, so that still won't be implemented.
3. read very carefully: Radial menu licence says:
- Expression "Radial menu" here means Radial menu code and program itself, and any part of whole Radial menu package...
- You are not allowed to (re)distribute... ...without my written permission!

You posted whole RM main code without my written permission! That is a heavy violation of licence! However, in this specific situation, my
licence works against my will. I'm not angry because of your act/conduct, I don't demand that you (in fact moderator) delete your post, but
I see that I must regulate situation when someone wants to help by posting modified RM code in this topic. Read my post below.
Back to top
View user's profile Send private message Visit poster's website
Learning one



Joined: 04 Apr 2009
Posts: 1001
Location: Croatia

PostPosted: Mon Mar 08, 2010 4:11 pm    Post subject: Posting Radial menu code - regulation Reply with quote

Posting Radial menu code - regulation
Radial menu license says:
- Expression "Radial menu" here means Radial menu codes and program itself, and any part of whole Radial menu package...
- You are not allowed to (re)distribute... ...without my written permission!

Uploading and posting any part of Radial menu without my written permission is violation of licence!
However, in situation when someone wants to help by posting modified RM code, my license works against my will.
I will not change RM license text, but I'm giving this revocable written permission:

Any person who agrees on all terms in Radial menu licence and in this permission,
can post original or modified Radial menu code under the following conditions:

1. you can post RM code only in RADIAL MENU scripts topic on Autohotkey forum in codebox - (not link to your modification uploaded somewhere else!).
2. purpose of posting must be intention to help to improve RM
3. I (author) can revoke and modify this permission. If I revoke it, everyone who posted code must delete it! If this is not possible, moderator will do it.
4. Revocation/modification of this permission will be published in RADIAL MENU scripts topic


Sorry for being so formal - remember that I'm a lawyer. If you want to do something else you'll need my written permission - so just ask before you act.
Learning one (B. Mudrinic), RM author


Last edited by Learning one on Mon Sep 13, 2010 8:32 pm; edited 4 times in total
Back to top
View user's profile Send private message Visit poster's website
bmn_
Guest





PostPosted: Mon Mar 08, 2010 10:28 pm    Post subject: Reply with quote

Learning one wrote:

- You are not allowed to (re)distribute... ...without my written permission!

sorry about that. Yea, I know you are not allowed, but didnt think of it affecting this thread as well. But yea, you are right.

Learning one wrote:
1. you can disable RM hotkeys with a)Black list.ahk, b)custom subroutine c) right click on tray icon --> suspend hotkeys. Read RM help file.

a)with the blacklist works, but when i want to drag something with right mouse, i would need to disable for explorer and some others ~.~ no thanks, i like RM too much
b)Thats it. And then use suspend
c) long way..... and i already got lazy with RM Smile
Back to top
bmn_
Guest





PostPosted: Mon Mar 08, 2010 10:45 pm    Post subject: Reply with quote

bmn_ wrote:

b)Thats it. And then use suspend

hmm, just played with it. but i still prefere two hotkeys Wink
Back to top
Learning one



Joined: 04 Apr 2009
Posts: 1001
Location: Croatia

PostPosted: Tue Mar 09, 2010 3:01 pm    Post subject: Reply with quote

Learning one presents you:
Radial menu v3.18
Description. Radial menu is a new method of giving commands to your computer. It's a powerful hotkey, launcher, and mouse gestures system
packed in ergonomic and nice looking interface. It is driven by Autohotkey, so it can do almost anything.


Radial menu program consist of 1) radial menu module and 2) mouse gestures functionality.

Default hotkeys:
Rbutton:
- Drag down to show radial menu module.
- Drag in other directions to execute mouse gestures.
Lbutton: shows/hides submenus
  1. Drag down to show radial menu module. Program shows radial menu around your mouse pointer when you press&hold right mouse button (Rbutton)
    and drag your mouse down for at least 9 pixels. Menu is displayed only while RButton is pressed down. Release RButton above item to select it, or
    anywhere else to hide menu. Item that has its own submenu is marked with two tiny stars near the top of the button. While holding down Rbutton, click it
    with left mouse button (Lbutton) to show its submenu. Release RButton above subitem to select it, or anywhere else to hide submenu and main menu.
    Click with LButton in the center of shown submenu to close it. Note that drag down with Rbutton to show main menu and Lbutton click to show/hide
    submenus are just default settings that can be changed.
  2. Drag in other directions to execute mouse gestures. All other mouse gestures (not drag down) will not show radial menu, but will execute whatever
    you specify when you release RButton.
Mouse gestures are suitable for quick macro commands, and radial menu module is more suitable to be used as a launcher.
Normal Rbutton's click function is always preserved - just click, and don't drag.

Radial menu (as the whole program, not just radial menu module) can be customized a lot. You can customize (change) all hotkeys, gestures, menus,
actions, skins, sounds and a plenty of other settings by editing .ini and .ahk files;
- Mouse gestures can be edited in RMUtilities\MyMouseGestures.ahk
- General Radial menu settings and definition of main menu can be edited in RM settings.ini
- Definitions of submenus can be found and edited in Submenus folder (CompControl.ini, Files.ini, etc.)
- Some additional settings can be edited in RMUtilities folder (MySubroutines.ahk and BlackList.ahk)

Default Radial menu setup is just suggestion how it should it be set up. You have total freedom to change it. Just to be clear, it will take some time
until you explore all possibilities that Radial menu offers.

Help. Please read Radial menu help file.

Download Radial menu v3.18 Licence included in Radial menu package. Read Posting Radial menu code - regulation

Changes compared to Radial menu v3.17:
- implemented mouse gestures
- ShowDelay setting replaced with RMShowGesture --> this is the only one change in ini files structure - you can easily update.
- new folder: RMUtilities, new file: MyMouseGestures.ahk
- updated RM help file - please read it
- changed inter script communication channel; from 0x4a to 0x1001
- fixed disappearing icons issue - Thanks to bmn_
- other minor changes
Back to top
View user's profile Send private message Visit poster's website
Houndx



Joined: 09 Mar 2010
Posts: 6

PostPosted: Tue Mar 09, 2010 3:12 pm    Post subject: Reply with quote

Hopefully I understand the rules about posting modified code correctly.

I've got an Asus T91MT convertible tablet. Since it is a touchscreen device, I wanted the menu to stay on screen until I selected an item - without having to hold down any buttons. Also, since I want to open it using the tablet button, I always want it to open in the center of the screen no matter what orientation I'm currently in. I made the following changes in order to make 3.17 open in the center of the screen, navigable with single screen taps then execute/close with a double tap.

Code:
;===Main menu show Hotkey========================================================================
RMShowHotkey:
IsSubmenuShown = 0
QuitRMShow = 0
deg = 0
MouseGetPos, mx1, my1, OrigWinID
WinGetTitle, OrigWinTitle, ahk_id %OrigWinID%
SetTimer, QuitRMShow, 20 

becomes
Code:
;===Main menu show Hotkey========================================================================
RMShowHotkey:
IsSubmenuShown = 0
QuitRMShow = 0
deg = 0
MouseGetPos, mx1, my1, OrigWinID
mx1 := A_ScreenWidth/2
my1 := A_ScreenHeight/2
WinGetTitle, OrigWinTitle, ahk_id %OrigWinID%
SetTimer, QuitRMShow, 20


Then
Code:
KeyWait, %RMShowHotkey%, u      ; waits RMShowHotkey to be released

becomes
Code:
While (A_PriorHotKey <> "LButton" or A_TimeSincePriorHotKey > 500)
sleep, 10


And finally, I set up the tablet button to send F16 and make the following changes in RM Settings.ini
Code:
RMShowHotkey =      F16
ShowDelay =       0


I had intended to use Simple Radial Menu for this but it has a few problems, for me at least. First, it cannot be reopened, after closing the menu, for a period of five to ten seconds and, more seriously, it stops working correctly on occasion and the script has to be reloaded to correct it.

I may change it later to be navigable by "touch to select" and "release to open", but I may not since it works fairly well this way. One obstacle I'm seeing to that method is that KeyWait does not work with the touchscreen. KeyHistory shows that the touchscreen properly generates LButton Up and Down messages but KeyWait ignores them.
Back to top
View user's profile Send private message
bmn_
Guest





PostPosted: Tue Mar 09, 2010 3:30 pm    Post subject: Reply with quote

Houndx wrote:

Code:
;===Main menu show Hotkey========================================================================
RMShowHotkey:
IsSubmenuShown = 0
QuitRMShow = 0
deg = 0
MouseGetPos, mx1, my1, OrigWinID
mx1 := A_ScreenWidth/2
my1 := A_ScreenHeight/2
WinGetTitle, OrigWinTitle, ahk_id %OrigWinID%
SetTimer, QuitRMShow, 20


problem here mouse will be moved to middle of the screen even if you dont select anything. instead change few lines below
Code:
RMBX := mx1/2-MenuBackgroundWidth/2, RMBY := my1-MenuBackgroundHeight/2

to
Code:
RMBX := A_ScreenWidth/2-MenuBackgroundWidth/2, RMBY := A_ScreenHeight/2-MenuBackgroundHeight/2



Houndx wrote:

Code:
KeyWait, %RMShowHotkey%, u      ; waits RMShowHotkey to be released

becomes
Code:
While (A_PriorHotKey <> "LButton" or A_TimeSincePriorHotKey > 500)
sleep, 10


easier would to not start the close timer at all. whereever you find
Code:
SetTimer, QuitRMShow,

write an off instead of the number
Back to top
Houndx



Joined: 09 Mar 2010
Posts: 6

PostPosted: Tue Mar 09, 2010 3:35 pm    Post subject: Reply with quote

Thanks for the tips. I'm brand new to AutoHotKey and made those changes within seconds of getting it installed Smile Since I'm exclusively using this with the touchscreen, the mouse position is irrelevant but I'll look at the second suggestion more closely.
Back to top
View user's profile Send private message
bmn_
Guest





PostPosted: Tue Mar 09, 2010 3:38 pm    Post subject: Reply with quote

i am missing show delay and disable gestures feature in 3.18!!!!!!!!!!!!!
Back to top
bmn_
Guest





PostPosted: Tue Mar 09, 2010 3:42 pm    Post subject: Reply with quote

I dont know if this solution would help though as you said ahk doesent get keywait malfunctions for you. But what looks definatelly wrong about your code is the A_TimeSincePriorHotKey > 500 if there is no new hotkey press for some time, it will stay in an infinite loop
Back to top
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3 ... 12, 13, 14 ... 46, 47, 48  Next
Page 13 of 48

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group