Sign in to follow this  
Followers 0
Info

My Virtual Keyboard

33 posts in this topic

#1 ·  Posted (edited)

Notes:

1) Do not try to combine keys with your keyboard and the keyboard GUI, most of the combines will work though.

2) I'm new to AutoIt so please give me advices how to improve my writing.

Thanks to:

- Melba 23 for his help.

- martin for his help.

- wraithdu for his help.

- GaryFrost for his GetKeyState functions.

Virtual Keyboard.au3

Virtual Keyboard - Everything.rar

Edited by Info
1 person likes this

Share this post


Link to post
Share on other sites



I'm suprised after that other thread this was how you chose to do it, but so be it. Anyway, this line -

If WinActivate($ReplacedString) = 1 Then Send($_Key)

is wrong. The WinActivate() function returns the handle of the activated window, so it will never equal 1, and you will never send the keystroke. Was this actually working for you somehow?

Share this post


Link to post
Share on other sites

I know it's a bit wrong, but still working just as

WinActivate($ReplacedString)
Send($_Key)

Share this post


Link to post
Share on other sites

Re-read the documentation. If you can't test for success, test for failure. For WinActivate(), failure equals 0.

If WinActivate($ReplacedString) <> 0 Then Send($_Key)

Share this post


Link to post
Share on other sites

Re-read the documentation. If you can't test for success, test for failure. For WinActivate(), failure equals 0.

If WinActivate($ReplacedString) <> 0 Then Send($_Key)

Could you not just do:

If WinActivate($ReplacedString) Then Send($_Key)

Since it will just evaluate true anyway if WinActivate($ReplacedString) is non-zero?

Share this post


Link to post
Share on other sites

Seems like that line isn't wrong after all.

Share this post


Link to post
Share on other sites

@KentonBomb

Yes :)

@Info

Which line? Both your original line and your posted alternative are still wrong.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

I'm not sure but if

If WinActivate($ReplacedString) Then Send($_Key)

is right then

If WinActivate($ReplacedString) = True Then Send($_Key)

is right

and if

If WinActivate($ReplacedString) = True Then Send($_Key)

is like

If WinActivate($ReplacedString) = 1 Then Send($_Key)

because both represent success then

If WinActivate($ReplacedString) = 1 Then Send($_Key)

is right

All of them work the same so it really doesn't matter...

:)

Edited by Info

Share this post


Link to post
Share on other sites

No no no. 'True' is an AutoIt keyword and does not equal 1. Try:

ConsoleWrite((5 = True) & @CRLF)
ConsoleWrite((5 = 1) & @CRLF)

You need to test these things instead of making assumptions.

Share this post


Link to post
Share on other sites

So you are right. :)

If WinActivate($ReplacedString) = 1 Then Send($_Key)

still works like all the others so it's not a problem.

Share this post


Link to post
Share on other sites

No it DOES NOT. That line is NEVER true.

Not that it matters, but see here for how to change button styles dynamically:

http://www.autoitscript.com/forum/index.php?showtopic=97951&view=findpost&p=705070

If you don't want to use that method, then it's still better to show/hide two buttons with different states that to always destroy/re-create buttons for the Shift etc. keys.

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

I delete the Alt, Ctrl and Shift buttons because I need to create new ones with a different style, I can't just hide and show them.

What do you think overall about the program?

No it DOES NOT. That line is NEVER true.

Both lines work exactly the same for me. How can you explain that? Edited by Info

Share this post


Link to post
Share on other sites

Both lines work exactly the same for me. How can you explain that?

What version of AutoIt are you running? What does your help file say is the return value of WinActivate()?

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Oh, hmmm, seems to have been a change in AutoIt 3.3.1.0 beta.

Added #764: Return Pid on ProcessWait() and handle on WinWait(), WinWaitActive, WinActivate(), WinActive(), WinMove() when successful.

That should probably be labeled as script breaking in the changelog. Anyway, given this fact, it's probably better to change that line to

If WinActivate($ReplacedString) Then Send($_Key)

for compatibility.

Edited by wraithdu

Share this post


Link to post
Share on other sites

Good work and thanks for sharing. :)

However, just wanted to mention that there is already a free virtual keyboard for clicking to type on the screen:

On-Screen Keyboard Portable

http://portableapps.com/apps/accessibility/on-screen_keyboard_portable

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

Good work and thanks for sharing. :)

However, just wanted to mention that there is already a free virtual keyboard for clicking to type on the screen:

On-Screen Keyboard Portable

http://portableapps.com/apps/accessibility/on-screen_keyboard_portable

Urgh, why do people always say something like that? This guy is learning, he is new. Maybe, just maybe he wanted to know how it was done? Maybe, he wanted to learn. Why re-invent the wheel? Do it until you find a better wheel. That's what innovation is about. The saying "If it's not broke, don't fix it" is flawed! It assumes perfection. And you know what it means to assume (it makes an ass out of u and me). Edited by JamesBrooks

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

Thanks :)

Updated the line

If WinActivate($ReplacedString) = 1 Then Send($_Key)

to

If WinActivate($ReplacedString) Then Send($_Key)

:)

Edited by Info

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

However, just wanted to mention that there is already a free virtual keyboard for clicking to type on the screen:

We know that and it's not very suitable for many applications. For instance if you want to use it on a touch screen then you have to have fingers like a pixie's, so I think it's good to know how to make your own. Edited by martin

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

martin what do you think about the virtual keyboard?

Share this post


Link to post
Share on other sites

martin what do you think about the virtual keyboard?

I think it's extremely good.

I think you could have made it even better.

A> If you used wraithdu's idea to prevent focus.

B> If you made better indication of the state of the modifyer keys. If Ctrl is down it's not so obvious. You make the shift key smaller when it is down, so if you made a bright label show behind it as a border it would look lit perhaps.

Maybe something like

#include <windowsconstants.au3>
#include <guiconstantsEx.au3>

$gui = GUICreate("lit key",100,100)

$btn = GUICtrlCreateButton("CTRL",52,52,38,20)
$lab = GUICtrlCreateLabel("",50,50,42,24,$WS_CLIPSIBLINGS)
GUICtrlSetBkColor(-1,0x300ff00)
GUICtrlSetState(-1,$GUI_HIDE)
GUISetState()
$off = false
while 1
    $Msg = GUIGetMsg()

        if $Msg = -3 then Exit

        if $Msg = $Btn Then
            if $off Then
                GUICtrlSetState($lab,$GUI_HIDE)
            Else
                GUICtrlSetState($lab,$GUI_SHOW)
            EndIf
            $off = not $off
        EndIf

WEnd

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

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  
Followers 0