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