Sign in to follow this  
Followers 0
Cykon

ControlSend()

3 posts in this topic

#1 ·  Posted (edited)

Currently I am trying to send keystrokes to a game without the window being up. The game has trouble recognizing "fast" keystrokes, so I played with the send options a little bit.

Current Code

#Include <Misc.au3>
Opt("SendKeyDownDelay", 200) 
Opt("SendKeyDelay",500)
$Initiated = False


while $Initiated == False
    if($initiated == False) Then
        if _IsPressed("6B") Then ;Game blocks hotkey commands
                $Initiated = True
                Go_To()
        EndIf
    EndIf
    sleep(100)
WEnd



Func Go_To()
    Send("{F4}")
EndFunc

The above code works perfect while the main window is up, however if I replace Send(...) with ControlSend("Game Title","","","{F4}) it seems like it is ignoring the edited options above.

When the chat window is open with the game, I can send simple text with ControlSend(...) and it recognizes it (Even if the the game is the active window or not).

EDIT: For clarification, send was working in the exact same way as ControlSend is now before I added the options code

Before I added the edited options, Send(...) was having similar problems recognizing commands similar to F4 or HOME.

I have a feeling that I did something wrong, but might it be a possibility that ControlSend() does not recognize the edited options?

Edited by Cykon

Share this post


Link to post
Share on other sites



Are you sending it to a chat window or another window?

Does it only not work if the window is minimized or does it also not work if the window is active?

Are you sure you have the right Control ID in your ControlSend command? Have you tried ControlFocus first as suggested by the help file? The help file suggests Sendkeydelay controls controlsend timings.

Also is there a reason you have

while $Initiated == False
    if($initiated == False) Then
        if _IsPressed("6B") Then;Game blocks hotkey commands
                $Initiated = True
                Go_To()
        EndIf
    EndIf
    sleep(100)
WEnd

Instead of

while $Initiated == False
    if _IsPressed("6B") Then;Game blocks hotkey commands
        $Initiated = True
        Go_To()
    EndIf
    sleep(100)
WEnd

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Are you sending it to a chat window or another window?

In game, when you press enter, you are able to type messages. That is the window I am sending it to

Does it only not work if the window is minimized or does it also not work if the window is active?

It "works" either way

Are you sure you have the right Control ID in your ControlSend command? Have you tried ControlFocus first as suggested by the help file?

I have.

The help file suggests Sendkeydelay controls controlsend timings.

I am not sure what you mean by this. Are you referring to the options I added, or are there others similar to it?

Also is there a reason you have

while $Initiated == False
    if($initiated == False) Then
        if _IsPressed("6B") Then;Game blocks hotkey commands
                $Initiated = True
                Go_To()
        EndIf
    EndIf
    sleep(100)
WEnd

Instead of

while $Initiated == False
    if _IsPressed("6B") Then;Game blocks hotkey commands
        $Initiated = True
        Go_To()
    EndIf
    sleep(100)
WEnd
Just a safety precaution on my part, I don't want the slightest chance of a double triggering.

Like I said, I am sure that the keystroke is getting to the program, I just have a feeling that it is being triggered too fast for the game to recognize the keystroke out of the chat feature of the game. This is the exact same problem I had with the Send() command before I added

Opt("SendKeyDownDelay", 200) 
Opt("SendKeyDelay",500)
Edited by Cykon

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