Display message by pressing key Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
kjaty
Posts: 36
Joined: 10 Dec 2019, 22:02

Display message by pressing key

27 Dec 2019, 17:52

I am trying to make that when pressing a key a message is issued, example "Macro Enabled", but only the smallest alert possible on the screen, no button to click and etc., only appears when pressing the key and disappears after 3 seconds. I tried some things with the help of the forum, but this is where my problems begin.
First: In my code so far the message appears only with a button and I do not want any button just a small message on the screen.
Second: I will use 3 keys and when I switch between one button and another sometimes I have to press 2 times each button for the message to appear.
Can someone help me?
I am adding the code for analysis.

Code: Select all

#NoEnv
SendMode Input

~1 Up::Suspend, OFF
~2 Up::Suspend, ON
~G Up::Suspend, ON
!1 Up::Suspend, OFF
!2 Up::Suspend, ON
;~Tab Up::Suspend, ON
;~WheelDown::Suspend, Off
;~WheelUp::Suspend, On


1::
SetTimer, Macro, -100
MsgBox,, macro, is Active, 2
Return

2::
SetTimer, Macro, -100
MsgBox,, macro, is Disabled, 2
Return

G::
SetTimer, Macro, -100
MsgBox,, macro, is Disabled, 2
Return
Macro:
Loop, 4
{
	SoundPlay, *-1
	Sleep, 1000
}
Return
User avatar
flyingDman
Posts: 2821
Joined: 29 Sep 2013, 19:01

Re: Display message by pressing key  Topic is solved

27 Dec 2019, 18:13

Other than building a specific gui for this, you can use a tooltip or a progress bar (w/o bar). Both will require a method to remove the tooltip or the progress after your 3 seconds. Test them out:

Code: Select all

#\::
tooltip,macro is diabled, % a_screenwidth/2, % a_screenheight/2
SetTimer, RemoveToolTip, 3000
return

RemoveToolTip:
tooltip
return

#]::
Progress, fm10 zh0 zy0 CWffffff CT000000 h40 w150, ,macro disabled, % " "
SetTimer, RemoveProgress, 3000
return

RemoveProgress:
Progress, off
return
14.3 & 1.3.7
kjaty
Posts: 36
Joined: 10 Dec 2019, 22:02

Re: Display message by pressing key

27 Dec 2019, 19:08

flyingDman wrote:
27 Dec 2019, 18:13
Other than building a specific gui for this, you can use a tooltip or a progress bar (w/o bar). Both will require a method to remove the tooltip or the progress after your 3 seconds. Test them out:

Code: Select all

#\::
tooltip,macro is diabled, % a_screenwidth/2, % a_screenheight/2
SetTimer, RemoveToolTip, 3000
return

RemoveToolTip:
tooltip
return

#]::
Progress, fm10 zh0 zy0 CWffffff CT000000 h40 w150, ,macro disabled, % " "
SetTimer, RemoveProgress, 3000
return

RemoveProgress:
Progress, off
return

It worked this way for two keys, but I need it to work for 4 different keys.
Sorry if you're asking silly questions, but I'm new to the subject.
OCP
Posts: 98
Joined: 28 Mar 2018, 19:28

Re: Display message by pressing key

27 Dec 2019, 19:28

to display text when i pressed a hotkey or gui label i used to work something like this into my code
replace your text and any option you like to alter and dont mess with the comma's on the end

; on top
Coordmode,mouse,screen

; in your hotkey or label
mouseGetPos,mx,my
mx+=25 ; set a offset x
my-=15 ; set a offset y
Progress, cw465155 CTFFFFFF W105 ZX1 ZY1 x%mx% y%my% m b fs14 zh0,Your Text, , , Arial

w105 is width
fs14 is font size
CT FFFFFF is text color
cw 465155 is background color
for the other options plz refer to docs

to get rid of the text after a set time you need to use {progress, off} you could use sleep or a settimer to do that

; sleep example
Sleep 400
Progress, Off

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Archimede, Bing [Bot], Chunjee, Ruediger Loos and 334 guests