Jump to content

Sending keyboard event to special running application


Recommended Posts

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...