ToolTipFont / ToolTipColor deactivates the rest of my script

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Gregorian
Posts: 22
Joined: 29 Aug 2020, 09:02

ToolTipFont / ToolTipColor deactivates the rest of my script

06 Oct 2020, 22:15

So, I have a script with the only function to deactivate all my other scripts when I press tab, and reactivate them when I press tab again.
I also made it so that whenever my AHK scripts are deactivated, it will show me a tooltip in the upper left corner, saying: "HOTKEYS-ARE-SUSPENDED"
It works flawlessly. It helps me to be able to write without accidentally activating any AHK scripts while writing.

But the tooltip is too small to see for me, so I searched for a way to make it bigger. I found lexikos' "ToolTipFont / ToolTipColor - options for the ToolTip command" script:
https://www.autohotkey.com/boards/viewtopic.php?f=6&t=4777

It's an AHK script that can make the tooltip font bigger.

So I tried it with my script, and it works, it does make the tooltip bigger. However, then it doesn't suspend my hotkeys anymore!

Does anyone know what I can do?

Code: Select all

#IfWinActive ahk_exe Resolve.exe
{
Write_mode:=1
Tab::
if (Write_mode=0)
	{
	ToolTip
	Write_mode:=1
	}
else
	{
	ToolTipFont("s20", "Comic Sans MS")
	ToolTipColor("Black", "White")
	ToolTip, HOTKEYS-ARE-SUSPENDED, 0, 0
	Write_mode:=0
	}
DetectHiddenWindows, On
WM_COMMAND := 0x111
ID_FILE_SUSPEND := 65404
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\quick zoom.ahk ahk_class AutoHotkey
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\B = Back to last stop and play.ahk ahk_class AutoHotkey
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\TimeLineClick-master\TimelineClick.ahk ahk_class AutoHotkey
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\Ripple delete start to playhead.ahk ahk_class AutoHotkey
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\Ripple delete end to playhead.ahk ahk_class AutoHotkey
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\Change transition length.ahk ahk_class AutoHotkey
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\Create Cross Dissolve Transition.ahk ahk_class AutoHotkey
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\Change Cross Dissolve Transition to Smooth Cut transition.ahk ahk_class AutoHotkey
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\Change Cross Dissolve Transition to Dip to Color Dissolve Transition.ahk ahk_class AutoHotkey
Return
}
Last edited by gregster on 06 Oct 2020, 22:43, edited 1 time in total.
Reason: Moved to 'Ask For Help'.
User avatar
mikeyww
Posts: 27096
Joined: 09 Sep 2014, 18:38

Re: ToolTipFont / ToolTipColor deactivates the rest of my script

06 Oct 2020, 22:51

One thing I noticed is that your first variable assignment occurs after #If.. That is a no-no: #If.. statements are used to create context-sensitive hotkeys and hotstrings. They are not for running other forms of code. Read about auto-execute.
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: ToolTipFont / ToolTipColor deactivates the rest of my script

06 Oct 2020, 23:05

Try changing Write_mode to a one liner toggle:

Code: Select all

#IfWinActive ahk_exe Resolve.exe
Tab::
Write_mode:=!Write_mode
if (Write_mode=0)
	ToolTip
else
	{
	ToolTipFont("s20", "Comic Sans MS")
	ToolTipColor("Black", "White")
	ToolTip, HOTKEYS-ARE-SUSPENDED, 0, 0
	}
DetectHiddenWindows, On
WM_COMMAND := 0x111
ID_FILE_SUSPEND := 65404
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\quick zoom.ahk ahk_class AutoHotkey
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\B = Back to last stop and play.ahk ahk_class AutoHotkey
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\TimeLineClick-master\TimelineClick.ahk ahk_class AutoHotkey
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\Ripple delete start to playhead.ahk ahk_class AutoHotkey
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\Ripple delete end to playhead.ahk ahk_class AutoHotkey
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\Change transition length.ahk ahk_class AutoHotkey
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\Create Cross Dissolve Transition.ahk ahk_class AutoHotkey
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\Change Cross Dissolve Transition to Smooth Cut transition.ahk ahk_class AutoHotkey
PostMessage, WM_COMMAND, ID_FILE_SUSPEND,,, %A_WorkingDir%\Change Cross Dissolve Transition to Dip to Color Dissolve Transition.ahk ahk_class AutoHotkey
Return
You could also move
DetectHiddenWindows, On
WM_COMMAND := 0x111
ID_FILE_SUSPEND := 65404


To the top of the script in AutoExec section.
User avatar
rommmcek
Posts: 1478
Joined: 15 Aug 2014, 15:18

Re: ToolTipFont / ToolTipColor deactivates the rest of my script

06 Oct 2020, 23:10

lexikos wrote:
05 Oct 2014, 00:47
Caution: Hooking messages which can interrupt AutoHotkey's commands...
You can try alternative for one script or if you're not too picky for all (standard) ToolTips.
User avatar
mikeyww
Posts: 27096
Joined: 09 Sep 2014, 18:38

Re: ToolTipFont / ToolTipColor deactivates the rest of my script

