Jump to content

Recommended Posts

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
Posted

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?

Posted

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?

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
Posted

So you are right. :)

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

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

Posted

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.

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
Posted

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()?
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
Posted

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

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
Posted (edited)

Thanks :)

Updated the line

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

to

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

:)

Edited by Info
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.
Posted

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.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...