How to tooltip menu script without hotkey? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
arrondark
Posts: 29
Joined: 01 May 2024, 05:27

How to tooltip menu script without hotkey?

Post by arrondark » 17 May 2024, 06:07

Problem: I am trying to run the tooltip menu script without hotkey but every time I do so I failed. I try to simply removing the hotkey but it didn't work.

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

the annoying thing which I don't understand that the hotkey has to at its particular place/position it can not be placed on top and also I am unable to remove the hotkey.
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


I am trying to make it a part of another script( I want to include this script in if and else statement but I am unable to do so)
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
I thought of making it a function but whenever I call it nothing happens also I used gosub function but than tooltip menu start moving with cursor thus there is no way for me to click on option.
User avatar
CoffeeChaton
Posts: 36
Joined: 11 May 2024, 10:50

Re: How to tooltip menu script without hotkey?

Post by CoffeeChaton » 17 May 2024, 11:30

Code: Select all


#Requires AutoHotkey v1.1.33+

SetFormat, float, 0.0
SetBatchLines, 10ms
SetTitleMatchMode, 2
#SingleInstance Force

global numItems, MenuTitle, MenuItems, MenuItem, Dyn1, Dyn, fnstate

numItems := 0
MenuTitle := "Select the below options:"
MenuItems := "
    (LTrim Join/
        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
    )"

MenuItem := []

Dyn1 := "Lecture Recordings|- OneNote" 
Dyn := [Dyn1]
fnstate := 0

Return


1_Screenshot1orScreenshot2State() {
    static scrstate ; only 0/1 ?
    scrstate := !scrstate

    Text := scrstate
        ? "Screenshot  - 2 press`n`nRepeat last - 1 press"
        : "Screenshot  - 1 press`n`nRepeat last - 2 press"

    MsgBox, 0x40000, % "Screenshot Key Press",% Text
}


2_SpeedUpDownorUndoRedo_State() {
    static spustate ; only 0/1 ?
    spustate := !spustate
    if (spustate=0)
    {
        MsgBox, 0x40000, % "Speed up/down", % "^ - speed up`n`nv - speed down"
    }
    else if (spustate=1)
    {
        MsgBox, 0x40000, % "undo/redo", % "^ - redo`n`nv - undo"
    } 
}


3_CopyCutorCopylinkCopyCutState() {
    static cpcstate
    cpcstate := !cpcstate
    if (cpcstate=0)
    {
        MsgBox, 0x40000, % "copy/cut", % "copy - 1 press`n`n",
            (LTrim
                copy - 1 press
                cut  - 1 press
            ) 
    }
    else if (cpcstate=1)
    {
        MsgBox, 0x40000, % "copylink/copy/cut",
			(
				copylink(onenote) - 1 press
							 `ncopy - 2 press
							  `ncut - 3 press
			) 
    } 
}

