Jump to content
Sign in to follow this  
John117

onscreen keyboard (could be faster)

Recommended Posts

John117

Hey - on a mobile so post will be short

I have buillt a keyboard for a touchscreen micropc 1024X600 -so it will look bad on something else. (just a warning)

I still have some right side button additions to make

the prob is its slow.

I think its the change back to the old window from the keyboard . alttab shows a flicker

_winprevious() by Psaltyds is better but slow for this use.

any idea's? -could kill the app otherwise

#include <GuiConstants.au3>
Opt("GUIOnEventMode", 1)
HotKeySet("{ESC}", "_Toggle")



$Show = False

;GUICreate ( "title" [, width [, height [, left [, top [, style [, exStyle [, parent]]]]]]] )
$GUI = GUICreate("", 3072, 225, -1024, 375, $WS_POPUPWINDOW, $WS_EX_TOPMOST)

Global $avSampleData[1] = ["Q-W-E-R-T-Y-U-I-O-P-{BACKSPACE}-q-w-e-r-t-y-u-i-o-p-{BACKSPACE}-1-2-3-4-5-6-7-8-9-0-{BACKSPACE}-A-S-D-F-G-H-J-K-L-{TAB}-{ENTER}-a-s-d-f-g-h-j-k-l-{TAB}-{ENTER}-Z-X-C-V-B-N-M-z-x-c-v-b-n-m"]

For $n = 0 To UBound($avSampleData) - 1
    $avSplit = StringSplit($avSampleData[$n], "-")
    For $i = 1 To $avSplit[0]
        $avSplit[$i] = StringStripWS($avSplit[$i], 1 + 2)
    Next
Next

Dim $aButtons[UBound($avSplit)]

;BUILD BUTTONS
$aTop = 0
$aLeft = 0
$Count = 1

For $x = 1 To $avSplit[0]
    ;Row1
    If $Count = 34 Then $aLeft = 0
    If $Count = 34 Then $aTop = $aTop + 75
    If $Count = 56 Then $aLeft = 0  
    If $Count = 56 Then $aTop = $aTop + 75
    If $Count = 63 Then $aLeft = 1024
    $aButtons[$x] = GUICtrlCreateButton($avSplit[$x], $aLeft, $aTop, 93, 75)
    GUICtrlSetOnEvent(-1, "_ButtonControl")
    $aLeft = $aLeft + 93
    $Count = $Count + 1
Next

GUICtrlCreateButton("{SPACE}", 651, 150, 186, 75)
GUICtrlSetOnEvent(-1, "_Space")
GUICtrlCreateButton("{SPACE}", 1675, 150, 186, 75)
GUICtrlSetOnEvent(-1, "_Space")

GUICtrlCreateButton("{SPEC }", 837, 150, 93, 75)
GUICtrlSetOnEvent(-1, "_Spec")
GUICtrlCreateButton("{SPEC }", 1861, 150, 93, 75)
GUICtrlSetOnEvent(-1, "_Spec")

GUICtrlCreateButton("{LOWER}", 930, 150, 93, 75)
GUICtrlSetOnEvent(-1, "_CaseLower")
GUICtrlCreateButton("{UPPER}", 1954, 150, 93, 75)
GUICtrlSetOnEvent(-1, "_CaseUpper")

GUICtrlCreateButton("{LOWER}", 2885, 150, 93, 75)
GUICtrlSetOnEvent(-1, "_CaseLower")
GUICtrlCreateButton("{UPPER}", 2978, 150, 93, 75)
GUICtrlSetOnEvent(-1, "_CaseUpper")


GUISetState(@SW_SHOW, $GUI);Show GUI

While 1
    Sleep(10)
WEnd

Func _Toggle()
    If $Show = True Then
        Global $Show = False
        GUISetState(@SW_SHOW, $GUI)
    Else
        Global $Show = True
        GUISetState(@SW_Hide, $GUI)
    EndIf
EndFunc   ;==>Toggle

Func _ButtonControl()
$ButtonControl = GUICtrlRead(@GUI_CtrlId)
;Send("!{tab}")
_WinPrevious()
Send($ButtonControl)
EndFunc   ;==>_ButtonControl

Func _Space()
$ButtonControl = GUICtrlRead(@GUI_CtrlId)
_WinPrevious()
Send($ButtonControl)
EndFunc   ;==>_Space

Func _CaseLower()
;WinMove ( "title", "text", x, y [, width [, height[, speed]]] )
WinMove($GUI, "", -1024, 375, 3072, 225)
EndFunc   ;==>CaseLower

Func _CaseUpper()
WinMove($GUI, "", 0, 375, 3072, 225)
EndFunc   ;==>CaseUpper

Func _Spec()
WinMove($GUI, "", -2048, 375, 3072, 225)
EndFunc   ;==>Spec

Func _WinPrevious($z = 1)
    If $z < 1 Then Return SetError(1, 0, 0) ; Bad parameter
    Local $avList = WinList()
    For $n = 1 to $avList[0][0]
        ; Test for non-blank title, and is visible
        If $avList[$n][0] <> "" And BitAND(WinGetState($avList[$n][1]), 2) Then
            If $z Then 
                $z -= 1
            Else
                WinActivate($avList[$n][1])
                Return 1
            EndIf
        EndIf
    Next
    Return SetError(2, 0, 0) ; z-depth exceeded
EndFunc

use esc to toggle

Edited by Hatcheda

Share this post


Link to post
Share on other sites
John117

bump -really only looking for a way to send keys to the last active window . . . any help?

Share this post


Link to post
Share on other sites
martin

bump -really only looking for a way to send keys to the last active window . . . any help?

I wrote a script for an on screen keyboard last year and this is what I did, though it needs your gui to have a title $version.

First add this to the beginning of your script

Global $wt = '';active window title
;Find the currently active window
GetLastActive($wt);need this line before guishow

After you show your gui add this line

if $wt then WinActivate($wt)

Then add this function

Func GetLastActive(ByRef $la,$setactive = false)
    Local $lastla = $la
    Local $wa='',$lastla
    $wa = WinGetTitle('');gets the title of the currently active window
;if key pressed too quickly then sometimes WingetTitl retiurns '' and then key presses are not sent, so ignore
    if not StringInStr($wa,$version) And $wa <> '' then $la = $wa
EndFunc

When ever a key was pressed I made the last active window active again and sent the key to it.

If you want to see my version let me know.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
jennico

look my signatures i made several OSKs.

the problem is autoit version 3.2.10.0. it does not handle reactivated edit boxes correctly. i made a bug request on that behaviour.

try autoit v 3.2.8.1

cheers

j.


Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.