OSK under Windows 10

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

OSK under Windows 10

Post by AUGE_OHR »

hi,

i have read http://www.hmgforum.com/viewtopic.php?p=35243

i try VirtualKeyboard.OPEN SHOW under 32 Bit but it does not show :(
also %windir%\system32\osk.exe does not show OSK ... hm ... :o

under System -> Setup -> Keyboard i saw OSK was disable ... so i enable it :idea:

when now try VirtualKeyboard.OPEN SHOW or %windir%\system32\osk.exe it does DISABLE that Setting :shock:

so it try

Code: Select all

%windir%\system32\osk.exe ON
and

Code: Select all

%windir%\system32\osk.exe OFF
and that is the Way it work now under Window 10 ... :lol:
it turn On/Off Switch under Setup -> Keyboard and OSK.EXE appear / disapear
have fun
Jimmy
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: OSK under Windows 10

Post by AUGE_OHR »

hi,

i can call OSK.EXE using my new #xtranslate ... but i have "no Handle" -> no Control :o

so i look for HMG_VirtualKeyboardGetHandle*** and add some Variable for Debug
*** c:\hmg.3.4.4\SOURCE\h_dialogs.prg

Code: Select all

FUNCTION __VirtualKeyboardGetHandle
__THREAD STATIC hWnd := 0
LOCAL i, nProcessID, aProcess, cProcess, cFound
LOCAL cSeek := VirtualKeyboard.FILENAME

//   IF IsValidWindowHandle (hWnd) == .F.
      hWnd := 0
      aProcess := EnumWindows ()
ALTD()
      FOR i = 1 TO HMG_LEN (aProcess)
         nProcessID := 0
         cProcess   := aProcess[i]
         GetWindowThreadProcessId (cProcess, NIL, @nProcessID)
         // this line fail
         cFound := GetProcessImageFileName(nProcessID)
         IF HMG_UPPER (cSeek) $ HMG_UPPER (cFound)
            hWnd := aProcess[i]
            EXIT
         ENDIF
      NEXT
//   ENDIF
RETURN hWnd 
my "Problem" are GetProcessImageFileName() which is EMPTY() ... :(

i got the right nProcessID (PID) from GetWindowThreadProcessId() but i can´t get Name with GetProcessImageFileName()***
*** c:\hmg.3.4.4\SOURCE\c_winapimisc.c
OSK_PID.JPG
OSK_PID.JPG (172.42 KiB) Viewed 8406 times
so what i`m doing wrong :idea:

is it a "Right" Problem of GetProcessImageFileName() :?:
https://docs.microsoft.com/en-us/window ... efilenamea
have fun
Jimmy
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: OSK under Windows 10

Post by AUGE_OHR »

hi,

i found a Sample c:\MiniGUI\SAMPLES\Advanced\GETTASKS\demo.prg ... but it does not show OSK.EXE :(

when using Xbase++ with Ot4xb it get OSK.EXE -> "Bildschirmtastatur".
OSK_Title.jpg
OSK_Title.jpg (248.54 KiB) Viewed 8384 times
i "think" the Problem is that OSK.EXE have no "Process Name" so it is not shown in MiniGUI Sample.

i have try

Code: Select all

*cFound := GetProcessImageFileName(nProcessID)
*cFound := GETPROCESSNAME(nProcessID)
*cFound := GETPROCESSFULLNAME(nProcessID)
cFound := cPid2ModName(nProcessID)

hProcess := OpenProcess(PROCESS_VM_READ+PROCESS_QUERY_INFORMATION,.F.,nPid)
when PID is 6744 (in this Sample) -> hProcess = 0 :(
work with other PID (when have Process Name like Explorer)

---

i have try Tasklist and search for OSK.EXE ... not found but "Bildschirmtastatur" work.
as it is only a Solution for German User it does not satisfy what i want.

Question : how to get Handle of OSK.EXE Windows :idea:
have fun
Jimmy
User avatar
dragancesu
Posts: 930
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia

Re: OSK under Windows 10

Post by dragancesu »

User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: OSK under Windows 10

Post by AUGE_OHR »

hi,

thx for Tip.

i have made a Xbase++ as "Stand-alone" but only for QWERTZ.
OSK_DE.jpg
OSK_DE.jpg (104.33 KiB) Viewed 7953 times
it also have anmation to "fly-away"
OSK_FlyKey.jpg
OSK_FlyKey.jpg (95.56 KiB) Viewed 7953 times
---

when try in CMD Box (as User)

Code: Select all

taskkill /f /im osk.exe
i got Error
FEHLER: Der Prozess "osk.exe" mit PID 10040 konnte nicht beendet werden.
Ursache: Zugriff verweigert
---

https://stackoverflow.com/questions/423 ... windows-10
if you looking to manifest of osk.exe you can view here next - uiAccess="true" this is User Interface Privilege Isolation (UIPI) , also read about similar problem UIAccess in Manifest Files

because osk.exe have uiAccess="true" in manifest it have Mandatory Label\High Mandatory Level in token. but your app, if running under UAC not elevated, usual have Medium Mandatory Level. as result:

A lower-privilege process cannot:

Use SendMessage or PostMessage to application windows running with higher rights. These APIs return success but silently drop the window message.

so you need have <requestedExecutionLevel level='requireAdministrator' uiAccess='false'/> in manifest or somehow run your application as elevated
---

Designing Applications to Run at a Low Integrity Level
https://docs.microsoft.com/en-us/previou

seems some more Work to close OSK.EXE ...
have fun
Jimmy
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: OSK under Windows 10

Post by AUGE_OHR »

hi,

i found a Solution with WMI

Code: Select all

   FindAndCloseProcress( "OSK.EXE" )

FUNCTION FindAndCloseProcress( cApp )
LOCAL oProcesses, oProcess, oWMI, oLocator
LOCAL lRet   := .F.

   oLocator := CreateObject( "wbemScripting.SwbemLocator" )
   IF EMPTY( oLocator )
      msginfo( "can not create wbemScripting.SwbemLocator" )
      RETURN .F.
   ELSE
      oWMI := oLocator:ConnectServer()
   ENDIF

   IF EMPTY( oWMI )
      msginfo( "can not connect oLocator:ConnectServer()" )
      RETURN .F.
   ELSE
      oProcesses = oWMI:ExecQuery( "SELECT * FROM Win32_Process" )

      IF oProcesses:Count > 0
         FOR EACH oProcess in oProcesses
            IF UPPER( TRIM( oProcess:Name ) ) = cApp
               //  msginfo( "terminate " + cApp )
               oProcess:Terminate( 0 )
               lRet := .T.
               EXIT
            ENDIF
         NEXT
      ENDIF
   ENDIF

   oProcesses := NIL
   oWMI := NIL
   oLocator := NIL
RETURN lRet
it work also for other Apps :idea:
have fun
Jimmy
Post Reply