4_MediaPlay4AllorMediaPlay4NoxState() {
    static mdastate
    mdastate := !mdastate
    SoundBeep, 300, 700
    if (mdastate = 1)
    {
        SplashTextOn, 250,60,,% "Play/Pause for nox"
        Sleep, 400
        SplashTextOff
        if (fnstate = 0) ; #1 where change `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() {
    static mdkystate

    mdkystate := !mdkystate
    text := mdkystate=0
        ? "Play/Pause - Play/Pause"
        : "Play/Pause - ctrl + shift + 6"
    MsgBox, 0x40000, % "Media_Play_Pause", % text
}

6_Mouse_Middle_ButtonState() {
    static mbtnstate

    mbtnstate := !mbtnstate
    SoundBeep, 565, 600

    text := mbtnstate = 0
        ? "Mbutton - Feature On"
        : "Mbutton - Feature Off(original)"
    MsgBox, 0x40000, % "Mouse Middle Button", % text
}

7_ExitApplication() {
    SplashTextOn, 150,40,,% "Exit Script"
    Sleep, 400
    SplashTextOff
    ExitApp
}


LectureRecording() {
    Explorer := A_WinDir "\explorer.exe /n,/e,"
    Foldexir := "C:\Users\amana\Music\Lecture Recordings"
    ; Run, %Explorer%"%Foldexir%"
    Run, % Explorer """" Foldexir """"
}


Mbutton:: fn_Mbutton()
;prepares dynamic menu
fn_Mbutton() {
    DynMenu := ""
    Loop
    {
        ; IfEqual, Dyn%A_Index%, , Break ;break out of loop if DynX is empty
        if (Dyn[A_Index] = "")
            Break
        ; StringGetPos, ppos, dyn%A_Index%
        ppos := InStr(Dyn[A_Index], "|")
        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%

        IfWinActive, %win%
            DynMenu := DynMenu "/" item
    }


    ;Joins sorted main menu and dynamic menu
    Sort, MenuItems, D/
    TempMenu := MenuItems . DynMenu

    MenuItem := []
    ;clears earlier entries
    Loop
    {
        ; IfEqual, MenuItem%A_Index%, , Break
        if (MenuItem[A_Index] == "") {
            Break
        }
        MenuItem[A_Index] := ""
    }

    Loop, Parse, TempMenu, /
    {
        MenuItem[A_Index] := A_LoopField
    }


    Menu := MenuTitle
    Loop
    {
        ; IfEqual, MenuItem%A_Index%, , Break
        if (MenuItem[A_Index] == "") 
            Break

        numItems++
        StringTrimLeft, MenuText,% MenuItem[A_Index], 0
        ; Menu = %Menu%`n%MenuText%
        Menu := Menu "`n" MenuText
    }

    MouseGetPos, mX, mY
    Hotkey, ~LButton, fnMenuClick
    Hotkey, ~LButton, On
    ToolTip, %Menu%, %mX%, %mY%
    WinActivate, %MenuTitle%
}


fnMenuClick() {
    ; global MenuTitle, MenuItem

    Hotkey, ~LButton, Off
    IfWinNotActive, %MenuTitle%
    {
        ToolTip
        Return
    }

    MouseGetPos, _mX, mY
    ToolTip
    mY += 10
    mY /= 23
    If (mY < 1)
        Return

    if (mY = numItems)
        Return


    TargetSection := MenuItem[mY]
    funcName := StrReplace(TargetSection, A_Space, "")
    funcName := StrReplace(funcName, ")", "_")

    %funcName%()
}

function version,
now you can del Mbutton:: fn_Mbutton(), just call fn_Mbutton()
the annoying thing which I don't understand that the hotkey has to at its particular place/position it can not be placed on top
Specifically, it is related to the location of global var.
Now you just need to make sure that this section is above the function.

Code: Select all

global numItems, MenuTitle, MenuItems, MenuItem, Dyn1, Dyn, fnstate

numItems := 0
MenuTitle := "Select the below options:"
MenuItems := "
    (LTrim Join/
        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
    )"

MenuItem := []

Dyn1 := "Lecture Recordings|- OneNote" 
Dyn := [Dyn1]
fnstate := 0

Return
arrondark
Posts: 29
Joined: 01 May 2024, 05:27

Re: How to tooltip menu script without hotkey?

Post by arrondark » 17 May 2024, 12:48

Thank you CoffeeChaton for making the code more organized, I understood what you said the only issue I am facing is to put the code inside the if and else statement. There are two ways which I have tried;
1) call the function from if and else

Code: Select all


#Requires AutoHotkey v1.1.33+

SetFormat, float, 0.0
SetBatchLines, 10ms
SetTitleMatchMode, 2
#SingleInstance Force

global numItems, MenuTitle, MenuItems, MenuItem, Dyn1, Dyn, fnstate

numItems := 0
MenuTitle := "Select the below options:"
MenuItems := "
    (LTrim Join/
        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
    )"

MenuItem := []

Dyn1 := "Lecture Recordings|- OneNote" 
Dyn := [Dyn1]
fnstate := 0

Return


1_Screenshot1orScreenshot2State() {
    static scrstate ; only 0/1 ?
    scrstate := !scrstate

    Text := scrstate
        ? "Screenshot  - 2 press`n`nRepeat last - 1 press"
        : "Screenshot  - 1 press`n`nRepeat last - 2 press"

    MsgBox, 0x40000, % "Screenshot Key Press",% Text
}


2_SpeedUpDownorUndoRedo_State() {
    static spustate ; only 0/1 ?
    spustate := !spustate
    if (spustate=0)
    {
        MsgBox, 0x40000, % "Speed up/down", % "^ - speed up`n`nv - speed down"
    }
    else if (spustate=1)
    {
        MsgBox, 0x40000, % "undo/redo", % "^ - redo`n`nv - undo"
    } 
}


3_CopyCutorCopylinkCopyCutState() {
    static cpcstate
    cpcstate := !cpcstate
    if (cpcstate=0)
    {
        MsgBox, 0x40000, % "copy/cut", % "copy - 1 press`n`n",
            (LTrim
                copy - 1 press
                cut  - 1 press
            ) 
    }
    else if (cpcstate=1)
    {
        MsgBox, 0x40000, % "copylink/copy/cut",
			(
				copylink(onenote) - 1 press
							 `ncopy - 2 press
							  `ncut - 3 press
			) 
    } 
}

