SetFocus with no title?!

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Link

SetFocus with no title?!

Post by Link » Tue Oct 12, 2004 12:47 pm

I am making a more complicated game macro and every hour I get it to press 1 then 2 up to 5. But send does not work. So I searched this forum and found i needed to SetFocus to the game. But... this game has no window title so Im wondering how I would go about it. I tried this:

GetActiveWindow>window_title,X,Y
SetFocus>window_title

in my code but it didnt work. Can anyone suggest how I might be able to setfocus simply to the currently active window

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Tue Oct 12, 2004 2:29 pm

Hi Link

1. What do you mean by "it didn't work"?
2. Referring to your script, please find out the value of window_title:
GetActiveWindow>window_title,X,Y
Msg>window_title
SetFocus>window_title

Link

OK finding out..

Post by Link » Tue Oct 12, 2004 2:35 pm

1. When I mean didnt work, I forgot to mention that while mouse commands are working fine when i try to send 1 to press 1 in game (to use an item) it doesnt work.

2. Finding out now can u hang around please :P

ok..

no title

Post by ok.. » Tue Oct 12, 2004 2:44 pm

Ok I found out the window title and its nuthin like I fort. Same as it shows on the taskbar. What can I do... do u want to see my entire macro?

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Oct 12, 2004 2:45 pm

Please submit more of your code, especially where you are trying to Send "1".

And be sure to remove all Trailing Spaces from your script.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Guest

Post by Guest » Tue Oct 12, 2004 2:47 pm

Label>Start
GetActiveWindow>window_title,X,Y
SetFocus>window_title
Let>SK_DELAY=10
Hour>starttime
Let>a=1
Label>Macro
LDown
Wait>1
Hour>currenttime
Let>Elapsed=currenttime-starttime
If>a=1,if1
If>a=2,if2
If>a=3,if3
If>a=4,if4
If>a=5,if5
If>a=6,Macro

Label>if1
If>Elapsed=1,eat1,Macro
Label>if2
If>Elapsed=1,eat2,Macro
Label>if3
If>Elapsed=1,eat3,Macro
Label>if4
If>Elapsed=1,eat4,Macro
Label>if5
If>Elapsed=1,eat5,Macro

Label>eat1
Send>1
Let>starttime=currenttime
Let>a=2
Let>Elapsed=0
Goto>Macro

Label>eat2
Send>2
Let>starttime=currenttime
Let>a=3
Let>Elapsed=0
Goto>Macro

Label>eat3
Send>3
Let>starttime=currenttime
Let>a=4
Let>Elapsed=0
Goto>Macro

Label>eat4
Send>4
Let>starttime=currenttime
Let>a=5
Let>Elapsed=0
Goto>Macro

Label>eat5
Send>5
Let>starttime=currenttime
Let>a=6
Let>Elapsed=0
Goto>Macro

Label>End

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Tue Oct 12, 2004 3:13 pm

Hi Link, Ok.., Guest,

The basic question here is whether you normally type 1 during the game. Most games have very limited support of keyboard functions such as , and .

It doesn't make any sense to set focus to the currently active (focused) window.

Why is LDown issued without any mouse positioning command?

Given such short time, Elapsed will be nearly zero. Please find out the value of Elapsed by: Msg>Elapsed
If Elapsed is 0 (zero), then all 6 IF comparisions will fail. Nonetheless, without a Goto> command, the control will still pass to Label>if1.

Link

Post by Link » Tue Oct 12, 2004 3:23 pm

Just Link :P

Ok Armsys, it does have the ability to press 1 at any time

the left mouse button remains pressed with no mouse coords because I put my mouse over the relevant place and then start the macro

elapsed yea shud be 0 for a long time until the hour changes. And all the ifs wont fail wen the elapse changes. Ill explain it..

program starts puts current hour in starttime loop begins puts currenttime in currenttime and fins the elapse which of course would be 0 at the start so all the ifs would fail and it would keep repeating the small LDown etc part.

