Jump to content
Sign in to follow this  
seask

Sending keyboard event to special running application

Recommended Posts

seask

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

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  

×

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.