Jump to content
Sign in to follow this  
changtraingheo

How to send key to On-Screen Keyboard

Recommended Posts

changtraingheo

I want to send key to On-Screen Keyboard (program in win 7) and then On-Screen Keyboard program send that key to notepad, but my script is not work, this is my script:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <Timers.au3>
 
Global $nDelay,$handle,$pid;
 
$nDelay = 2000
 
$gui = GUICreate("My GUI",200,100)
 
$button_gen = GUICtrlCreateButton("Start",10,30,60)
$button_stop = GUICtrlCreateButton("Stop",10,60,60)
 
$handle = WinGetHandle('On-Screen Keyboard', "")
$pid = WinGetProcess($handle)
 
GUISetState()
; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
ExitLoop
Case $button_gen
_Timer_SetTimer($gui, $nDelay, "AutoTDK")
Case $button_stop
_Timer_KillAllTimers($gui)
EndSwitch
WEnd
GUIDelete()
 
Func AutoTDK($hWnd, $Msg, $iIDTimer, $dwTime)
WinActivate("Untitled - Notepad") ; active notepad program
ControlSend($handle, "", $pid,"{SPACE}") ; send space key to On-Screen Keyboard
EndFunc

pls help me

Share this post


Link to post
Share on other sites
spudw2k

Sending keys to an On-Screen keyboard, sounds kinda strange. :mellow:

You are on the right track though. Use the AutoIt Window tool to get the ids of the buttons and use ControlClick.

Share this post


Link to post
Share on other sites
monoscout999

ControlSend doesn`t use the pid, do what spudw2k says

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  

  • Similar Content

    • TheDcoder
      By TheDcoder
      Hello everyone, long time since I made a post in the H&S sub-forum
      I am working on a project where in a situation I would have to hold down an arrow key and release it in another statement/command, however when I wrote the code it isn't working exactly like I thought it would. Here is an example:
      Send("{UP down}") Sleep(10000) Send("{UP up}") This should hold the up arrow key for 10 seconds before releasing it again, but when I run this code the cursor in SciTE moves up only once
      If I hold the up arrow manually for 10 seconds it "repeats" and the cursor moves up several times until I release the key... Is this a known limitation of Send? Is there any other way I can accomplish this?
      Thanks for all the help and feedback in advance! TD
    • WoodGrain
      By WoodGrain
      Hi All,
      I've bought a Ergodox EZ programmable keyboard with layers of key maps (eg, layer 0 = dvorak, layer 1 = numberpad & nav, layer 2 = qwerty, etc), I've also got a small USB screen that can pull information from the registry. What I would like to determine is a way to pull the value of each current key from the keyboard, I can then write the values to the registry and pull them into my USB screen so I can see the keyboard key layout.
      I'm stuck with retrieving the key values, I've looked at _IsPressed(), _WinAPI_GetKeyState(), _WinAPI_GetKeyboardState(), _WinAPI_GetKeyboardType(), _WinAPI_GetKeyNameText(), but none of them appear to be able to pull the keyboard key values without user interaction.
      The idea being, in pseudo code, bear in mind no error checking etc in this code, "GetKeyValue()" is what I'm needing help with and is a made up function, as is "HardwareKey1" etc:
      $keyOnePrev = "" $numOfKeys = 76 While 1 $keyOneCurrent = GetKeyValue(HardwareKey1) If $keyOneCurrent <> $keyOnePrev Then For $key = 1 To $numOfKeys $keyToWrite = GetKeyValue(HardwareKey & $key) RegWrite("HKEY_CURRENT_USER\Software\myKeyboard", "key" & $key, "REG_SZ", $keyToWrite) Next EndIf $keyOnePrev = $keyOneCurrent Sleep(5000) WEnd Thanks guys!
    • badcoder123
      By badcoder123
      Anyone know how to access the information circled in the photo?
       

    • AndreyS
      By AndreyS
      Dear developers and creators of the language, please explain to me why when pressing the combination Crtl + Shift + C from the 5th or the 10th time "sticks / sinks" Ctrl or Shift? And then you need to press Ctrl or Shift again to reset their triggering. I only need to use hot keys like in the example!
      The code is a small example. Its essence is that when a user in the editor selects any number and presses a combination, then it increases by 1. 
      Dim $x HotKeySet("+^c","Calc") While 1 Sleep(10000) WEnd Func Calc() Send("^c") Sleep(50) $x=ClipGet()+1 ClipPut($x) Send("^v") EndFunc I thought that in my program some kind of glitch was searching for a reason for a long time. And it turned out that apparently somehow the work of some functions used in the example is not compatible. 
      Tell me, please, what is the problem?
    • ur
      By ur
      If you observe in below code.
      Func _WinWaitActivate($title,$text,$timeout=$time_out) Logging("Waiting for "&$title&":"&$text) $dHandle = WinWait($title,$text,$timeout) if not ($dHandle = 0) then If Not WinActive($title,$text) Then WinActivate($title,$text) WinWaitActive($title,$text,$timeout) Else Logging("Timeout occured while waiting for the window...") Exit EndIf EndFunc WinActivate("Untitled - Notepad") $p = "Notallowed1!!" Send("{ENTER}{ENTER}{ENTER}{ENTER}"& $p &"{ENTER}create{SPACE}database{SPACE}"& $p &";{ENTER}") In the notepad if you observe, ! is missing in the text got.
       
      Is there way to get that also printed.
×

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.