Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Sending keyboard event to special running application

$
0
0
Hi, i'm trying to writing application that sending keyboard event to running application. The code below are send to any application that am viewing, I want it send only to special application.
Hope to get some hint or example at here, thank you for reading :)
#Region func
Func start()
If $start = False Then
  If GUICtrlRead($txtdelay[8]) == "" Then
   MsgBox(0, "Error", "Input this form first")
   GUICtrlSetBkColor($txtdelay[8], 16711680)
  Else
   GUICtrlSetBkColor($txtdelay[8], 16777215)
   $start = True
   WinSetTitle($hwnd, "", "Auto started ...")
   For $i = 1 To 8
	$timestart[$i] = 0
	GUICtrlSetState($txtskill[$i], $gui_disable)
	GUICtrlSetState($txtdelay[$i], $gui_disable)
   Next
  EndIf
Else
  GUICtrlSetBkColor($txtdelay[8], 16777215)
  $start = False
  WinSetTitle($hwnd, "", "Auto paused ...")
  For $i = 1 To 8
   GUICtrlSetState($txtskill[$i], $gui_enable)
   GUICtrlSetState($txtdelay[$i], $gui_enable)
  Next
EndIf
EndFunc
Func quit()
WinSetTitle($hwnd, "", "My Auto")
Exit
EndFunc
#EndRegion func
While 1
$nmsg = GUIGetMsg()
Switch $nmsg
  Case $gui_event_close
   WinSetTitle($hwnd, "", "My Auto")
   Exit
EndSwitch
If $start = True Then
  For $i = 1 To 8
   If GUICtrlRead($txtdelay[$i]) <> "" AND GUICtrlRead($txtdelay[$i]) <> "" Then
	If $timestart[$i] == 0 Then
	 $timestart[$i] = TimerInit()
	Else
	 $timediff[8] = TimerDiff($timestart[8])
	 If $timediff[8] >= (GUICtrlRead($txtdelay[8]) * 1000) Then
	  ControlSend($hwnd, "", "", "p")
	  Sleep(2000)
	  ControlSend($hwnd, "", "", "p")
	  Sleep(2000)
	  ControlSend($hwnd, "", "", "p")
	  Sleep(2000)
	  ControlSend($hwnd, "", "", "p")
	  Sleep(2000)
	  $timestart[8] = TimerInit()
	 Else
	  $timediff[$i] = TimerDiff($timestart[$i])
	  If $timediff[$i] >= (GUICtrlRead($txtdelay[$i]) * 1000) Then
	   ControlSend($hwnd, "", "", GUICtrlRead($txtskill[$i]))
	  EndIf
	 EndIf
	EndIf
   EndIf
  Next
EndIf
WEnd


Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>