Check if osk.exe is opened then close...

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
4k3or3et
Posts: 35
Joined: 23 Jan 2019, 13:58

Check if osk.exe is opened then close...

27 Jan 2019, 10:06

Hi guys

I have strange issue with osk.exe process which is Windows 10's On-Screen Keyboard.

I would like to check if osk.exe is running. If it is, close it, if it is not then open in. Sort of toggle mode.

The scripts i use is:

Code: Select all

#notrayicon
#singleinstance force

Process, Exist, osk.exe
If ErrorLevel != 0
	Process, Close, osk.exe
Else
	Run, osk.exe
It simply does not close On-Screen Keyboard when it is running but it opens it when it is not running.

Weird thing is that if i change all osk.exe to foobar2000.exe it works with Foobar2000 app. Anybody has a clue why osk.exe is different? Thank you.
AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: Check if osk.exe is opened then close...

27 Jan 2019, 10:51

try running your script as admin
4k3or3et
Posts: 35
Joined: 23 Jan 2019, 13:58

Re: Check if osk.exe is opened then close...

27 Jan 2019, 12:53

AHKStudent wrote:
27 Jan 2019, 10:51
try running your script as admin
Unfortunately while running converted file as Administrator the situation gets other way around. It cannot open OSK but it can close it when previously opened manually. The error is:

Code: Select all

---------------------------
test.exe
---------------------------
Error:  Failed attempt to launch program or document:
Action: <c:\windows\system32\osk.exe>
Params: <>

Specifically: The system cannot find the file specified.



	Line#
--->	007: Run,c:\windows\system32\osk.exe

The current thread will exit.
---------------------------
OK   
---------------------------
The path

Code: Select all

c:\windows\system32\osk.exe
works when i paste it into Run window. Any other clues guys?
4k3or3et
Posts: 35
Joined: 23 Jan 2019, 13:58

Re: Check if osk.exe is opened then close...

29 Jan 2019, 14:21

The solution is to create shortcut

Code: Select all

taskill /f /im osk.exe
then edit the properties and set to run it as Administrator. Then the script is:

Code: Select all

#notrayicon
#singleinstance force
Process, Exist, osk.exe
If ErrorLevel != 0
run, "PATH_TO_SCRIPT"
Else
Run, osk.exe
Thank you.
User avatar
labrint
Posts: 379
Joined: 14 Jun 2017, 05:06
Location: Malta

Re: Check if osk.exe is opened then close...

29 Nov 2021, 03:49

Code: Select all

Run, %A_WinDir%\system32\osk.exe,,, OSKPID

Sleep, 2000

Loop,
{
Process, Exist, osk.exe
If ErrorLevel != 0
	SendInput, #^o

If ErrorLevel = 0
	Break

Sleep, 1000
}	


Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Aqualest, Bing [Bot], serenite and 183 guests