opening the windows virtual keyboard

267 views
Skip to first unread message

Ronaldo Geniais

unread,
Jun 1, 2021, 8:48:26 AM6/1/21
to Harbour Users
I created a button on a form with the action of opening the windows virtual keyboard, but it doesn't open.
I already have a button that opens the calculator and it works fine, but opening the virtual keyboard doesn't work.
I'm doing it like this:

cvirtualkeyb := "c:\windows\system32\osk.exe"
EXECUTE FILE (cvirutalkeyb)

Does not open, when opening the calculator, it works.

ccalc := "c:\windows\system32\calc.exe"
EXECUTE FILE (ccalc)
This one works.

I also tried with ShellExecute( 0, "Open", cVirtualKeyb,,, 3 )

Auge & Ohr

unread,
Jun 1, 2021, 8:57:24 AM6/1/21
to Harbour Users
hi,

are you working under 64 Bit OS an try to call OSK.EXE from 64 Bit App ?

as i can say you need to disable "Wow64EnableWow64FsRedirection" on 64 Bit OS when call OSK.EXE

Jimmy

Ronaldo Geniais

unread,
Jun 1, 2021, 9:46:49 AM6/1/21
to Harbour Users
Hi Jimmy
thanks for the tip.
I looked at the documentation you indicated, but I didn't understand how to do it.

Auge & Ohr

unread,
Jun 1, 2021, 6:54:30 PM6/1/21
to Harbour Users
for HMG i use

#include "HMG.CH"
#include "dll.ch"

PROCEDURE ShowOSK()
LOCAL windir := GETENV( "windir" )
STATIC lOpen := .F.

   IF lOpen = .F.
      lOpen := .T.

      IF Is64Bit()
         HMG_CallDLL( "Kernel32.dll", DLL_OSAPI, "Wow64EnableWow64FsRedirection", FALSE )  // disable before API Call
      ENDIF

      _EXECUTE( 0,, VirtualKeyboard.FULLFILENAME, "ON",, 5 )
      hb_IdleSleep( 1 )   // Wait until the application is loaded

      IF Is64Bit()
         HMG_CallDLL( "Kernel32.dll", DLL_OSAPI, "Wow64EnableWow64FsRedirection", TRUE )    // enable again
      ENDIF
   ELSE
      lOpen := .F.
      FindAndCloseProcress( "OSK.EXE" )
   ENDIF

RETURN

Jimmy

Ronaldo BLima

unread,
Jun 1, 2021, 7:37:49 PM6/1/21
to harbou...@googlegroups.com
Jimmy
i try your code but 
system complains about virtualkeyboard.FULLFILENAME 
replaces with C:\WINDOWS\SYSTEM32\OSK.EXE 
and when compiling, complains about  _HB_FUN_IS64BIT'

--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to a topic in the Google Groups "Harbour Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/harbour-users/_pqCKcDN8mo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to harbour-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-users/03f33543-1f0f-4e74-bec1-fb0716a5055an%40googlegroups.com.

Ivanil Marcelino

unread,
Jun 1, 2021, 8:44:58 PM6/1/21
to harbou...@googlegroups.com
is64Bit não é uma função é uma translate, talvez você não tenha colocado o cabeçalho;

at;

You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-users/CAB82cs%3Da%2B2hqXziTqnTmcZ9bbhV%3DCxwJ%2BU-Cqg2nzBBLLFxWGA%40mail.gmail.com.


--

Paul Smith

unread,
Jun 1, 2021, 11:32:40 PM6/1/21
to Harbour Users
Hi Ronaldo
It works on a 64 bit machine if you make it as 64 bit executable
or on a 32 bit machine as a 32bit executable. I don't currently have HB32 as 64 bit
so my 64 bit test was using Victors' HB34
Cheers
Paul

using:
hbmk2 test -cpu=x64 -mt

//test.prg
FUNCTION MAIN
mtest = space(10)
hb_threadStart( @osk() )

DO WHILE LASTKEY() <> 27
   @ 0,0 CLEAR
   @ 08,10 SAY "ESC to exit"
   @ 10,10 SAY "Test word   " GET mtest PICTURE "@k"
   READ
ENDDO
//add in a tidy way to close OSK.exe

FUNCTION OSK()
Hb_processrun("osk.exe")
RETURN nil

Paul Smith

unread,
Jun 2, 2021, 12:20:39 AM6/2/21
to Harbour Users
Hi Ronaldo
I also found that if I copied a 32 bit version of osk.exe and  msswch.dll from a 32 bit version of windows7
it worked fine on a 64 bit machine running either a 32 bit or 64 bit executable of test.exe
Cheers
Paul

Auge & Ohr

unread,
Jun 2, 2021, 5:48:10 AM6/2/21
to Harbour Users
hi,

VirtualKeyboard
Opens the Virtual Keyboard of the System
      - VirtualKeyboard.FileName         --> "OSK.EXE"
      - VirtualKeyboard.FullFileName     --> GetSystemDir()+"\OSK.EXE"

FUNCTION Is64Bit()
RETURN IF( FILE( "C:\WINDOWS\SysWOW64\Format.COM" ), .T., .F. )

Jimmy

Bernard Mouille

unread,
Jun 2, 2021, 6:26:08 AM6/2/21
to Harbour Users
Hello,
In hb32 :
wapi_GetSystemDirectory()
wapi_GetWindowsDirectory()
hb_osIs64bit()


Regards,
Bernard.

Ronaldo Geniais

unread,
Jun 2, 2021, 9:51:43 AM6/2/21
to Harbour Users
thank you friends,
It works, with some tweaks I made to the code sent by Jimmy.
see below:

/*************/

#include "minigui.ch"
#include "dll.ch"           //calldll.lib

PROCEDURE Exec_KeyVirtual()
LOCAL windir := GETENV( "windir" ) 
STATIC lOpen := .F.

Private cVirtualKeyboard := WINDIR+"\SYSTEM32\OSK.EXE"    

IF lOpen = .F.
   lOpen := .T.

   IF IsWin64() //Is64Bit()
      HMG_CallDLL( "Kernel32.dll", DLL_OSAPI, "Wow64EnableWow64FsRedirection", FALSE )  // disable before API Call
   ENDIF

   _EXECUTE( 0,,cVirtualKeyboard, "ON",, 5 )   //VirtualKeyboard.FULLFILENAME
   hb_IdleSleep( 1 )   // Wait until the application is loaded

   IF IsWin64()  //Is64Bit()
      HMG_CallDLL( "Kernel32.dll", DLL_OSAPI, "Wow64EnableWow64FsRedirection", TRUE )    // enable again
   ENDIF
ELSE
   lOpen := .F.
   *FindAndCloseProcress( "OSK.EXE" )    // funcao nao encontrada
ENDIF

RETURN
/**********/
Reply all
Reply to author
Forward
Message has been deleted
0 new messages