Pause and suspend with one key Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
roeleboele
Posts: 36
Joined: 24 Nov 2022, 02:39

Pause and suspend with one key

27 May 2024, 07:49

hello
I 've seen in some documentation that you can't toggle the pause and suspend key anymore in v2
Is there an woraround for this ?
I have an tray-menu where there are some functionalities but when i press "Pause" or CTRL + esc i want to suspend and pause my script and change the tray-icon to the suspend-icon
if i press pause or ctrl+esc again the script should be unpaused and unsuspended

Code works in v1

Code: Select all

Menu, tray, add, &Afsluiten`tSHIFT + ESC, EVENT_BTNSluiten
Menu, tray, add, Her&laden`tCTRL + SHIFT + ESC, EVENT_BTNHerladen
Menu, tray, add, Sus&pend`tCTRL + ESC / PAUSE, EVENT_Suspend
^ESC:: ; CTRL + ESC
Pause:: ; PAUSE
EVENT_Suspend:
Suspend
Pause, , 1
if A_IsSuspended = 1
	Menu, Tray, Icon, Sus&pend`tCTRL + ESC / PAUSE, %A_AhkPath%, 5 ; suspend icon
Else
	Menu, Tray, NoIcon, Sus&pend`tCTRL + ESC / PAUSE, 
return
code does not work in v2

Code: Select all

tray:= A_TrayMenu
tray.add("&Afsluiten`tSHIFT + ESC", EVENT_BTNSluiten)
tray.add("Her&laden`tCTRL + SHIFT + ESC", EVENT_BTNHerladen)
tray.add("Sus&pend`tCTRL + ESC / PAUSE", EVENT_Suspend)
^ESC:: ; CTRL + ESC
Pause:: ; PAUSE
EVENT_Suspend(A_ThisMenuItem, A_ThisMenuItemPos, MyMenu)
{ ; V1toV2: Added bracket
Suspend()
Pause()
if (A_IsSuspended = 1)
	Tray.Icon("Sus&pend`tCTRL + ESC / PAUSE", A_AhkPath, "5") ; suspend icon
Else
	Tray.NoIcon("Sus&pend`tCTRL + ESC / PAUSE")
return
}
Rohwedder
Posts: 7776
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Pause and suspend with one key  Topic is solved

27 May 2024, 09:37

Hallo,
pause and suspend with one (Hot)key on/off:
try:

Code: Select all

#Requires AutoHotkey v2.0
#SuspendExempt
^ESC::Suspend(), Pause(-1) ; Pause and suspend on/off with CTRL + ESC
#SuspendExempt False
roeleboele
Posts: 36
Joined: 24 Nov 2022, 02:39

Re: Pause and suspend with one key

27 May 2024, 10:07

Rohwedder wrote:
27 May 2024, 09:37
Hallo,
pause and suspend with one (Hot)key on/off:
try:

Code: Select all

#Requires AutoHotkey v2.0
#SuspendExempt
^ESC::Suspend(), Pause(-1) ; Pause and suspend on/off with CTRL + ESC
#SuspendExempt False
Thanks a lot
For completion i changed it a little bit so the suspend menu in the tray is checked or unchecked

Code: Select all

^ESC::Suspend(), Pause(-1), Tray.ToggleCheck("Sus&pend`tCTRL + ESC / PAUSE") ; Pause and suspend on/off with CTRL + ESC
roeleboele
Posts: 36
Joined: 24 Nov 2022, 02:39

Re: Pause and suspend with one key

28 May 2024, 01:09

Is there a way to get the tray icon from v1 to a file (the red "S"-icon)
like this in v1 code

Code: Select all

Menu, Tray, Icon, Sus&pend`tCTRL + ESC / PAUSE, %A_AhkPath%, 5 ; suspend icon ahk v1
and converted to v2 but then i get an "H"

Code: Select all

Tray.SetIcon("Sus&pend`tCTRL + ESC / PAUSE",A_AhkPath,"5") ; suspend icon ahk v2
Anyone who knows where i can find those icons?
Rohwedder
Posts: 7776
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Pause and suspend with one key

28 May 2024, 02:16

Rename these AutoHotkeyA32.exe-3.txt and AutoHotkeyA32.exe-4.txt to .ico
and if required pcwIconExtractor.txt to .exe
I used this freeware from https://www.pcwelt.de/article/1135977/pcwiconextractor.html
Attachments
pcwIconExtractor.txt
(40 KiB) Downloaded 6 times
AutoHotkeyA32.exe-4.txt
(767 Bytes) Downloaded 7 times
AutoHotkeyA32.exe-3.txt
(767 Bytes) Downloaded 8 times

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: Xeilous and 21 guests