Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

How to automatically popup keyboard in Windows 8


  • Please log in to reply
3 replies to this topic
Haupo
  • Members
  • 6 posts
  • Last active: Mar 28 2013 02:04 PM
  • Joined: 02 Mar 2013

Hello,

 

i have a Acer W510 Tablet with Windows 8 Pro.

I want to resolve the following problem:

 

When you are in desktop-mode, the touchscreen-keyboard will not automatically popup. In Metro-Mode it works correct.

The keyboard should popup when i enter a text-field in browser or an editor for example, or in word, excel, etc.

The, when i hit a place outside the text-field, the keyboard should pop-down automatically.

 

Everybody knows this funktion vom Android or IOs-Tablets, Smartphones and others.

In Win7Pro, there was such a funtction too (http://www.bleepingc...-automatically/), but in Win8Pro it only works in Metro-Mode.

 

Here there is a TechNet-Discussion about the reasons MS had for this step:

http://social.techne...b5-2ddcc0fbcdf8

 

So i found a few approaches to solve the problem, but no one works for me.

 

Here are the most promising links:

http://forum.xda-dev...=1992361&page=5

http://forum.tabletp...sktop-mode.html

 

There are ideas with C++ and Autoit, but for me the way with autohotkey is the best i think at the moment.

 

This is the full script i prefer:

 

#NoEnv

Menu, Tray, Icon , img/Enabled.ico,,1
Menu, Tray, NoStandard
	; remove standard Menu items
Menu, Tray, Click, 1
	; a single-click to activate the tray menu
Menu, Tray, Add , &off, off
	; add a item named Off that goes to the Off label
Menu, Tray, Add , &Stop Touch Service, StopTouch
	; add a item named Stop Touch Service that goes to the StopTouch label
	; Stop the Touch Service
	; This is necessary because it will be enabled if we touch the keyboard icon
	; by accident.
Menu, Tray, Add , E&xit, ButtonExit
	; add a item named Exit that goes to the ButtonExit label
Menu, Tray, Default, &off
	; When the user double-clicks the tray icon, its default menu item is launched - in this case Off

RunAsAdmin()
	; put RunAsAdmin.ahk in C:\Program Files\AutoHotkey\lib\RunAsAdmin.ahk. You may have to make the lib folder.
TabTip := A_ProgramFiles . "\Common Files\microsoft shared\ink\TabTip.exe"
	; TabTip-Variable mit Programmpfad von TapTip.exe füllen
TouchService = 1
	; TouchService-Variable mit 1 füllen

While True
{

	RegRead, KBCount, HKEY_LOCAL_MACHINE, SYSTEM\CurrentControlSet\Services\kbdclass\Enum, Count
		; Auslesen des Wertes Count in der Registry und speichern in KBCount. Count hat Wert 1 wenn Tablet Docked und 2 wenn Undocked.

	if (KBCount = 2)
	{
		; falls Tablet undocked...

        	if (TouchService < 1)
		{
	            TouchService = 1
	            Run, sc start TabletInputService
			; ...Touchservice aktivieren
	        }

		Cursor := A_Cursor
	      	Sleep, 750

	        If (Cursor = "IBeam") And (A_Cursor = "IBeam")
        	IfWinNotActive, ahk_class Windows.UI.Core.CoreWindow
			; falls Metro-Fenster nicht aktiv ist
        	IfWinNotActive, ahk_class OpusApp 
			; falls Word-Fenster nicht aktiv ist
	        {
	            osk = yes        
        	    Run, "%TabTip%"
			; starte TabTip.exe
	        }

	        IfWinNotActive, ahk_class Windows.UI.Core.CoreWindow
			; falls Metro-Fenster nicht aktiv ist		
        	IfWinNotActive, ahk_class OpusApp 
			; falls Word-Fenster nicht aktiv ist
	        If (osk = "yes")
			; yes, wenn TabTip aktiv ist
	        If (Cursor != "IBeam") And (A_Cursor != "IBeam")
	        {
        	    run, taskkill /im tabtip.exe, ,hide
	            osk = no

	        }

		Else
		{
	            Sleep, 750
        	}
	}

	else
		; falls Tablet docked, Touchservice deaktivieren
	{
		if (TouchService = 1)
		{
			TouchService = 0
		        Run, sc stop TabletInputService
	        }
	}
}

off:
if (A_IsPaused)
{
	Menu, Tray, Icon , img/Enabled.ico,,1
	Menu, Tray, Rename, &on , &off
}
else
{
	Menu, Tray, Icon , img/Disabled.ico,,1
	Menu, Tray, Rename, &off , &on
}
pause
Return

StopTouch:
    TouchService = 0
    Run, sc stop TabletInputService
Return

ButtonExit:
ExitApp  

With this saved as RunAsAdmin.ahk and put it in C:\Program Files\AutoHotkey\lib\RunAsAdmin.ahk.

 

/*           ,---,                                          ,--,    
           ,--.' |                                        ,--.'|    
           |  |  :                      .--.         ,--, |  | :    
  .--.--.  :  :  :                    .--,`|       ,'_ /| :  : '    
 /  /    ' :  |  |,--.  ,--.--.       |  |.   .--. |  | : |  ' |    
|  :  /`./ |  :  '   | /       \      '--`_ ,'_ /| :  . | '  | |    
|  :  ;_   |  |   /' :.--.  .-. |     ,--,'||  ' | |  . . |  | :    
 \  \    `.'  :  | | | \__\/: . .     |  | '|  | ' |  | | '  : |__  
  `----.   \  |  ' | : ," .--.; |     :  | |:  | : ;  ; | |  | '.'| 
 /  /`--'  /  :  :_:,'/  /  ,.  |   __|  : ''  :  `--'   \;  :    ; 
'--'.     /|  | ,'   ;  :   .'   \.'__/\_: |:  ,      .-./|  ,   /  
  `--'---' `--''     |  ,     .-./|   :    : `--`----'     ---`-'   
                      `--`---'     \   \  /                         
                                    `--`-'  
------------------------------------------------------------------
Function: To check if the user has Administrator rights and elevate it if needed by the script
URL: http://www.autohotkey.com/forum/viewtopic.php?t=50448
------------------------------------------------------------------
*/

RunAsAdmin() {
  Loop, %0%  ; For each parameter:
    {
      param := %A_Index%  ; Fetch the contents of the variable whose name is contained in A_Index.
      params .= A_Space . param
    }
  ShellExecute := A_IsUnicode ? "shell32\ShellExecute":"shell32\ShellExecuteA"
      
  if not A_IsAdmin
  {
      If A_IsCompiled
         DllCall(ShellExecute, uint, 0, str, "RunAs", str, A_ScriptFullPath, str, params , str, A_WorkingDir, int, 1)
      Else
         DllCall(ShellExecute, uint, 0, str, "RunAs", str, A_AhkPath, str, """" . A_ScriptFullPath . """" . A_Space . params, str, A_WorkingDir, int, 1)
      ExitApp
  }
}

 

The Script should works fine, but the BIG the problem is:

 

On my Acer W510, it is not possible to use the variable A_Cursor when the tablet is undocked from the keyboard!

 

It always returns "unknown", whatever i do with the mouse.

 

When the tablet is docked, everythink works fine, the keyboard pops up and down and so on.

 

So i tried a different thing:

 

        	if (TouchService < 1)
		{
	            TouchService = 1
	            Run, sc start TabletInputService
			; ...Touchservice aktivieren
	        }

		VarSetCapacity(ci,20,0), NumPut(20,ci)
		DllCall("GetCursorInfo", "Uint", &ci)
		hCursor := NumGet(ci,8)
			; A_Cursor only returns Unknown on Acer W510, so there is a workaround with GetCursorInfo. hCursor returns 65557 when cursor is in a textfield.

	        Cursor := hCursor
	        Sleep, 750

	        If (Cursor = "65557") And (hCursor = "65557")
        	IfWinNotActive, ahk_class Windows.UI.Core.CoreWindow
			; falls Metro-Fenster nicht aktiv ist
        	IfWinNotActive, ahk_class OpusApp 
			; falls Word-Fenster nicht aktiv ist
	        {
	            osk = yes        
        	    Run, "%TabTip%"
			; starte TabTip.exe
	        }

	        IfWinNotActive, ahk_class Windows.UI.Core.CoreWindow
			; falls Metro-Fenster nicht aktiv ist		
        	IfWinNotActive, ahk_class OpusApp 
			; falls Word-Fenster nicht aktiv ist
	        If (osk = "yes")
			; yes, wenn TabTip aktiv ist
        	If (Cursor != "65557") And (hCursor != "65557")
	        {
        	    run, taskkill /im tabtip.exe, ,hide
	            osk = no

	        }

		Else
		{
	            Sleep, 750
        	}

But the same like first time: In undocked-Mode, hCursor returns always "0"!

 

Docked i got the correct value and can use the script.

It seems, like there is something as a sandbox around all programms in desktop-mode when the tablet is undocked??!!

 

 

The question now is: Is there an other solution for this problem?

A possibility to know, where the cursor is?

How is windows doing it in the metro-apps? Because there it works perfectly even when the tablet is undocked!

 

It would be nice, if anyone can help :)



Haupo
  • Members
  • 6 posts
  • Last active: Mar 28 2013 02:04 PM
  • Joined: 02 Mar 2013

Hi, gahfe hiere in this forum: http://forum.tabletp...top-mode-8.html

gave me the very good solution to use A-CaretX, like in this posting: http://www.autohotke...ouble-clicking/

 

I used the "A_Caret.ahk" in folder lib and in my script only the compare

If (A_CaretX <> A_Caret("x")) Or (A_CaretY <> A_Caret("y"))

and

If (A_CaretX == A_Caret("x")) Or (A_CaretY == A_Caret("y"))

because the X- and Y-Variable always returns a value, the (X)- and (Y)-Variable only returns a value, if the cursor is in the adress-bar of the browser, or in the windows-editor for example. In a text-field.

First it looked very good, but i have one big problem: If i put the mouse-cursor in a textfield IN the browsers websites, nothing happens!
The (X)- and (Y)-Variables get NO value.

The problem is with every text-field in websites, like this one i use at the moment. Or google-search, or the login-fields here in the forum.

Do you have any idea for this?

 

Thank you!



Haupo
  • Members
  • 6 posts
  • Last active: Mar 28 2013 02:04 PM
  • Joined: 02 Mar 2013

Hi,

 

i now have a solution that works for me on my Acer W510:

 

Save the following as RunAsAdmin.ahk and put it in C:\Program Files\AutoHotkey\lib\RunAsAdmin.ahk. You may have to make the lib folder.

 

/*           ,---,                                          ,--,    
           ,--.' |                                        ,--.'|    
           |  |  :                      .--.         ,--, |  | :    
  .--.--.  :  :  :                    .--,`|       ,'_ /| :  : '    
 /  /    ' :  |  |,--.  ,--.--.       |  |.   .--. |  | : |  ' |    
|  :  /`./ |  :  '   | /       \      '--`_ ,'_ /| :  . | '  | |    
|  :  ;_   |  |   /' :.--.  .-. |     ,--,'||  ' | |  . . |  | :    
 \  \    `.'  :  | | | \__\/: . .     |  | '|  | ' |  | | '  : |__  
  `----.   \  |  ' | : ," .--.; |     :  | |:  | : ;  ; | |  | '.'| 
 /  /`--'  /  :  :_:,'/  /  ,.  |   __|  : ''  :  `--'   \;  :    ; 
'--'.     /|  | ,'   ;  :   .'   \.'__/\_: |:  ,      .-./|  ,   /  
  `--'---' `--''     |  ,     .-./|   :    : `--`----'     ---`-'   
                      `--`---'     \   \  /                         
                                    `--`-'  
------------------------------------------------------------------
Function: To check if the user has Administrator rights and elevate it if needed by the script
URL: http://www.autohotkey.com/forum/viewtopic.php?t=50448
------------------------------------------------------------------
*/

RunAsAdmin() {
  Loop, %0%  ; For each parameter:
    {
      param := %A_Index%  ; Fetch the contents of the variable whose name is contained in A_Index.
      params .= A_Space . param
    }
  ShellExecute := A_IsUnicode ? "shell32\ShellExecute":"shell32\ShellExecuteA"
      
  if not A_IsAdmin
  {
      If A_IsCompiled
         DllCall(ShellExecute, uint, 0, str, "RunAs", str, A_ScriptFullPath, str, params , str, A_WorkingDir, int, 1)
      Else
         DllCall(ShellExecute, uint, 0, str, "RunAs", str, A_AhkPath, str, """" . A_ScriptFullPath . """" . A_Space . params, str, A_WorkingDir, int, 1)
      ExitApp
  }
}

 

Save the following as A_Caret.ahk and put it in C:\Program Files\AutoHotkey\lib\A_Caret.ahk. You may have to make the lib folder:

 

A_Caret(param, coordMode = "Relative")
{
	target_window := DllCall("GetForegroundWindow")
		; Handle des Fensters, das sich im Vordergrund befindet

	If !target_window
		Return ""

	VarSetCapacity(guiThreadInfo, 48)
	NumPut(48, guiThreadInfo, 0)
	DllCall("GetGUIThreadInfo", uint, 0, str, guiThreadInfo)

	hwndCaret := NumGet(GuiThreadInfo, 28)
	If !hwndCaret
		Return ""

	top := NumGet(guiThreadInfo, 36)
	bottom := NumGet(guiThreadInfo, 44)
	If param = h
		Return bottom - top

	left := NumGet(guiThreadInfo, 32)
	right := NumGet(guiThreadInfo, 40)
	If param = w
		Return right - left

	VarSetCapacity(sPoint, 8, 0)
	NumPut(left, sPoint, 0, "Int")
	NumPut(top, sPoint, 4, "Int")

	DllCall("ClientToScreen", "UInt", hwndCaret, "UInt", &sPoint) 
	
	left := NumGet(sPoint, 0, "Int")
	top := NumGet(sPoint, 4, "Int")
	
	If coordMode = Relative
	{
		VarSetCapacity(rect, 16)
		DllCall("GetWindowRect", UInt, target_window, UInt, &rect)
		left -= NumGet(Rect, 0, True)
		top  -= NumGet(Rect, 4, True)
	}

	If param = x
		Return left
	Else
		Return top

}

Save the following as keyboardpopup.ahk start it from where you want:

; My thread http://www.autohotkey.com/board/topic/91002-how-to-automatically-popup-keyboard-in-windows-8/
; The unmodified code I got from  http://forum.tabletpcreview.com/samsung/54862-my-fix-keyboard-popup-desktop-mode.html and http://forum.xda-developers.com/showthread.php?t=1992361
; Thanks for all your help!

#NoEnv

Menu, Tray, Icon , img/Enabled.ico,,1
Menu, Tray, NoStandard
	; remove standard Menu items
Menu, Tray, Click, 1
	; a single-click to activate the tray menu
Menu, Tray, Add , &off, off
	; add a item named Off that goes to the Off label
Menu, Tray, Add , &Stop Touch Service, StopTouch
	; add a item named Stop Touch Service that goes to the StopTouch label
	; Stop the Touch Service
	; This is necessary because it will be enabled if we touch the keyboard icon
	; by accident.
Menu, Tray, Add , E&xit, ButtonExit
	; add a item named Exit that goes to the ButtonExit label
Menu, Tray, Default, &off
	; When the user double-clicks the tray icon, its default menu item is launched - in this case Off

RunAsAdmin()
	; put RunAsAdmin.ahk in C:\Program Files\AutoHotkey\lib\RunAsAdmin.ahk. You may have to make the lib folder.
TabTip := A_ProgramFiles . "\Common Files\microsoft shared\ink\TabTip.exe"
	; TabTip-Variable mit Programmpfad von TapTip.exe füllen
TouchService = 1
	; TouchService-Variable mit 1 füllen

While True
{

	RegRead, KBCount, HKEY_LOCAL_MACHINE, SYSTEM\CurrentControlSet\Services\kbdclass\Enum, Count
		; Auslesen des Wertes Count in der Registry und speichern in KBCount. Count hat Wert 1 wenn Tablet Docked und 2 wenn Undocked.

	if (KBCount < 2)
	{
		; falls Tablet undocked...

        	if (TouchService < 1)
		{
	            TouchService = 1
	            Run, sc start TabletInputService
			; ...Touchservice aktivieren
	        }

	        Sleep, 750

		If (A_CaretX == A_Caret("x")) Or (A_CaretY == A_Caret("y"))
			; falls X und (X) gleich sind
        	IfWinNotActive, ahk_class Windows.UI.Core.CoreWindow
			; falls Metro-Fenster nicht aktiv ist
        	IfWinNotActive, ahk_class OpusApp 
			; falls Word-Fenster nicht aktiv ist
	        {
	            osk = yes        
        	    Run, "%TabTip%"
			; starte TabTip.exe
	        }

	        IfWinNotActive, ahk_class Windows.UI.Core.CoreWindow
			; falls Metro-Fenster nicht aktiv ist		
        	IfWinNotActive, ahk_class OpusApp 
			; falls Word-Fenster nicht aktiv ist
	        If (osk = "yes")
			; yes, wenn TabTip aktiv ist
		If (A_CaretX <> A_Caret("x")) Or (A_CaretY <> A_Caret("y"))
			; falls X und (X) ungleich sind
	        {
        	    run, taskkill /im tabtip.exe, ,hide
	            osk = no

	        }

		Else
		{
	            Sleep, 750
        	}
	}

	else
		; falls Tablet docked, Touchservice deaktivieren
	{
		if (TouchService = 1)
		{
			TouchService = 0
		        Run, sc stop TabletInputService
	        }
	}
}

off:
if (A_IsPaused)
{
	Menu, Tray, Icon , img/Enabled.ico,,1
	Menu, Tray, Rename, &on , &off
}
else
{
	Menu, Tray, Icon , img/Disabled.ico,,1
	Menu, Tray, Rename, &off , &on
}
pause
Return

StopTouch:
    TouchService = 0
    Run, sc stop TabletInputService
Return

ButtonExit:
ExitApp  

 

And finally:

 

You have to have an "img" folder wherever keyboardpopup.ahk is with the 2 .ico files in it. You can find the 2 .ico files here:

 

https://skydrive.liv...ABa4CScN1M2UXCs



id_fei
  • Members
  • 1 posts
  • Last active: Apr 24 2013 12:31 AM
  • Joined: 18 Apr 2013

Hi Haupo,

 

I tried to follow your method. Seems like no effect on my acer W510. I can only see the notification icon of the keyboardpopup is there, but there is no change that I can observe to the behaviour of my onscreen keyboard.

 

Any advise ? Or maybe you can post the exe file ?

 

Thanks

 

Cheers....