Calculator with numlock on

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Elaphe666
Posts: 131
Joined: 28 Nov 2015, 11:39

Calculator with numlock on

18 Jul 2017, 05:05

How can I make Pgup also close the Calculator and set numlock off, when it has already been opened?

Code: Select all

$Pgup:: ; Runs calculator with numlock on
run, c:\windows\system32\calc.exe
winwaitactive, ahk_class SciCalc
GetKeyState, state, numlock, T
if state = u
SetNumLockState, On
winwaitclose, ahk_class SciCalc
GetKeyState, state, numlock, T
if state = d
SetNumLockState, Off
return
Trigg
Posts: 97
Joined: 07 Apr 2017, 19:43

Re: Calculator with numlock on

18 Jul 2017, 10:52

Elaphe666 wrote:How can I make Pgup also close the Calculator and set numlock off, when it has already been opened?
Maybe try IfWinExist

Code: Select all

$Pgup:: ; Runs calculator with numlock on
IfWinExist, Calculator
	{
	WinClose, Calculator
	SetNumLockState, On
	}
Else
	{
	Run, Calc
	SetNumLockState, Off
	}
Return
Elaphe666
Posts: 131
Joined: 28 Nov 2015, 11:39

Re: Calculator with numlock on

18 Jul 2017, 15:54

The problem is with winwaitclose, ahk_class SciCalc. At that point, the hotkey script is waiting until the user closes the calculator, so pressing Pgup (which should close the calculator) is ignored.
Elaphe666
Posts: 131
Joined: 28 Nov 2015, 11:39

Re: Calculator with numlock on

25 Jul 2017, 04:21

Can't anyone find a solution to this problem?
Rohwedder
Posts: 7647
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Calculator with numlock on

25 Jul 2017, 05:08

Hallo,
simple let the numlock off!

Code: Select all

#IfWinActive, ahk_class SciCalc
NumpadIns::0
NumpadEnd::1
NumpadDown::2
NumpadPgDn::3
NumpadLeft::4
NumpadClear::5
NumpadRight::6
NumpadHome::7
NumpadUp::8
NumpadPgUp::9
NumpadDot::.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Araphen, Descolada, Joey5, JPMuir, KolaBorat, matt101 and 174 guests