IonicWind Software

IWBasic => General Questions => Topic started by: Andy on August 18, 2018, 06:06:23 AM

Title: Windows 10 users (a little test)
Post by: Andy on August 18, 2018, 06:06:23 AM
Hi,

For those of you who are on Windows 10 (64 bit) I wonder if you could do a little test for me please.

Here is a simple program with one button which is a keyboard bitmap image loaded onto it (bitmap attached).

Can you tell me when you click on the keyboard button if it opens your on screen keyboard?

AUTODEFINE "off"

window mainwin
OPENWINDOW mainwin,0,0,500,300,@CAPTION|@SYSMENU,0,"On screen keyboard",&mainhandler

'On screen keyboard
CONTROL mainwin,@BUTTON,"",200,90,50,25,@CTLBTNBITMAP,1
SETCONTROLTEXT mainwin,1,GETSTARTPATH+"keyboard.bmp"
WAITUNTIL mainwin = 0
END

SUB mainhandler(),INT
SELECT @MESSAGE
CASE @IDCLOSEWINDOW
         closewindow mainwin
         end

CASE @IDCREATE
CENTERWINDOW mainwin

CASE @IDCONTROL
SELECT @CONTROLID
CASE 1
IF @NOTIFYCODE=0
system "osk.exe"   'On Screen keyboard
ENDIF
ENDSELECT
ENDSELECT
RETURN 0
ENDSUB


Thanks,

Andy.
Title: Re: Windows 10 users (a little test)
Post by: Egil on August 18, 2018, 07:02:58 AM
Did not work on my win10/64 laptop... sorry.
Screendump below says "Unable to start On-Screen Keyboard" in norwegian.


Egil
Title: Re: Windows 10 users (a little test)
Post by: billhsln on August 18, 2018, 11:52:03 AM
Windows 10 Pro laptop with touch screen, program comes up, clicked on keyboard icon, nothing happens.  Put in messagebox's and it is going thru the code, just does nothing.  Went to DOS command prompt, did OSK.EXE and it did bring up the keyboard.

Tried: system "C:\\Windows\\System32\\osk.exe"   'On Screen keyboard

Still did nothing.

Bill
Title: Re: Windows 10 users (a little test)
Post by: Brian on August 18, 2018, 12:28:42 PM
Andy's code worked for me OK, without any alteration

Brian
Title: Re: Windows 10 users (a little test)
Post by: Andy on August 18, 2018, 10:36:54 PM
Thanks guys for that.

Bill / Egil,

Could you have a look for me please and tell me does 

OSK.exe exist in your C:\Windows\SysWOW64 folder?

If so, could you try changing the System path in the program to C:\Windows\SysWOW64 to see if that works.

I've also just read that you can use cmd.exe to invoke OSK.exe, but at the moment I can't test that as I can't remember the switches needed.

Thanks,
Andy.
Title: Re: Windows 10 users (a little test)
Post by: Egil on August 19, 2018, 12:59:36 AM
QuoteOSK.exe exist in your C:\Windows\SysWOW64 folder?
If so, could you try changing the System path in the program to C:\Windows\SysWOW64 to see if that works.

The file exists in that folder, but changing the system path does not help, neither does doubleclicking the filename from within that system folder.
So I'm starting to beleive that there is something with the system setup on my laptop blocking such calls.

My screen is not touch sensitive, so maybe it only works with such screens???


Egil
Title: Re: Windows 10 users (a little test)
Post by: billhsln on August 19, 2018, 01:40:37 AM
Mine exists only in C:\Windows\System32.  There are no parameters required when I ran it from the command prompt, but it did work from the command prompt.

Bill
Title: Re: Windows 10 users (a little test)
Post by: Andy on August 19, 2018, 03:08:03 AM
Thanks guys again for that.

Could you try amending the system path to:

C:\Windows\Sysnative\osk.exe

I've read that this is a special (hidden) folder that allows 32 bit applications to invoke 64 bit ones.

At least that's what I've just read.

Andy.
:)
Title: Re: Windows 10 users (a little test)
Post by: Egil on August 19, 2018, 05:11:58 AM
Does not work here Andy.


Egil
Title: Re: Windows 10 users (a little test)
Post by: Andy on August 19, 2018, 05:35:44 AM
No it doesn't Egil, just been to my friends with 64 bit Win 7, no luck there either.

I need a way around this, maybe a batch file or something?

We must be able to start the on screen keyboard program some way surely?

Any ideas anyone?

Andy.
Title: Re: Windows 10 users (a little test)
Post by: fasecero on August 19, 2018, 08:03:51 AM
This works for me but it can have wac problems if it is not handled by the shell


$INCLUDE "windowssdk.inc"

SUB ShowScreenKeyboard() ' WIN LOGO + CTRL + O
keybd_event(VK_LWIN, VK_LWIN, 0, 0)
keybd_event(VK_LCONTROL, VK_LCONTROL, 0, 0)
keybd_event(0x4F, 0x4F, 0, 0)
keybd_event(0x4F, 0x4F, KEYEVENTF_KEYUP, 0)
keybd_event(VK_LCONTROL, VK_LCONTROL, KEYEVENTF_KEYUP, 0)
keybd_event(VK_LWIN, VK_LWIN, KEYEVENTF_KEYUP, 0)
ENDSUB
Title: Re: Windows 10 users (a little test)
Post by: Andy on August 20, 2018, 12:30:00 AM
Thanks Fasecero,

