AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

On Screen Keyboard clickable

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
DavidProut



Joined: 06 Jan 2008
Posts: 1

PostPosted: Sun Jan 06, 2008 7:56 pm    Post subject: On Screen Keyboard clickable Reply with quote

I have seen that is possible to display a keyboard on a monitor. Is it possible to display a keyboard that can be used to enter data using the mouse to type. Being very new to hot keys I haven't a clue how to do this.
It would be useful I think.
In my case I would be using the keys to enter numbers as I find this tedious on my laptop. If the keyboard could be created I think I would then try to adapt the code to produce a number pad which would be ideal for me. I do have a USB keypad but it is cumbersome to carry around and there is not always room to use it.
Back to top
View user's profile Send private message
Jero3n



Joined: 19 Jan 2007
Posts: 151

PostPosted: Sun Jan 06, 2008 8:01 pm    Post subject: Reply with quote

It's possible.
You first make a gui with all the keys you want on the keyboard.
Than you make for every button a function to send the clicked keys.
Don't think this is really hard.

Here an example with just a, b & c.

Code:

Gui, Add, Button, gSendA, A
Gui, Add, Button, gSendB, B
Gui, Add, Button, gSendC, C

SendA:
Send, a

SendB:
Send, b

SendC:
Send, c


Didn't tested it, but it has to be something like this.[/code]
Back to top
View user's profile Send private message
DerRaphael



Joined: 23 Nov 2007
Posts: 604
Location: 127.0.0.1

PostPosted: Sun Jan 06, 2008 9:44 pm    Post subject: Reply with quote

this one might interest u

http://www.autohotkey.com/forum/viewtopic.php?t=18378

its a full fledged onscreen keyboard written in ahk also some nice screenshots

greets
derRaphael
_________________
Back to top
View user's profile Send private message
dncarac



Joined: 31 Aug 2006
Posts: 64

PostPosted: Sun Jan 06, 2008 11:05 pm    Post subject: Reply with quote

Here's one I wrote. It's not full featured, but it's short and sweet. There are a list of constants which may be changed to change the layout. I think it's understandable enough to be customized.

Code:
ControlWidth=351

;*** Keyboard data
KeySize=27      ; Pixels.  Minimum 21 or "Shift" labels don't display properly

Row1LC=``1234567890-=
Row1UC=~!@#$`%^&*()_+
Row2LC=qwertyuiop[]\
Row2UC=QWERTYUIOP{}|
Row3LC=asdfghjkl;'
Row3UC=ASDFGHJKL:"
Row4LC=zxcvbnm,./
Row4UC=ZXCVBNM<>?
Rows=4
MaxKeys=13

ShiftRow=4
ShiftFactor:=1.5
ShiftSize:=ShiftFactor*KeySize
EnterRow:=3
EnterFactor:=2
EnterSize:=EnterFactor*Keysize
SpaceFactor:=8
SpaceSize:=SpaceFactor*KeySize
SpaceOffsetFactor:=(MaxKeys-SpaceFactor)/2
SpaceOffset:=SpaceOffsetFactor*KeySize
MaxWidth:=MaxKeys*KeySize
Case=LC

;* End keyboard data
   
;*** GUI layout

Gui, 4:Add, Edit, xm w%ControlWidth% r5 vTyped_Text +ReadOnly -tabstop VScroll,_

Loop %Rows%
{
    Row:=A_Index
    If Row=1
        Gui, 4:Add, Button, w%KeySize%   h%KeySize%        vR%Row%K1     gKeyPressed, % SubStr(Row%Row%%Case%,1,1)
    Else If Row=%ShiftRow%
    {
        Gui, 4:Add, Button, w%ShiftSize% h%KeySize% xm y+0 vLShift       gButtonShift, Shift
        Gui, 4:Add, Button, w%KeySize%   h%KeySize%    x+0 vR%Row%K1     gKeyPressed, % SubStr(Row%Row%%Case%,1,1)
    }
    Else
        Gui, 4:Add, Button, w%KeySize%   h%KeySize% xm y+0 vR%Row%K1     gKeyPressed, % SubStr(Row%Row%%Case%,1,1)

    Loop % StrLen(Row%Row%LC)-1
    {
        Key:=A_Index+1
        Gui, 4:Add, Button, w%KeySize%   h%KeySize% x+0    vR%Row%K%Key% gKeyPressed, % SubStr(Row%Row%%Case%,Key,1)
    }

    If Row=%EnterRow%
        Gui, 4:Add, Button, w%EnterSize% h%KeySize% x+0    vEnter       gButtonEnter, Enter
    If Row=%ShiftRow%
        Gui, 4:Add, Button, w%ShiftSize% h%KeySize% x+0    vRShift      gButtonShift, Shift
}
Gui, 4:Add, Button, xm+%SpaceOffset% h%KeySize%  w%SpaceSize% y+0 gButtonSpace vSpace,
CancelLocation := ControlWidth + 10 - EnterSize    ; 10 for margin
Gui, 4:Add, Button, x%CancelLocation% yp h%KeySize% w%EnterSize%  -tabstop, Cancel

