Sign in to follow this  
Followers 0
changtraingheo

How to send key to On-Screen Keyboard

3 posts in this topic

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



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

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

  • Similar Content

    • 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.
    • nacerbaaziz
      By nacerbaaziz
      Hi all
      I want a way to get the last key pressed.
      I have a program that works with keyboard shortcuts and I want to  give the permission for the user to edit shortcut keys depending on what suits him
      i  want to make read-only edit box and the program writes the latest shortcut key pressed
      Please help me,
      greetings to all
      And thanks in advance
    • rawkhopper
      By rawkhopper
      Hello everyone,
      I have a script that is automating a piece of sluggish software.  I want to automate it with a bit of caution and I am not sure the best way to do it.  ControlSend works great most of the time.  If I have it enter 10 into a text box every once in a while it will enter 1 or 11 and then hit enter.
      To overcome this I use MouseClick to select the text I just entered and then see if it matches the string it was supposed to put in before it hits enter.  This seems to work but what I love about ControlSend is there is less room for human interaction messing it up.  
      Yes I could block input but I prefer not to do that (permissions).
      Is there a better way of doing this?  Any Help would be much appreciated.
      Anyway here is the snippet of the script in question:
      Func KVSend () WinActivate ( "Window", "" ) Local $WindowPos = WinGetPos("Window", "") If $kV < 30 Then WinActivate ( "Window", "" ) ControlClick ("Window", "", 1001) ;Click in Accel Voltage box Sleep (100) ControlSend ("Window", "", 1001, $kV) ; \ kV Sleep (100) MouseMove($WindowPos[0]+130,$WindowPos[1]+75,1) MouseClick($MOUSE_CLICK_LEFT) MouseClick($MOUSE_CLICK_LEFT) Send ("^c") Local $clip = ClipGet () If $clip = $kV Then ControlSend ("Window", "", 1001, "{ENTER}") ;Hit ENTER if value is correct Sleep (100) ControlClick ("Window", "", 1518) ;Lens Clear Else Send ("{BACKSPACE}") KVSend() ; If value is incorrect try again EndIf EndIf  
    • JustinZandee
      By JustinZandee
      I want to create a loop which loops a code until for example f2 is pressed.
      So I tried something with _IsPressed but it doesn't work.
      Local $test = WinActivate("Notepad") Do Send("hi") Until _IsPressed("72", $test)  
      I don't know how I can do nothing when pressing f2 because it says "error: _IsPressed(): undefined function.".
      I did put 
      Send("hi") after Local $test = but it gives the same error.
      Does anyone know how to solve this problem? 
      Maybe I am wrong and I need to use a whole other Function.. I am new to AutoIT so I am sorry..
       
    • spuuunit
      By spuuunit
      This is what I'm trying to do: In Firefox, if you hold down CTRL + C for about 200ms, then press CTRL + T. This is my code:
      While WinActive(" - Mozilla Firefox") If _IsPressed("A2", $hDLL) And _IsPressed("43", $hDLL) Then $timer = TimerInit() While _IsPressed("A2", $hDLL) And _IsPressed("43", $hDLL) Sleep(10) $diff = TimerDiff($timer) If $diff > 200 Then Send("^{T}") While _IsPressed("A2", $hDLL) And _IsPressed("43", $hDLL) Sleep(10) WEnd EndIf WEnd EndIf WEnd The problem is that the CTRL key gets stuck down after Send("^{T}"). I found this, but what I understand that happens when I release, and that is not what I want. The "General unstuck method" did nothing.