Info Posted July 8, 2009 Share Posted July 8, 2009 (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.au3Virtual Keyboard - Everything.rar Edited August 29, 2009 by Info misrepresentative 1 Link to comment Share on other sites More sharing options...
wraithdu Posted July 8, 2009 Share Posted July 8, 2009 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? Link to comment Share on other sites More sharing options...
Info Posted July 8, 2009 Author Share Posted July 8, 2009 I know it's a bit wrong, but still working just as WinActivate($ReplacedString) Send($_Key) Link to comment Share on other sites More sharing options...
wraithdu Posted July 8, 2009 Share Posted July 8, 2009 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) Link to comment Share on other sites More sharing options...
NELyon Posted July 8, 2009 Share Posted July 8, 2009 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? Link to comment Share on other sites More sharing options...
Info Posted July 8, 2009 Author Share Posted July 8, 2009 Seems like that line isn't wrong after all. Link to comment Share on other sites More sharing options...
wraithdu Posted July 8, 2009 Share Posted July 8, 2009 @KentonBomb Yes @Info Which line? Both your original line and your posted alternative are still wrong. Link to comment Share on other sites More sharing options...
Info Posted July 8, 2009 Author Share Posted July 8, 2009 (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 July 8, 2009 by Info Link to comment Share on other sites More sharing options...
wraithdu Posted July 8, 2009 Share Posted July 8, 2009 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. Link to comment Share on other sites More sharing options...
Info Posted July 8, 2009 Author Share Posted July 8, 2009 So you are right. If WinActivate($ReplacedString) = 1 Then Send($_Key) still works like all the others so it's not a problem. Link to comment Share on other sites More sharing options...
wraithdu Posted July 8, 2009 Share Posted July 8, 2009 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. Link to comment Share on other sites More sharing options...
Info Posted July 9, 2009 Author Share Posted July 9, 2009 (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 July 9, 2009 by Info Link to comment Share on other sites More sharing options...
wraithdu Posted July 9, 2009 Share Posted July 9, 2009 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()? Link to comment Share on other sites More sharing options...
wraithdu Posted July 9, 2009 Share Posted July 9, 2009 (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 July 9, 2009 by wraithdu Link to comment Share on other sites More sharing options...
daluu Posted July 9, 2009 Share Posted July 9, 2009 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 Link to comment Share on other sites More sharing options...
James Posted July 9, 2009 Share Posted July 9, 2009 (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 Portablehttp://portableapps.com/apps/accessibility/on-screen_keyboard_portableUrgh, 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 July 9, 2009 by JamesBrooks Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Info Posted July 9, 2009 Author Share Posted July 9, 2009 (edited) Thanks Updated the line If WinActivate($ReplacedString) = 1 Then Send($_Key) to If WinActivate($ReplacedString) Then Send($_Key) Edited July 9, 2009 by Info Link to comment Share on other sites More sharing options...
martin Posted July 9, 2009 Share Posted July 9, 2009 (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 July 9, 2009 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. Link to comment Share on other sites More sharing options...
Info Posted July 9, 2009 Author Share Posted July 9, 2009 martin what do you think about the virtual keyboard? Link to comment Share on other sites More sharing options...
martin Posted July 10, 2009 Share Posted July 10, 2009 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now