Gui, 4:Show, AutoSize Center, Keyboard

;* End GUI layout

;*** Key handlers

KeyPressed:
KeyPressed := A_GuiControl
Row := SubStr(KeyPressed,2,1)
Key := SubStr(KeyPressed,4)
Letter := SubStr(Row%Row%%Case%,Key,1)
UpdateCurrentText(Letter)
Return

ButtonShift:
If Case=UC
    UpdateKeyboardLabels("LC")
Else
    UpdateKeyboardLabels("UC")
Return

ButtonSpace:
UpdateCurrentText(" ")
Return

ButtonEnter:
UpdateCurrentText("`n")
Return

4GuiEscape:
4GuiClose:
4ButtonCancel:
ExitApp
Return

;* End key handlers

;*** Function definitions

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
UpdateCurrentText(NewLetter)
{
    global
    GuiControlGet, Typed_Text, 4:
    StringTrimRight,Typed_Text,Typed_Text,1
    Typed_Text .= NewLetter . "_"
    GuiControl,4:,Typed_Text,%Typed_Text%
    If Case=UC
        UpdateKeyboardLabels("LC")
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
UpdateKeyboardLabels(CaseParameter)
{
    global
    Case := CaseParameter
    Loop %Rows%
    {
        Row:=A_Index
        Loop % StrLen(Row%Row%%Case%)
        {
            Key:=A_Index
            If(SubStr(Row%Row%%Case%,Key,1)="&")
                GuiControl,4:, R%Row%K%Key%, &&
            Else
                GuiControl,4:, R%Row%K%Key%, % SubStr(Row%Row%%Case%,Key,1)
        }
    }
}

;*  End function definitions


Enjoy.

DNC
Back to top
View user's profile Send private message
dncarac



Joined: 31 Aug 2006
Posts: 64

PostPosted: Sun Jan 06, 2008 11:42 pm    Post subject: Numeric only Reply with quote

And here's that same keyboard modified for only numeric keys. Again, I think it's easily understood so it may be modified as you wish.

Code:
ControlWidth=150

;*** Keyboard data
KeySize=27      ; Pixels.  Minimum 21 or "Shift" labels don't display properly

Row1LC=123
Row2LC=456
Row3LC=789
Row4LC=0
Rows=4
MaxKeys=13

EnterRow:=4
EnterFactor:=2
EnterSize:=EnterFactor*Keysize
Case=LC

;* End keyboard data
   
;*** GUI layout

Gui, 4:Add, Edit, xm w%ControlWidth% r1 vTyped_Text

Loop %Rows%
{
    Row:=A_Index
    If Row=1
        Gui, 4:Add, Button, w%KeySize%   h%KeySize%        vR%Row%K1     gKeyPressed, % SubStr(Row%Row%%Case%,1,1)
    Else
        Gui, 4:Add, Button, w%KeySize%   h%KeySize% xm y+0 vR%Row%K1     gKeyPressed, % SubStr(Row%Row%%Case%,1,1)

    Loop % StrLen(Row%Row%LC)-1
    {
        Key:=A_Index+1
        Gui, 4:Add, Button, w%KeySize%   h%KeySize% x+0    vR%Row%K%Key% gKeyPressed, % SubStr(Row%Row%%Case%,Key,1)
    }

    If Row=%EnterRow%
        Gui, 4:Add, Button, w%EnterSize% h%KeySize% x+0    vEnter       gButtonEnter, Enter
}
CancelLocation := ControlWidth + 10 - EnterSize    ; 10 for margin
Gui, 4:Add, Button, x%CancelLocation% yp h%KeySize% w%EnterSize%  -tabstop, Cancel

Gui, 4:Show, AutoSize Center, Keyboard

;* End GUI layout

;*** Key handlers

KeyPressed:
KeyPressed := A_GuiControl
Row := SubStr(KeyPressed,2,1)
Key := SubStr(KeyPressed,4)
Letter := SubStr(Row%Row%%Case%,Key,1)
UpdateCurrentText(Letter)
Return

ButtonEnter:
  GuiControlGet, Typed_Text, 4: 
  MsgBox Number: %Typed_Text%
Return

4GuiEscape:
4GuiClose:
4ButtonCancel:
ExitApp

;* End key handlers

;*** Function definitions

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
UpdateCurrentText(NewLetter)
{
    global
    GuiControlGet, Typed_Text, 4:
    Typed_Text .= NewLetter
    GuiControl,4:,Typed_Text,%Typed_Text%
}

;*  End function definitions



Enjoy,

DNC
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group