Jump to content

Recommended Posts

Posted (edited)

Long time lurker rare poster.

What's the deal with osk.exe?  Why is it's behavior so much different than calc.exe or other built in Windows stuff?  I have a tablet app that I need to be able to launch the OSK for the user when it's time to use it.  And I can't figure out an easy way to do it.

 

The code example below should illustrate the different ways I am trying and their results. 

;  This isn't working at all... not output
Run('osk.exe')

sleep(2000)

; This one pops up a message box that looks like...
; MsgBox(16, 'On-Screen Keyboard', 'Could not start On-Screen Keyboard.')
ShellExecute(@WindowsDir & '\system32\osk.exe')

sleep(2000)

; As stupid as it is this way works every time.
Send("#r")
sleep(100)
Send("osk.exe{enter}")
Run(@WindowsDir & '\system32\osk.exe')
ShellExecute('osk.exe')

don't work either in exactly the same way as the examples above.

Thanks so much.  AutoIt has been a huge part of my life/career for the past 12+ years.

Edited by Skizmata

AutoIt changed my life.

Posted

Please try it the other way round:

Run(@WindowsDir & '\system32\osk.exe')
ShellExecute('osk.exe')

According to the help file (which is your friend BTW):
Run: The full path of the program
ShellExecute: The name of the file to run

If needed set the working directory parameter so the program can find config files etc.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

Neither one of those work.  Did they work for you? I'll add them to my example code.  They do the same thing as the code already in my example. 

The run and the shell execute aren't failing do to path issues.  They both use the system path and system32 is in the path.

AutoIt changed my life.

  • Developers
Posted (edited)

These work both when ran in x64 mode for me:

#AutoIt3Wrapper_UseX64=y
Run(@ComSpec & " /c " & @WindowsDir & '\system32\osk.exe','',@SW_HIDE)
;-or-
#AutoIt3Wrapper_UseX64=y
ShellExecute(@WindowsDir & '\system32\osk.exe')

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

Thanks Jos that works for me too.  I'd love an explanation of what makes osk.exe not run from an x32 script if you have the time.

Thanks again. Jos "You da real MVP" <insert meme>

AutoIt changed my life.

  • Developers
Posted

If it were to work there should be a osk.exe in c:\windows\syswow64 since that is the c:\windows\system32  when running in x86 mode.
I believe there's only a x64 version of the OSK.exe on win10 x64.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted
7 minutes ago, Skizmata said:

I'd love an explanation of what makes osk.exe not run from an x32 script if you have the time.

Because there's no program osk.exe in the SysWOW64 directory which is the folder looked into when you use system32 in your command when running under x86. Do a search for turning off folder redirection.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

  • 7 months later...
Posted

Hello I hawe car-pc end I wont to run automatical the osk when input text cursor blink, end exit osk aftre some inactivity blink time 

While 1
$cursor = MouseGetCursor()
If $cursor = 5 or $cursor = 0 Then ShellExecute('"C:\Windows\system32\osk.exe"')
Sleep(750)
WEnd

 

  • 1 month later...
  • 4 years later...
Posted

I know this is an old topic, but for HOURS now, I tried unsuccessfully to get autoIT to launch osk.exe in Win10. ABSOLUTELY NOTHING worked. 

The feedback in the DOS prompt, when using autoIT, was usually something like "there is no such file as C:\Windows\system32\osk.exe". 

Yet, there it was, and it worked if I ran from WinExplorer or even if I used a cmd prompt.

Thanks Jos!!  for the explanation and an autoIT example that will (haven't tried it yet) finally work.

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...