Not sure how to implement what you've posted?

I have found a free alternative 32 bit virtual keyboard program which can be installed on 64 bit windows and executed from any IWB program.

So that's one way around it, but still curious to find a way to invoke the osk.exe in a 64 bit environment.

I tried creating a batch file:


@cecho=off
cd "C:\"
cd "C:\Windows\System32"
start osk.exe
exit


I called it "key.bat" and placed it on the desktop.

Clicking it worked, but again calling it from the SYSTEM command didn't.

Andy.


Title: Re: Windows 10 users (a little test)
Post by: srvaldez on August 20, 2018, 06:11:51 AM
it could be a permission problem, recently I installed VB6 on Windows 10 and while testing out one of my programs, it failed to run because of the use of SendKey, apparently Windows considers that a security risk.
Title: Re: Windows 10 users (a little test)
Post by: Andy on August 20, 2018, 06:18:59 AM
Yes, you are right, it could be a permissions problem.

Just thought it was much easier to install a free alternative on screen keyboard with no issues.

Thanks,
Andy.
:)
Title: Re: Windows 10 users (a little test)
Post by: fasecero on August 20, 2018, 09:32:14 AM
Quote
Not sure how to implement what you've posted?

Just call ShowScreenKeyboard() and the keyboard should show appear on the screen if you have the same keyboard shortcut to open it :) (WIN LOGO + CTRL + O).

I did some research and this is what I have found. Your code is not working because the System32 directory is reserved for 64-bit applications on 64-bit Windows. To access that folder from 32 bits you must disable the "file system redirection" briefly, do what you want and then enable it again. The following code is only for 64 bit system:


$INCLUDE "windowssdk.inc"
$INCLUDE "Shlobj.inc"

OPENCONSOLE
PRINT

CoInitialize(0)
ShowScreenKeyboard()
CoUninitialize()

PRINT
PRINT "Press any key to exit"
DO:UNTIL INKEY$ <> ""
CLOSECONSOLE

SUB ShowScreenKeyboard()
pointer ptr
istring szPath[MAX_PATH] = ""

IF _Wow64DisableWow64FsRedirection(ptr) THEN
ExpandEnvironmentStrings("%windir%\system32\osk.exe", &szPath, MAX_PATH)
SYSTEM szPath ' ShellExecute (0, "runas", szPath, "", "", SW_SHOWNORMAL)
_Wow64RevertWow64FsRedirection(ptr)
ENDIF
ENDSUB

DECLARE Wow64DisableWow64FsRedirectionTemplate(pointer ptr), INT

SUB _Wow64DisableWow64FsRedirection(pointer ptr), INT
UINT hInst=LoadLibrary("kernel32.dll")

IF hInst THEN
UINT proc = GetProcAddress(hInst, "Wow64DisableWow64FsRedirection")

IF proc THEN
RETURN !<Wow64DisableWow64FsRedirectionTemplate>proc(ptr)
ENDIF

FreeLibrary(hInst)
ENDIF

RETURN 0
ENDSUB

DECLARE Wow64RevertWow64FsRedirectionTemplate(pointer ptr), INT

SUB _Wow64RevertWow64FsRedirection(pointer ptr), INT
UINT hInst=LoadLibrary("kernel32.dll")

IF hInst THEN
UINT proc = GetProcAddress(hInst, "Wow64RevertWow64FsRedirection")

IF proc THEN
RETURN !<Wow64RevertWow64FsRedirectionTemplate>proc(ptr)
ENDIF

FreeLibrary(hInst)
ENDIF

RETURN 0
ENDSUB


if the SYSTEM command fail (it can) you need to start the process as administrator using ShellExecute + "runas"

ShellExecute (0, "runas", szPath, "", "", SW_SHOWNORMAL)

Also, Windows 10 has a new on screen keyboard but to use it you need to implement IValueProvider/ITextProvider COM objects in your control to achieve this but this is a very advanced topic.
Title: Re: Windows 10 users (a little test)
Post by: Andy on August 21, 2018, 01:34:46 AM
Fasecero,

Thanks, you have put a lot of work into this and it is greatly appreciated!

This is an advanced topic, one that shouldn't need to be as any 32 program really should be able to open something as simple as the built in on screen keyboard.

After considering what's been posted, I have decided to go with the free virtual keyboard, it just keeps life simple, but thanks to all for your suggestions.

Thanks,
Andy.
:)
Title: Re: Windows 10 users (a little test)
Post by: fasecero on August 21, 2018, 09:04:46 AM
No worries. This is a hobby to me and I enjoy a lot playing with this stuff no matter how crazy it sounds. It has become so much easier with the passage of time and I had had the best teachers anyone could hope for in the past. That soft it's probably your best bet if the license allows its redistribution for third-party usage.