Below is the code:
Code: Select all
;https://www.autohotkey.com/docs/scripts/index.htm#TooltipMouseMenu
;hotkey changed from long press MButton to RButton
; ToolTip Mouse Menu (requires XP/2k/NT) -- by Rajat
; https://www.autohotkey.com
; This script displays a popup menu in response to briefly holding down
; the middle mouse button. Select a menu item by left-clicking it.
; Cancel the menu by left-clicking outside of it. A recent improvement
; is that the contents of the menu can change depending on which type of
; window is active (Notepad and Word are used as examples here).
; You can set any title here for the menu:
MenuTitle = Select the below options: ;create menu title
SetFormat, float, 0.0 ;not required
SetBatchLines, 10ms ;not necessary
SetTitleMatchMode, 2 ;required for dynamic menu
#SingleInstance, Force
;___________________________________________
;_____Menu Definitions______________________
; Create / Edit Menu Items here.
; You can't use spaces in keys/values/section names.
; Don't worry about the order, the menu will be sorted.
MenuItems = 1)Screenshot1 or Screenshot2 State/2)SpeedUpDown or UndoRedo_State/3)CopyCut or CopylinkCopyCut State/4)MediaPlay4All or MediaPlay4Nox State/5)MediaKey4OneNote or MediaKey4All State/6)Mouse_Middle_Button State/7)Exit Application ;create menu items separated by /
;___________________________________________
;______Dynamic menuitems here_______________
; Syntax:
; Dyn# = MenuItem|Window title
Dyn1 = Lecture Recordings|- OneNote ;create dynamic menu item and window title for the menu to show up separated by |
;~ Dyn3 = SciTE|SciTE4AutoHotkey ;reserved to demo how dynamic menu item can be created
;___________________________________________
Exit
;___________________________________________
;_____Menu Sections_________________________
; Create / Edit Menu Sections here.
1)Screenshot1orScreenshot2State: ;create non-spaced labels for menu items
{
scrstate := !scrstate
if (scrstate=0)
{
MsgBox, 262144, Screenshot Key Press,
(
Screenshot - 2 press
`nRepeat last - 1 press
)
}
else if (scrstate=1)
{
MsgBox, 262144, Screenshot Key Press,
(
Screenshot - 1 press
`nRepeat last - 2 press
)
}
}
Return
2)SpeedUpDownorUndoRedo_State:
{
spustate := !spustate
if (spustate=0)
{
MsgBox, 262144, Speed up/down,
(
^ - speed up
`nv - speed down
)
}
else if (spustate=1)
{
MsgBox, 262144, undo/redo,
(
^ - redo
`nv - undo
)
}
}
Return
3)CopyCutorCopylinkCopyCutState:
{
cpcstate := !cpcstate
if (cpcstate=0)
{
MsgBox, 262144, copy/cut,
(
copy - 1 press
`ncut - 1 press
)
}
else if (cpcstate=1)
{
MsgBox, 262144, copylink/copy/cut,
(
copylink(onenote) - 1 press
`ncopy - 2 press
`ncut - 3 press
)
}
}
Return
4)MediaPlay4AllorMediaPlay4NoxState:
{
mdastate:=!mdastate
SoundBeep, 300, 700
if (mdastate = 1)
{
SplashTextOn,250,60,,Play/Pause for nox
Sleep 400
SplashTextOff
if (fnstate = 0)
{
Menu, Tray, Icon, fndisableone_nox.ico
}
else if (fnstate = 1)
{
Menu, Tray, Icon, fnenableone_nox.ico
}
}
else if (mdastate = 0)
{
SplashTextOn,250,60,,Play/Pause for all
Sleep 400
SplashTextOff
if (fnstate = 0)
{
Menu, Tray, Icon, fndisableone_all.ico
}
else if (fnstate = 1)
{
Menu, Tray, Icon, fnenableone_all.ico
}
}
}
Return
5)MediaKey4OneNoteorMediaKey4AllState:
{
mdkystate := !mdkystate
if (mdkystate=0)
{
MsgBox, 262144, Media_Play_Pause,
(
Play/Pause - Play/Pause
)
}
else if (mdkystate=1)
{
MsgBox, 262144, Media_Play_Pause,
(
Play/Pause - ctrl + shift + 6
)
}
}
Return
6)Mouse_Middle_ButtonState:
{
mbtnstate := !mbtnstate
SoundBeep, 565, 600
if (mbtnstate=0)
{
MsgBox, 262144, Mouse Middle Button,
(
Mbutton - Feature On
)
}
else if (mbtnstate=1)
{
MsgBox, 262144, Mouse Middle Button,
(
Mbutton - Feature Off(original)
)
}
}
Return
7)ExitApplication:
{
SplashTextOn,150,40,,Exit Script
Sleep 400
SplashTextOff
ExitApp
}
Return
LectureRecording:
Explorer = %A_WinDir%\explorer.exe /n,/e,
Foldexir = C:\Users\amana\Music\Lecture Recordings
Run, %Explorer%"%Foldexir%"
Return
;~ SciTE: ;reserved to demo how dynamic menu item can be created
;~ MsgBox, this is a dynamic entry (SciTE)
;~ Return
;___________________________________________
;_____Hotkey Section________________________
;=======================================================================================
;automatically going to turn on because it will be inside if and else statement ; currtly not possibl
;=========================================================================================
Mbutton::
;prepares dynamic menu
DynMenu =
Loop
{
IfEqual, Dyn%A_Index%,, Break ;break out of loop if DynX is empty
StringGetPos, ppos, dyn%A_Index%, | ;separate out dynamic menu by menu name and window name
StringLeft, item, dyn%A_Index%, %ppos%
ppos += 2
StringMid, win, dyn%A_Index%, %ppos%, 1000
IfWinActive, %win%, ;add dynamic menu only if the window is active
DynMenu = %DynMenu%/%item%
}
;Joins sorted main menu and dynamic menu
Sort, MenuItems, D/
TempMenu = %MenuItems%%DynMenu%
;clears earlier entries
Loop
{
IfEqual, MenuItem%A_Index%,, Break
MenuItem%A_Index% =
}
;creates new entries
Loop, Parse, TempMenu, /
{
MenuItem%A_Index% = %A_LoopField%
}
;creates the menu
Menu = %MenuTitle%
Loop
{
IfEqual, MenuItem%A_Index%,, Break
numItems ++ ;variable to store number of menu items (counted by loop iterations)
StringTrimLeft, MenuText, MenuItem%A_Index%, 0 ;not sure why this is here
Menu = %Menu%`n%MenuText%
}
MouseGetPos, mX, mY
Hotkey, ~LButton, MenuClick ;convert LButton to a hotkey
Hotkey, ~LButton, On ;enable the hotkey if it is currently disabled
ToolTip, %Menu%, %mX%, %mY% ;show tooltip of menu at current cursor loc
WinActivate, %MenuTitle% ;required to by default activate the tooltip to prepare for the next mouse click
Return
MenuClick:
Hotkey, ~LButton, Off ;disable the hotkey if it is currently enabled
IfWinNotActive, %MenuTitle% ;if you clicked elsewhere and so tooltip is not the active window, otherwise you clicked on the tooltip so skip these lines
{
ToolTip
Return
}
MouseGetPos, mX, mY
ToolTip
;use msgbox % mY to see the math result
mY += 10 ;space after which first line starts | adjustment may be required (increase number to start further down from the top of tooltip)
;~ msgbox % mY
mY /= 23 ;space taken by each line | adjustment may be required (decrease number to narrow down the height of each row and vice versa)
;~ msgbox % mY
IfLess, mY, 1, Return ;do nothing if the number is less than 1, i.e. you clicked the title area
IfGreater, mY, %numItems%, Return ;do nothing if mY exceeds the number of menu items
StringTrimLeft, TargetSection, MenuItem%mY%, 0
StringReplace, TargetSection, TargetSection, %A_Space%,, A ;remove all spaces
Gosub, %TargetSection%
Return
here is the hotkey section in the code if you didn't find. ;
Code: Select all
;___________________________________________
;_____Hotkey Section________________________
;=======================================================================================
;automatically going to turn on because it will be inside if and else statement ; currtly not possibl
;=========================================================================================
Mbutton::
;prepares dynamic menu
Here is the script which I want this to part of;
Code: Select all
#IF (mbtnstate=0)
;Hotkey to select area
Mbutton::
SCW_ScreenClip2Win(clip:=0) ; set to 1 to auto-copy to clipboard
WinActivate, ScreenClippingWindow ahk_class AutoHotkeyGUI
If (ClickCount > 0)
{
ClickCount +=1
}
else
{
ClickCount :=1
}
Tooltip, %ClickCount%
SetTimer, oKeyPressMonitor, 500
return
oKeyPressMonitor:
If (ClickCount = 2)
{
SendInput, Media_Play_Pause
}
else if (ClickCount = 3)
{
SendInput, ^+/
}
else if (ClickCount = 4)
{
;Over here I want place above script
}
ClickCount := 0
SetTimer, oKeyPressMonitor, Off
Tooltip,
return
#IF