4_MediaPlay4AllorMediaPlay4NoxState() {
    static mdastate
    mdastate := !mdastate
    SoundBeep, 300, 700
    if (mdastate = 1)
    {
        SplashTextOn, 250,60,,% "Play/Pause for nox"
        Sleep, 400
        SplashTextOff
        if (fnstate = 0) ; #1 where change `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() {
    static mdkystate

    mdkystate := !mdkystate
    text := mdkystate=0
        ? "Play/Pause - Play/Pause"
        : "Play/Pause - ctrl + shift + 6"
    MsgBox, 0x40000, % "Media_Play_Pause", % text
}

6_Mouse_Middle_ButtonState() {
    static mbtnstate

    mbtnstate := !mbtnstate
    SoundBeep, 565, 600

    text := mbtnstate = 0
        ? "Mbutton - Feature On"
        : "Mbutton - Feature Off(original)"
    MsgBox, 0x40000, % "Mouse Middle Button", % text
}

7_ExitApplication() {
    SplashTextOn, 150,40,,% "Exit Script"
    Sleep, 400
    SplashTextOff
    ExitApp
}


LectureRecording() {
    Explorer := A_WinDir "\explorer.exe /n,/e,"
    Foldexir := "C:\Users\amana\Music\Lecture Recordings"
    ; Run, %Explorer%"%Foldexir%"
    Run, % Explorer """" Foldexir """"
}


Mbutton:: 
If (ClickCount > 0)
	{
		ClickCount +=1
	}
else
	{
		ClickCount :=1
	}
Tooltip, %ClickCount%
SetTimer, mbclickmonitor, 15000
return
mbclickmonitor:
If (ClickCount = 2)
	{
		Send, {Media_Play_Pause}
	}
else if (ClickCount = 3)
    {
        whelscrlfn:=!whelscrlfn
        if (whelscrlfn=0)
			{
				MsgBox, 262144, Scroll Up/Down,
				(
			        Scroll Up   - Scroll Up
			        `nScroll Down - Scroll Down
				)
			}
		else if (whelscrlfn=1)
			{
				MsgBox, 262144, Scroll Up/Down,
				(
			        Scroll Up   - Arrow Right
			        `nScroll Down - Arrow Left
				)
			} 
    }
else if (ClickCount = 4)
	{
		run, Notepad
	}
else if (ClickCount = 5)
    {
		fn_Mbutton()
    }
ClickCount := 0
SetTimer, mbclickmonitor, Off
Tooltip,
return

;prepares dynamic menu
fn_Mbutton() {
    DynMenu := ""
    Loop
    {
        ; IfEqual, Dyn%A_Index%, , Break ;break out of loop if DynX is empty
        if (Dyn[A_Index] = "")
            Break
        ; StringGetPos, ppos, dyn%A_Index%
        ppos := InStr(Dyn[A_Index], "|")
        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%

        IfWinActive, %win%
            DynMenu := DynMenu "/" item
    }


    ;Joins sorted main menu and dynamic menu
    Sort, MenuItems, D/
    TempMenu := MenuItems . DynMenu

    MenuItem := []
    ;clears earlier entries
    Loop
    {
        ; IfEqual, MenuItem%A_Index%, , Break
        if (MenuItem[A_Index] == "") {
            Break
        }
        MenuItem[A_Index] := ""
    }

    Loop, Parse, TempMenu, /
    {
        MenuItem[A_Index] := A_LoopField
    }


    Menu := MenuTitle
    Loop
    {
        ; IfEqual, MenuItem%A_Index%, , Break
        if (MenuItem[A_Index] == "") 
            Break

        numItems++
        StringTrimLeft, MenuText,% MenuItem[A_Index], 0
        ; Menu = %Menu%`n%MenuText%
        Menu := Menu "`n" MenuText
    }

    MouseGetPos, mX, mY
    Hotkey, ~LButton, fnMenuClick
    Hotkey, ~LButton, On
    ToolTip, %Menu%, %mX%, %mY%
    WinActivate, %MenuTitle%
}


fnMenuClick() {
    ; global MenuTitle, MenuItem

    Hotkey, ~LButton, Off
    IfWinNotActive, %MenuTitle%
    {
        ToolTip
        Return
    }

    MouseGetPos, _mX, mY
    ToolTip
    mY += 10
    mY /= 23
    If (mY < 1)
        Return

    if (mY = numItems)
        Return


    TargetSection := MenuItem[mY]
    funcName := StrReplace(TargetSection, A_Space, "")
    funcName := StrReplace(funcName, ")", "_")

    %funcName%()
}

If you unable to find the condition, see below;

Code: Select all

Mbutton:: 
If (ClickCount > 0)
	{
		ClickCount +=1
	}
else
	{
		ClickCount :=1
	}
Tooltip, %ClickCount%
SetTimer, mbclickmonitor, 15000
return
mbclickmonitor:
If (ClickCount = 2)
	{
		Send, {Media_Play_Pause}
	}
else if (ClickCount = 3)
    {
        whelscrlfn:=!whelscrlfn
        if (whelscrlfn=0)
			{
				MsgBox, 262144, Scroll Up/Down,
				(
			        Scroll Up   - Scroll Up
			        `nScroll Down - Scroll Down
				)
			}
		else if (whelscrlfn=1)
			{
				MsgBox, 262144, Scroll Up/Down,
				(
			        Scroll Up   - Arrow Right
			        `nScroll Down - Arrow Left
				)
			} 
    }
else if (ClickCount = 4)
	{
		run, Notepad
	}
else if (ClickCount = 5)
    {
		fn_Mbutton()
    }
ClickCount := 0
SetTimer, mbclickmonitor, Off
Tooltip,
return
If feel the above if else state is working with timer and also with single key press it does multiple function that might be one of the issue.
I actually see ToolTipMenu, but it's visible for few miliseconds and it disappears. It difficult to take a picture feel free to try the code yourself.

2)Put the whole ToolTipMenu code inside the if else statement
I did it bit controversial and also it did give the result but thing is I won't be able to click anything because the menu also moves with my cursor again free to try code snippet. Below is the code I have tried;

Code: Select all

fnstate := 0
Mbutton:: 
If (ClickCount > 0)
	{
		ClickCount +=1
	}
else
	{
		ClickCount :=1
	}
Tooltip, %ClickCount%
SetTimer, mbclickmonitor, 15000
return
mbclickmonitor:
If (ClickCount = 2)
	{
		Send, {Media_Play_Pause}
	}
else if (ClickCount = 3)
    {
        whelscrlfn:=!whelscrlfn
        if (whelscrlfn=0)
			{
				MsgBox, 262144, Scroll Up/Down,
				(
			        Scroll Up   - Scroll Up
			        `nScroll Down - Scroll Down
				)
			}
		else if (whelscrlfn=1)
			{
				MsgBox, 262144, Scroll Up/Down,
				(
			        Scroll Up   - Arrow Right
			        `nScroll Down - Arrow Left
				)
			} 
    }
else if (ClickCount = 4)
	{
		run, Notepad
	}
else if (ClickCount = 5)
    {
        SetFormat, float, 0.0
        SetBatchLines, 10ms
        SetTitleMatchMode, 2
        #SingleInstance Force

        global numItems, MenuTitle, MenuItems, MenuItem, Dyn1, Dyn, fnstate

        numItems := 0
        MenuTitle := "Select the below options:"
        MenuItems := "
            (LTrim Join/
                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
            )"

        MenuItem := []

        Dyn1 := "Lecture Recordings|- OneNote" 
        Dyn := [Dyn1]

        Return


        1_Screenshot1orScreenshot2State() {
            static scrstate ; only 0/1 ?
            scrstate := !scrstate

            Text := scrstate
                ? "Screenshot  - 2 press`n`nRepeat last - 1 press"
                : "Screenshot  - 1 press`n`nRepeat last - 2 press"

            MsgBox, 0x40000, % "Screenshot Key Press",% Text
        }


        2_SpeedUpDownorUndoRedo_State() {
            static spustate ; only 0/1 ?
            spustate := !spustate
            if (spustate=0)
            {
                MsgBox, 0x40000, % "Speed up/down", % "^ - speed up`n`nv - speed down"
            }
            else if (spustate=1)
            {
                MsgBox, 0x40000, % "undo/redo", % "^ - redo`n`nv - undo"
            } 
        }


        3_CopyCutorCopylinkCopyCutState() {
            static cpcstate
            cpcstate := !cpcstate
            if (cpcstate=0)
            {
                MsgBox, 0x40000, % "copy/cut", % "copy - 1 press`n`n",
                    (LTrim
                        copy - 1 press
                        cut  - 1 press
                    ) 
            }
            else if (cpcstate=1)
            {
                MsgBox, 0x40000, % "copylink/copy/cut",
                    (
                        copylink(onenote) - 1 press
                                    `ncopy - 2 press
                                    `ncut - 3 press
                    ) 
            } 
        }

        4_MediaPlay4AllorMediaPlay4NoxState() {
            static mdastate
            mdastate := !mdastate
            SoundBeep, 300, 700
            if (mdastate = 1)
            {
                SplashTextOn, 250,60,,% "Play/Pause for nox"
                Sleep, 400
                SplashTextOff
                if (fnstate = 0) ; #1 where change `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() {
            static mdkystate

            mdkystate := !mdkystate
            text := mdkystate=0
                ? "Play/Pause - Play/Pause"
                : "Play/Pause - ctrl + shift + 6"
            MsgBox, 0x40000, % "Media_Play_Pause", % text
        }

        6_Mouse_Middle_ButtonState() {
            static mbtnstate

            mbtnstate := !mbtnstate
            SoundBeep, 565, 600

            text := mbtnstate = 0
                ? "Mbutton - Feature On"
                : "Mbutton - Feature Off(original)"
            MsgBox, 0x40000, % "Mouse Middle Button", % text
        }

        7_ExitApplication() {
            SplashTextOn, 150,40,,% "Exit Script"
            Sleep, 400
            SplashTextOff
            ExitApp
        }


        LectureRecording() {
            Explorer := A_WinDir "\explorer.exe /n,/e,"
            Foldexir := "C:\Users\amana\Music\Lecture Recordings"
            ; Run, %Explorer%"%Foldexir%"
            Run, % Explorer """" Foldexir """"
        }

        ;prepares dynamic menu
        fn_Mbutton() {
            DynMenu := ""
            Loop
            {
                ; IfEqual, Dyn%A_Index%, , Break ;break out of loop if DynX is empty
                if (Dyn[A_Index] = "")
                    Break
                ; StringGetPos, ppos, dyn%A_Index%
                ppos := InStr(Dyn[A_Index], "|")
                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%

                IfWinActive, %win%
                    DynMenu := DynMenu "/" item
            }


            ;Joins sorted main menu and dynamic menu
            Sort, MenuItems, D/
            TempMenu := MenuItems . DynMenu

            MenuItem := []
            ;clears earlier entries
            Loop
            {
                ; IfEqual, MenuItem%A_Index%, , Break
                if (MenuItem[A_Index] == "") {
                    Break
                }
                MenuItem[A_Index] := ""
            }

            Loop, Parse, TempMenu, /
            {
                MenuItem[A_Index] := A_LoopField
            }


            Menu := MenuTitle
            Loop
            {
                ; IfEqual, MenuItem%A_Index%, , Break
                if (MenuItem[A_Index] == "") 
                    Break

                numItems++
                StringTrimLeft, MenuText,% MenuItem[A_Index], 0
                ; Menu = %Menu%`n%MenuText%
                Menu := Menu "`n" MenuText
            }

            MouseGetPos, mX, mY
            Hotkey, ~LButton, fnMenuClick
            Hotkey, ~LButton, On
            ToolTip, %Menu%, %mX%, %mY%
            WinActivate, %MenuTitle%
        }


        fnMenuClick() {
            ; global MenuTitle, MenuItem

            Hotkey, ~LButton, Off
            IfWinNotActive, %MenuTitle%
            {
                ToolTip
                Return
            }

            MouseGetPos, _mX, mY
            ToolTip
            mY += 10
            mY /= 23
            If (mY < 1)
                Return

            if (mY = numItems)
                Return


            TargetSection := MenuItem[mY]
            funcName := StrReplace(TargetSection, A_Space, "")
            funcName := StrReplace(funcName, ")", "_")

            %funcName%()
        }

    }
ClickCount := 0
SetTimer, mbclickmonitor, Off
Tooltip,
return

Last time when I checked, the script was atleast showing me the menu but now it doesn't show anything(2nd type of code)
If feel the problems are
1. I am trying to use a single key for multiple function but I am to this timer based If and else statement which creates further problem, I also priorhotkey but it didn't work for me(may be I use it incorrectly). I wish I knew more ways to implement.
2. Calling a function from if and else statement with a timer is hectic, for this purpose many use exit and I did it too. Which again didn't work well. But atleast I show ToolTipMenu which disappear quickly.
User avatar
CoffeeChaton
Posts: 36
Joined: 11 May 2024, 10:50

Re: How to tooltip menu script without hotkey?

Post by CoffeeChaton » 17 May 2024, 13:44

Code: Select all


global ClickCount
Mbutton:: fn_Mbutton_withClick() 

fn_Mbutton_withClick() {
    If (ClickCount > 0) {
        ClickCount += 1
    } else {
        ClickCount := 1
    }
    Tooltip, %ClickCount%
    SetTimer, mbclickmonitor, -1500
}

mbclickmonitor() {
    static whelscrlfn

    Switch ClickCount {
        Case 2:
            Send, {Media_Play_Pause}

        Case 3:
            MsgBox % "debug 3"
            whelscrlfn := !whelscrlfn
            Text := whelscrlfn = 0
                ? "Scroll Up   - Scroll Up`n`nScroll Down - Scroll Down"
                : "Scroll Up   - Arrow Right`n`nScroll Down - Arrow Left"
            MsgBox, 0x40000, % "Scroll Up/Down", % Text

        Case 4:
            run, Notepad

        Case 5:
            fn_Mbutton()

        Default:
            ; nothing
    }
    ClickCount := 0
    SetTimer, mbclickmonitor, Off
    Tooltip
}
If you unable to find the condition, see below;

SetTimer, mbclickmonitor, -1500

did you want , Mbutton *3 in 1.5 sec , show MsgBox % "debug 3" ?

i just change 15000 (15 sec loop) to -150 (1.5 sec not loop)
arrondark
Posts: 29
Joined: 01 May 2024, 05:27

Re: How to tooltip menu script without hotkey?

Post by arrondark » 17 May 2024, 20:09

Unfortunately it does not work I tried the code and also changed a bit to see any difference but nothing happen. In each trial I do get the ToolTip Menu but it disappeared in less than a second.
Here is the code:

Code: Select all


#Requires AutoHotkey v1.1.33+

SetFormat, float, 0.0
SetBatchLines, 10ms
SetTitleMatchMode, 2
#SingleInstance Force

global numItems, MenuTitle, MenuItems, MenuItem, Dyn1, Dyn, fnstate

numItems := 0
MenuTitle := "Select the below options:"
MenuItems := "
    (LTrim Join/
        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
    )"

MenuItem := []

Dyn1 := "Lecture Recordings|- OneNote" 
Dyn := [Dyn1]
fnstate := 0

Return


1_Screenshot1orScreenshot2State() {
    static scrstate ; only 0/1 ?
    scrstate := !scrstate

    Text := scrstate
        ? "Screenshot  - 2 press`n`nRepeat last - 1 press"
        : "Screenshot  - 1 press`n`nRepeat last - 2 press"

    MsgBox, 0x40000, % "Screenshot Key Press",% Text
}


2_SpeedUpDownorUndoRedo_State() {
    static spustate ; only 0/1 ?
    spustate := !spustate
    if (spustate=0)
    {
        MsgBox, 0x40000, % "Speed up/down", % "^ - speed up`n`nv - speed down"
    }
    else if (spustate=1)
    {
        MsgBox, 0x40000, % "undo/redo", % "^ - redo`n`nv - undo"
    } 
}


3_CopyCutorCopylinkCopyCutState() {
    static cpcstate
    cpcstate := !cpcstate
    if (cpcstate=0)
    {
        MsgBox, 0x40000, % "copy/cut", % "copy - 1 press`n`n",
            (LTrim
                copy - 1 press
                cut  - 1 press
            ) 
    }
    else if (cpcstate=1)
    {
        MsgBox, 0x40000, % "copylink/copy/cut",
			(
				copylink(onenote) - 1 press
							 `ncopy - 2 press
							  `ncut - 3 press
			) 
    } 
}

4_MediaPlay4AllorMediaPlay4NoxState() {
    static mdastate
    mdastate := !mdastate
    SoundBeep, 300, 700
    if (mdastate = 1)
    {
        SplashTextOn, 250,60,,% "Play/Pause for nox"
        Sleep, 400
        SplashTextOff
        if (fnstate = 0) ; #1 where change `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() {
    static mdkystate

    mdkystate := !mdkystate
    text := mdkystate=0
        ? "Play/Pause - Play/Pause"
        : "Play/Pause - ctrl + shift + 6"
    MsgBox, 0x40000, % "Media_Play_Pause", % text
}

6_Mouse_Middle_ButtonState() {
    static mbtnstate

    mbtnstate := !mbtnstate
    SoundBeep, 565, 600

    text := mbtnstate = 0
        ? "Mbutton - Feature On"
        : "Mbutton - Feature Off(original)"
    MsgBox, 0x40000, % "Mouse Middle Button", % text
}

7_ExitApplication() {
    SplashTextOn, 150,40,,% "Exit Script"
    Sleep, 400
    SplashTextOff
    ExitApp
}


LectureRecording() {
    Explorer := A_WinDir "\explorer.exe /n,/e,"
    Foldexir := "C:\Users\amana\Music\Lecture Recordings"
    ; Run, %Explorer%"%Foldexir%"
    Run, % Explorer """" Foldexir """"
}



global ClickCount
Mbutton:: fn_Mbutton_withClick() 

fn_Mbutton_withClick() {
    If (ClickCount > 0) {
        ClickCount += 1
    } else {
        ClickCount := 1
    }
    Tooltip, %ClickCount%
    SetTimer, mbclickmonitor, -1500
}

mbclickmonitor() {
    static whelscrlfn

    Switch ClickCount {
        Case 2:
            Send, {Media_Play_Pause}

        Case 3:
            MsgBox % "debug 3"
            whelscrlfn := !whelscrlfn
            Text := whelscrlfn = 0
                ? "Scroll Up   - Scroll Up`n`nScroll Down - Scroll Down"
                : "Scroll Up   - Arrow Right`n`nScroll Down - Arrow Left"
            MsgBox, 0x40000, % "Scroll Up/Down", % Text

        Case 4:
            run, Notepad

        Case 5:
            fn_Mbutton()

        Default:
            ; nothing
    }
    ClickCount := 0
    SetTimer, mbclickmonitor, Off
    Tooltip
}

;prepares dynamic menu
fn_Mbutton() {
    DynMenu := ""
    Loop
    {
        ; IfEqual, Dyn%A_Index%, , Break ;break out of loop if DynX is empty
        if (Dyn[A_Index] = "")
            Break
        ; StringGetPos, ppos, dyn%A_Index%
        ppos := InStr(Dyn[A_Index], "|")
        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%

        IfWinActive, %win%
            DynMenu := DynMenu "/" item
    }


    ;Joins sorted main menu and dynamic menu
    Sort, MenuItems, D/
    TempMenu := MenuItems . DynMenu

    MenuItem := []
    ;clears earlier entries
    Loop
    {
        ; IfEqual, MenuItem%A_Index%, , Break
        if (MenuItem[A_Index] == "") {
            Break
        }
        MenuItem[A_Index] := ""
    }

    Loop, Parse, TempMenu, /
    {
        MenuItem[A_Index] := A_LoopField
    }


    Menu := MenuTitle
    Loop
    {
        ; IfEqual, MenuItem%A_Index%, , Break
        if (MenuItem[A_Index] == "") 
            Break

        numItems++
        StringTrimLeft, MenuText,% MenuItem[A_Index], 0
        ; Menu = %Menu%`n%MenuText%
        Menu := Menu "`n" MenuText
    }

    MouseGetPos, mX, mY
    Hotkey, ~LButton, fnMenuClick
    Hotkey, ~LButton, On
    ToolTip, %Menu%, %mX%, %mY%
    WinActivate, %MenuTitle%
}


fnMenuClick() {
    ; global MenuTitle, MenuItem

    Hotkey, ~LButton, Off
    IfWinNotActive, %MenuTitle%
    {
        ToolTip
        Return
    }

    MouseGetPos, _mX, mY
    ToolTip
    mY += 10
    mY /= 23
    If (mY < 1)
        Return

    if (mY = numItems)
        Return


    TargetSection := MenuItem[mY]
    funcName := StrReplace(TargetSection, A_Space, "")
    funcName := StrReplace(funcName, ")", "_")

    %funcName%()
}

arrondark
Posts: 29
Joined: 01 May 2024, 05:27

Re: How to tooltip menu script without hotkey?

Post by arrondark » 17 May 2024, 20:30

No I can not press that quickly I was just testing out the. But I want to find out a way where right now I am trying with other ways to implement same function when I will be successful I will post them.
arrondark
Posts: 29
Joined: 01 May 2024, 05:27

Re: How to tooltip menu script without hotkey?  Topic is solved

Post by arrondark » 18 May 2024, 03:47

After all this I found a better way to deal with it. Here is my final script which does all:

Code: Select all

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
	}
If (ClickCount > 1 AND ClickCount < 4)
    Tooltip, %ClickCount%
SetTimer, mbclickmonitor, 500
return
mbclickmonitor:
If (ClickCount = 2)
	{
		Send, {Media_Play_Pause}
	}
else if (ClickCount > 2)
	{
        MNFunctionmenu()
        Menu, MNFunctions, DeleteAll
	}
ClickCount := 0
SetTimer, mbclickmonitor, Off
Tooltip,
return
#IF

#IF (whelscrlfn=1)
{
    WheelUp::Right
    WheelDown::Left
}
#IF

;============================================================================================================
;============================================================================================================
;Menu function and call
;InstantMenu is a function which can be called from any where or any if else statments
;current states of key always on top of script
;make a menu
;name of the menu is MNFunctions
MNFunctionmenu()
{
    Menu, MNFunctions, Add, Screenshot State, Screenshot1orScreenshot2State 
    Menu, MNFunctions, Add, SpeedUpDown_UnRe State, SpeedUpDownorUndoRedo_State
    Menu, MNFunctions, Add, CopyCut/CopylinkCopyCut State, CopyCutorCopylinkCopyCutState
    Menu, MNFunctions, Add, Play Pause 4 All - PlayPause 4 Nox State, MediaPlay4AllorMediaPlay4NoxState
    Menu, MNFunctions, Add
    Menu, MNFunctions, Add
    Menu, MNFunctions, Add, Media Key 4 OneNote State, MediaKey4OneNoteorMediaKey4AllState
    Menu, MNFunctions, Add, Fn Key Enable/Disable, fnkeystateenabledisable
    Menu, MNFunctions, Add, Scroll Up/Down - Arrow State, wheelupdownarrow
    Menu, MNFunctions, Add, Mouse_Middle_Button Enable/Disable , mousembuttonenabledisable
    Menu, MNFunctions, Add
    Menu, MNFunctions, Add
    Menu, MNFunctions, Add, Lecture Recordings, lectruerecordingopen
    Menu, MNFunctions, Add, Explore E_D, exploreedopen
    Menu, MNFunctions, Add
    Menu, MNFunctions, Add
    Menu, MNFunctions, Add, OneNote, OneNoterunner
    Menu, MNFunctions, Add, Calculator, calculatorrunneropen
    Menu, MNFunctions, Add, Notepad, notepadrunneropen
    Menu, MNFunctions, Add
    Menu, MNFunctions, Add
    Menu, MNFunctions, Add
    Menu, MNFunctions, Add, Exit App, exiterapp
    Menu, MNFunctions, Show
}


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

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

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

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

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

fnkeystateenabledisable:
{
	fnstate:=!fnstate
	SoundBeep, 900, 500
	if (fnstate = 1)
		{
			if (mdastate = 0)
				{
					Menu, Tray, Icon, fnenableone_all.ico
				}
			else if (mdastate = 1)
				{
					Menu, Tray, Icon, fnenableone_nox.ico
				}
		}
	else if (fnstate = 0)
		{
			if (mdastate = 0)
				{
					Menu, Tray, Icon, fndisableone_all.ico
				}
			else if (mdastate = 1)
				{
					Menu, Tray, Icon, fndisableone_nox.ico
				}
	}
}
Return

wheelupdownarrow:
{
    whelscrlfn:=!whelscrlfn
    if (whelscrlfn=0)
        {
            MsgBox, 262144, Scroll Up/Down,
            (
                Scroll Up   - Scroll Up
                `nScroll Down - Scroll Down
            )
        }
    else if (whelscrlfn=1)
        {
            MsgBox, 262144, Scroll Up/Down,
            (
                Scroll Up   - Arrow Right
                `nScroll Down - Arrow Left
            )
        } 
}
Return

mousembuttonenabledisable:
{
    mbuttonstate:=!mbuttonstate
    if (mbuttonstate=0)
        {
            SplashTextOn,350,100,,Scroll Button Disable
            Sleep 400
            SplashTextOff
        }
    else if (whelscrlfn=1)
        {
            SplashTextOn,350,100,,Scroll Button Enable
            Sleep 400
            SplashTextOff
        } 
}
Return

lectruerecordingopen:
run, C:\Users\amana\Music\Lecture Recordings
Return

exploreedopen:
run, C:\DaTa\E_D
Return

OneNoterunner:
run, ONENOTE
Return

calculatorrunneropen:
run, Calc
Return

notepadrunneropen:
run, Notepad
Return

exiterapp:
{
    SplashTextOn,150,40,,Exit Script
    Sleep 400
    SplashTextOff
    ExitApp
}
Return

arrondark
Posts: 29
Joined: 01 May 2024, 05:27

Re: How to tooltip menu script without hotkey?

Post by arrondark » 18 May 2024, 06:30

Thanks CoffeeChaton for organizing the code it feels little off too me(but it still works flawlessly in the conventional way(not having if statements)). I am still new so I need to learn many things.
Post Reply

Return to “Ask for Help (v1)”