Unable to send commands to unfocused window.

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Mr Fun
Newbie
Posts: 7
Joined: Tue Jul 17, 2012 7:56 pm

Unable to send commands to unfocused window.

Post by Mr Fun » Tue Jul 17, 2012 8:10 pm

So I plan on purchasing the lite version of this software but I figured I would try the 30 day trial to see if it would work for me first.
I am glad I did. This is one serious tool and I am oblivious as to how to get it to do what I want. So here I am looking for a hand.
I run a multiple monitor desktop, and on one screen I run my game where I just need to press 1 then wait 1.1 seconds then press 2 then wait 1.1 seconds, and then press 3 and wait 0.5 seconds and then recycle (I have the recycle down by the way).
The problem is that I need to be able to work on my second monitor while the macro runs on the first not interrupting my work. So I tried the "Send Keys to Object Wizard" but the game doesn't have an object to send the key to. I just need the key to be sent to the game.

So to sum this up, how do I send "1" then "2" then "3" to an unfocused window that does not have an object in the window to focus on?

Jerry Thomas
Macro Veteran
Posts: 267
Joined: Mon Sep 27, 2010 8:57 pm
Location: Seattle, WA

Post by Jerry Thomas » Tue Jul 17, 2012 9:54 pm

This is fairly straight forward, but it might not do what you want...

The code to send the information, pause, send, etc. is easy.
In this example, Test.txt is my 'work' file, and MyGame is the game.

Code: Select all

//Give me time to start typing in Test.txt
SetFocus>Test.txt*
wait>5

SetFocus>MyGame*
Send>1
SetFocus>Test.txt*
Wait>1.1

SetFocus>MyGame*
Send>2
SetFocus>Test.txt*
Wait>1.1

SetFocus>MyGame*
Send>3
SetFocus>Test.txt*
Wait>0.5
If I understand your descriptiton, you want to keep working on your other monitor while this script does some of the game actions for you.

The problem is that when the focus moves to the other window for the Send command you might end up typing in that window. It wont happen often, but it could.

Hopefully this will get you started...
Thanks,
Jerry

[email protected]

Mr Fun
Newbie
Posts: 7
Joined: Tue Jul 17, 2012 7:56 pm

Post by Mr Fun » Wed Jul 18, 2012 1:42 am

Yeah if I read that correctly, it will just swap to the game instance hit the key and then flop back to my work. That wont work. I can't lose focus on work at all.

Jerry Thomas
Macro Veteran
Posts: 267
Joined: Mon Sep 27, 2010 8:57 pm
Location: Seattle, WA

Post by Jerry Thomas » Wed Jul 18, 2012 5:08 pm

Here is a similar conversation that may give you some more info as replies come in...

http://www.mjtnet.com/forum/objectsend ... 7390.html
Thanks,
Jerry

[email protected]

Mr Fun
Newbie
Posts: 7
Joined: Tue Jul 17, 2012 7:56 pm

Post by Mr Fun » Wed Jul 18, 2012 8:19 pm

Thanks Ill read into that.

Mr Fun
Newbie
Posts: 7
Joined: Tue Jul 17, 2012 7:56 pm

Post by Mr Fun » Thu Jul 19, 2012 4:46 am

So I have tried many many things, and I am at my wits end. It does not seem to like the name of the window. "The window handle is not valid" so if that helps anyone...

Jerry Thomas
Macro Veteran
Posts: 267
Joined: Mon Sep 27, 2010 8:57 pm
Location: Seattle, WA

Post by Jerry Thomas » Thu Jul 19, 2012 3:06 pm

Are you using the window title or handle?

The handle is more precise, but will be different every time you run the program. Your script will have to capture the handle each time the script runs.
GetWindowHandle>window title goes here,WinHandle

The WIN_USEHANDLE variable must be set to 1 for SetFocus to accept a handle.

Can you add a MessageModal call and see that the handle is a 7 digit number?

Can you post the few lines of code where you are capturing the handle and calling SetFocus?
Thanks,
Jerry

[email protected]

Mr Fun
Newbie
Posts: 7
Joined: Tue Jul 17, 2012 7:56 pm

Post by Mr Fun » Sat Jul 21, 2012 11:50 pm

Let me attempt to convert what you said into the macro and I'll post results here shortly. Thanks ahead of time!

Mr Fun
Newbie
Posts: 7
Joined: Tue Jul 17, 2012 7:56 pm

Post by Mr Fun » Mon Jul 30, 2012 2:40 am

So I have tried everything, and have been working on this for days. I just need something like this:

Code: Select all

GetWindowHandle>The Secret World,gamewindow
1
send 1 "gamewindow"
wait 1100 (milsec)
send 2 "gamewindow"
wait 1100 (milsec)

2
goto 1
So basically I need to to get the handle of the window and set it to the variable, then I need to be able to send key stroke "1" to that variable being the game window. and then wait 1.1 seconds and then send 2 to the same game window, and then wait 1.1 seconds and then reset and go back to 1 and repeat.
"The Secret World" is the name of the game that I would like to be able to run the macro on while I can do my work on the second monitor. Having to stop the macro setup on my G510 keyboard and then to jump over to the chat and watch my character die while I chat with a customer is very depressing.
I have contacted their support to see if they have any support for macroing, and they only thing they could tell me is that macro'ing is ok, just not unattended macroing and that they should have their own macro system in place in the next few patches, but no ETA.
Currently if I don't shut off the macro then the client gets "1" then "2" and it keeps going till I can shut it off :P

Mr Fun
Newbie
Posts: 7
Joined: Tue Jul 17, 2012 7:56 pm

Post by Mr Fun » Fri Aug 03, 2012 9:20 pm

Still no luck. :(

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts