Sign in to follow this  
Followers 0
chii

controlsend doesnt work properly

2 posts in this topic

Controlsend() doesn't seem to work properly. When it is combined with a directional key and a character, it doesn't work properly. Let me describe the problem in detail.

I tried narrowing down the problem, but I'm still confused.

I tried this:

$i = 0

Do

ControlSend("TWC", "", "", "{DOWN}")

ControlSend("TWC", "", "", "{UP}")

ControlSend("TWC", "", "", "{RIGHT}")

Sleep(2000)

$i = $i + 1

Until $i = 6

EndFunc

It worked. The character moved accordingly. It also worked when the program is minimized.

I added a few more lines:

func Plant()

$i = 0

Do

ControlSend("TWC", "", "", "5")

ControlSend("TWC", "", "", "{DOWN}")

ControlSend("TWC", "", "", "{UP}")

ControlSend("TWC", "", "", "{RIGHT}")

Sleep(8000)

ControlSend("TWC", "", "", "2")

ControlSend("TWC", "", "", "{LEFT}")

Sleep(2000)

$i = $i + 1

Until $i = 10

EndFunc

The macro refuses to work at all. It skips DOWN, UP, RIGHT, LEFT. I only see it sending 5 and 2. It works when the window is minimized.

I was confused so I tried working around it. I added a bit more:

func Plant()

$i = 0

Do

Seed()

ControlSend("TWC", "", "", "{DOWN}")

ControlSend("TWC", "", "", "{UP}")

ControlSend("TWC", "", "", "{RIGHT}")

Sleep(8000)

Move()

ControlSend("TWC", "", "", "{LEFT}")

Sleep(2000)

$i = $i + 1

Until $i = 10

EndFunc

func Move()

ControlSend("TWC", "", "", "2")

EndFunc

func Seed()

ControlSend("TWC", "", "", "5")

EndFunc

As you can see, I just separated the ControlSend() that sends numbers 2 and 5. I placed them in a function of their own. It worked, but it skips the first loop (so if it were supposed to loop 10 times, it actually only does it 9 times). Also, it refuses to work when the window is inactive.

Let me explain when I say that it refuses to work when the window is inactive. I added a few more lines:

$i = 0

Do

Plant()

Sleep(3000)

ControlSend("TWC", "", "", "4")

ControlSend("TWC", "", "", "e")

Sleep(1000)

$i = $i + 1

Until $i = 113

func Plant()

$i = 0

Do

Seed()

ControlSend("TWC", "", "", "{DOWN}")

ControlSend("TWC", "", "", "{UP}")

ControlSend("TWC", "", "", "{RIGHT}")

Sleep(8000)

Move()

ControlSend("TWC", "", "", "{LEFT}")

Sleep(2000)

$i = $i + 1

Until $i = 10

EndFunc

func Move()

ControlSend("TWC", "", "", "2")

EndFunc

func Seed()

ControlSend("TWC", "", "", "5")

EndFunc

This code would loop Plant() ten times before it clicks 4 and e. It doesn't work. When I had the window minimized, Autoit thinks that it has done the steps in Plant(), but it doesn't register. I tested the script. I ran it, waited for a few minutes, and when I activated the window, it suddenly sends 4 and e, which should mean that it already looped Plant() but it didn't.

I'm confused as hell. Can anyone help me?

I tried the function AutoitSetOption, but it also refused to work. Thanks.

Share this post


Link to post
Share on other sites



I would have to know how TWC is written. If the same problem was exhibited in more than one app we would likely have an issue. If it performs correctly in other apps, then perhaps TWC is coded poorly.

Lar.


f_mrcleansmalm_77ce002.jpgAutoIt has helped make me wealthy

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