When the hour changes, elapse becomes 1 and based on wot variable a is i.e 1 the relevant if would be true and move to the eat1 lable. here the elapsed time is reset to 0 and the STARTTIME is made to be the same as currenttime also the variable a is cahnged. den it goes bk to LDown loop and it keeps goin till elapse is 1 then it does the if2 lable etc etc....

ive traced it b4 and it works.. wen it gets to send it places an extra 1 in the code send>1 to send>11 which i have to delete after. But it wont press 1 in game. I also tried releasing the mousebutton but that didnt work. hmm...

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Tue Oct 12, 2004 3:42 pm

Hi Link,

I'm unsure whether the window focus has been changed after LDown. As mentioned in my last post, all 6 IF comparisions will fail initially:
If>a=1,if1
If>a=2,if2
If>a=3,if3
If>a=4,if4
If>a=5,if5
If>a=6,Macro

Again, all 5 IF comparisons under Labels if1, if2, if3, if4, if5 will fail again. Then, the control will be passed to Label>eat1 and typinng 1 is simulated by Send>1.

BTW, how come the left mouse button isn't released immeidately after Ldown?
Last edited by armsys on Tue Oct 12, 2004 3:49 pm, edited 1 time in total.

Link

Post by Link » Tue Oct 12, 2004 3:48 pm

but wen all dese fail when elapse=0

Label>if1
If>Elapsed=1,eat1,Macro
Label>if2
If>Elapsed=1,eat2,Macro
Label>if3
If>Elapsed=1,eat3,Macro
Label>if4
If>Elapsed=1,eat4,Macro
Label>if5
If>Elapsed=1,eat5,Macro

only one will fail depending on wot a currently is.

example a=1, elapse is still 0

If>a=1,if1

goes straight to if1 label

Label>if1
If>Elapsed=1,eat1,Macro

if fails, the false action is to go to label Macro so it wont neva get to label eat1 if it keeps failing which is wat i want. But wot u said could be the solution. If i set the focus at say um just b4 the send command for each eat subroutine, wud that work.. Must remind u that the window has no name at all.. but i foudn the process name is DragonRaja.bin (now u no wot game this is for :P)

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Oct 12, 2004 3:56 pm

now u no wot game this is for
I dont understand why you would not provide the name of the game to begin with. Any information can be helpful when trying to troubleshoot someone's problems.

Like armsys, I have been curious about the LDown button never being released, and I still don't see an answer to that question. IT appears that if you were at the keyboard, you would left click down on the mouse button and hold it there for the rest of the routine? Gonna get a cramp in the finger pretty soon!
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Tue Oct 12, 2004 4:00 pm

Hi Link,

I've trouble in deciphering your encrypted post.

Link

Post by Link » Tue Oct 12, 2004 4:01 pm

yea sorry shudve provided the game name

ok i see wot ur sayin but say i changed it to just clicking repetitvely would that even help?. Cos I tested it in game and the mouse aspect of it works fine...

so basically do you fink it is not pressing one cos the mouse button is constantly pressed? im sure ders a simple fix. Ive traced the macro like i send b4 and it worked 100% i simulated an hour change by changing the time in Windows.

so all i need to know is how to get that send to work...

Thanks Bob,armsys

Link

Post by Link » Tue Oct 12, 2004 4:03 pm

armsys wrote:Hi Link,

I've trouble in deciphering your encrypted post.
Yea, im typing way too quickly and without the necessary punctuation :P.

Link
Newbie
Posts: 3
Joined: Tue Oct 12, 2004 4:12 pm

After a simple test...

Post by Link » Tue Oct 12, 2004 4:32 pm

Label>Start
Send>1
Label>End


I ran this very simple macro which i hope shud just mean "Press 1" and it didnt work as i didnt focus etc.

So bascially ignoring my full macro how do i focus ont he active window
a window with NO title at all

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