06 Oct 2020, 23:25

Yet another method for the tip!

Code: Select all

tip("No more!")
Sleep, 2000
tip()
Return

tip(text := "") {
 If !text {
  Gui, Tip:Hide
  SoundBeep, 1000, 20
  Return
 }
 Static width := 100, height := 30
 Gui, Tip:New, Border -Caption
 Gui, Font, s10 bold
 Gui, Color, FDF360
 Gui, Add, Text,, %text%
 x := A_ScreenWidth - width - 4, y := A_ScreenHeight - height - 7
 Gui, Show, x%x% y%y% w%width% h%height%
 SoundBeep, 1500, 20
}

F4::
SoundBeep, 1000, 20
ExitApp
Gregorian
Posts: 22
Joined: 29 Aug 2020, 09:02

Re: ToolTipFont / ToolTipColor deactivates the rest of my script

06 Oct 2020, 23:58

Xtra wrote:
06 Oct 2020, 23:05
Try changing Write_mode to a one liner toggle
I tried it. Still the same result as before. The tooltip will show up with a bigger font, but my hotkeys won't be suspended.
Xtra wrote:
06 Oct 2020, 23:05
You could also move
DetectHiddenWindows, On
WM_COMMAND := 0x111
ID_FILE_SUSPEND := 65404


To the top of the script in AutoExec section.
I tried this as well now. Still the same result as before. The tooltip will show up with a bigger font, but my hotkeys won't be suspended.
Gregorian
Posts: 22
Joined: 29 Aug 2020, 09:02

Re: ToolTipFont / ToolTipColor deactivates the rest of my script

06 Oct 2020, 23:59

mikeyww wrote:
06 Oct 2020, 23:25
Yet another method for the tip!
When I copy and paste your code into an empty AHK file and execute it, it simply makes 1 sound, then waits a couple of seconds, and then makes another sound.
I see no tooltip anywhere on the screen.

I don't understand how this is helping me.
Gregorian
Posts: 22
Joined: 29 Aug 2020, 09:02

Re: ToolTipFont / ToolTipColor deactivates the rest of my script

07 Oct 2020, 00:00

rommmcek wrote:
06 Oct 2020, 23:10
lexikos wrote:
05 Oct 2014, 00:47
Caution: Hooking messages which can interrupt AutoHotkey's commands...
You can try alternative for one script or if you're not too picky for all (standard) ToolTips.
Do these alternatives allow me to make the font of the tooltip bigger?
Gregorian
Posts: 22
Joined: 29 Aug 2020, 09:02

Re: ToolTipFont / ToolTipColor deactivates the rest of my script

07 Oct 2020, 00:01

mikeyww wrote:
06 Oct 2020, 22:51
One thing I noticed is that your first variable assignment occurs after #If.. That is a no-no: #If.. statements are used to create context-sensitive hotkeys and hotstrings. They are not for running other forms of code. Read about auto-execute.
Could you please tell me how I could write it better?
I only want it to run when the program Davinci Resolve is active and in focus.
User avatar
rommmcek
Posts: 1478
Joined: 15 Aug 2014, 15:18

Re: ToolTipFont / ToolTipColor deactivates the rest of my script

07 Oct 2020, 00:22

Gregorian wrote:
07 Oct 2020, 00:00
Do these alternatives allow me to make the font of the tooltip bigger?
That's the main point! The first one is for individual script with more functionality, the second one is for all ToolTips even those generated by third part applications and easy to use (run the script and that's it for all (standard) Tooltips on your PC)!
User avatar
mikeyww
Posts: 27096
Joined: 09 Sep 2014, 18:38

Re: ToolTipFont / ToolTipColor deactivates the rest of my script

07 Oct 2020, 00:45

This is just an example. Replace the MsgBox with your suspension commands. Use the other tooltip routine if you prefer it.

Code: Select all

#IfWinActive ahk_exe Resolve.exe
Tab::
If (susp := !susp) {
 MsgBox, 48, Suspended, Do some suspend commands here.
 tip("No more!")
} Else {
 MsgBox, 64, Running, Do some unsuspend commands here.
 tip()
}
Return
#IfWinActive

tip(text := "") {
 If !text {
  Gui, Tip:Hide
  SoundBeep, 1000, 20
  Return
 }
 Static width := 100, height := 30
 Gui, Tip:New, Border -Caption AlwaysOnTop
 Gui, Font, s10 bold
 Gui, Color, FDF360
 Gui, Add, Text,, %text%
 x := A_ScreenWidth - width - 4, y := A_ScreenHeight - height - 7
 WinGetActiveTitle, winTitle
 Gui, Show, x%x% y%y% w%width% h%height%
 SoundBeep, 1500, 20
 WinActivate, %winTitle%
}
Last edited by mikeyww on 07 Oct 2020, 00:52, edited 1 time in total.
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: ToolTipFont / ToolTipColor deactivates the rest of my script

07 Oct 2020, 00:48

but my hotkeys won't be suspended.
Make sure your suspend script and your scripts to be suspended are in the same folder.

or set A_WorkingDir appropriately,

HTH

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 142 guests