Help with specific game script

Ask gaming related questions
Magnic
Posts: 7
Joined: 25 Apr 2016, 17:42

Help with specific game script

25 Apr 2016, 17:51

I want someone to fix my script because i'm too dumb to make it work.
I want it to be bound to specific window, press [up], [down] and wait 5min before repeating it forever or until manually stopped.

What i have right now after few hours of me trying to fix it.
~F6::
#IfWinActive DBVictory

Loop
{
send {Up} ;
send {Down} ;
sleep 300000 ;
}

#IfWinActive
As you can probably see, it won't work. And i have no idea why.
User avatar
Flarebrass
Posts: 104
Joined: 20 Nov 2015, 13:13
Location: USA
Contact:

Re: Help with specific game script

26 Apr 2016, 07:01

Code: Select all

SetTimer, keys, 300000

F6::toggle := !toggle

keys:
if toggle
{
	IfWinActive, DBVictory
		Send, {Up}{Down}
}
return
Do you want this to force DBVictory to become active? Or just check if it's the active window then send Up+Down if it is?
Last edited by Flarebrass on 26 Apr 2016, 07:22, edited 1 time in total.
(Note that I can't test my code before posting, so beware of bugs! -Flarebrass Amatzikahni)
John
Posts: 78
Joined: 10 Apr 2014, 08:59

Re: Help with specific game script

26 Apr 2016, 07:19

Not a prebaked solution, but this should help you in future,

Code: Select all

run,notepad.exe ;run/use 100% ahk compatible program
WinActivate, ahk_class Shell_TrayWnd ;deactivate it, so we can test if the next part works
#ifwinactive, ahk_class Notepad ;target window being notepad
p::
tooltip, hotkey activated ;visual cues to have a clue if what you wrote even works
loop, 20 { ;try to avoid infinite loops, at least when testing since you might crash your computer and then it's another 5 mins wasted
	tooltip, looping (%a_index%)
	sleep, 100
}
tooltip, hotkey ended
return
#ifwinactive
rshift::exitapp ;failsafe for when everything goes on craycray due to a typo or brainfreeze
Magnic
Posts: 7
Joined: 25 Apr 2016, 17:42

Re: Help with specific game script

26 Apr 2016, 09:31

Flarebrass wrote: Do you want this to force DBVictory to become active? Or just check if it's the active window then send Up+Down if it is?
I want it to work only in DBVictory window and nowhere else. DBVictory is active but no matter what i do if i leave it in the background, it start working in currently open window instead of DBV. Also i want it to repetitively do up+down once every 5min
User avatar
Flarebrass
Posts: 104
Joined: 20 Nov 2015, 13:13
Location: USA
Contact:

Re: Help with specific game script

27 Apr 2016, 09:06

The script I gave sends Up+Down only if DBVictory is the active window once every 5 minutes. If it sends Up+Down to other windows, then you should specify SetTitleMatchMode, 3 at the top of your script because there's unintended behavior. If you want to force-send Up+Down to the window "DBVictory" regardless of whether it is the top window or not, then you can add more functionality to the script to do so, but I didn't get clarity from your last reply on the exact specifications of what you need so there's not much more I can say at this point.
(Note that I can't test my code before posting, so beware of bugs! -Flarebrass Amatzikahni)
Magnic
Posts: 7
Joined: 25 Apr 2016, 17:42

Re: Help with specific game script

28 Apr 2016, 02:57

@Flarebrass
I have no idea what is says in the link you posted. I'm not a programmer in any possible way. "My" script is edited script which someone else did for me. I didn't wrote it all, just edited it. That's why i asked someone to "make me" not "help make me" a script, because it will take few months and i still won't be able to make any script at all. Not to mention english isn't my first language, so learning programming in english is impossible for me. Actually learning anything i know i won't need at least for the rest of my life is impossible. I have that kind of blockage.
User avatar
Flarebrass
Posts: 104
Joined: 20 Nov 2015, 13:13
Location: USA
Contact:

Re: Help with specific game script

28 Apr 2016, 05:18

I would appreciate if you would let me know what you want for your script. My code works, but you're saying it doesn't, which means that your description is different from your desired behavior.

Can you provide more details on how you want your script to work?

Do you want to force DBVictory to become the active window every 5 minutes so that Up+Down can be sent?
Do you want to check every 5 minutes whether DBVictory is active, and if it is, then send Up+Down?
Do you want Up+Down to be sent to the window DBVictory every 5 minutes regardless of whether the window can be seen or not?
What is currently not operating or performing as intended?
Magnic wrote:I want it to work only in DBVictory window and nowhere else.
It currently does.
Magnic wrote:DBVictory is active but no matter what i do if i leave it in the background, it start working in currently open window instead of DBV.
If the code is acting on another, unintended window, then go to the very beginning of the script, press Enter or Return once, then press the Up arrow so that you're on the first line, and copy+paste the following code into that first line:
SetTitleMatchMode, 3
If it still has problems acting upon unintended windows, then I'll know exactly where those problems reside and can begin to attempt various solutions.
Magnic wrote: Also i want it to repetitively do up+down once every 5min
My code currently checks if DBVictory is the active window, and if it is, it will send Up+Down, then do nothing for 5 minutes before repeating the process.
(Note that I can't test my code before posting, so beware of bugs! -Flarebrass Amatzikahni)
Magnic
Posts: 7
Joined: 25 Apr 2016, 17:42

Re: Help with specific game script

28 Apr 2016, 07:24

Ok let me rephrase it. Maybe my speaking skills are lower than i thought. I want it to:
-Work only in one and only game window
-Send up+down once every 5min
-Do all of it even if it's in the background or minimalized without pulling it "on top".

currently its doing all but the last thing. Right now i need to have be on this window for script to work. I want it to work regardless of me being in the game window or not.
Shadowpheonix
Posts: 1259
Joined: 16 Apr 2015, 09:41

Re: Help with specific game script

28 Apr 2016, 09:38

You will need to remove the WinActivate entry, and replace the Send commands with ControlSend. Be aware that this does not work with all applications.
User avatar
Flarebrass
Posts: 104
Joined: 20 Nov 2015, 13:13
Location: USA
Contact:

Re: Help with specific game script

29 Apr 2016, 06:20

Magnic wrote:-Do all of it even if it's in the background or minimalized without pulling it "on top".
I avoided that because it's more complicated and requires you to do some personal research and testing to work.

In a nutshell, we have to figure out the control type and name of your program, then tell AHK to forcibly send Up+Down to that specific control within that window.

The first method to find out this information is through WindowSpy. If you open up the program that comes packaged with AHK called WindowSpy, you'll have to mess with the options to eventually get something like the ClassID or ControlName of DBVictory. I don't really mess with WindowSpy much, so I'll leave that to you if you so choose.

The second method is by making a few scripts to tell us that information, then plug that information into your current script. Run the following script, hover over the region where you want Up+Down to be sent, and press Number Pad 1:

Code: Select all

Numpad1::
MouseGetPos, x, y, winTitle, controlClass
MsgBox, The window's title is "%winTitle%"`nThe control's class is "%controlClass%"
ExitApp
Copy and paste the window's title (between the quotation marks) and the control's class into the X's in the following script:

Code: Select all

SetKeyDelay, 0, 30
SetTitleMatchMode, 2
SetTimer, keys, 300000

F6::toggle := !toggle

keys:
if (toggle)
{
	Critical, On
	ControlSend, XXXcontrolXXX, {Up}{Down}, XXXwindowtitleXXX
	Critical, Off
}
return
You may have something that looks like ControlSend, boolDinoBotVictoryYes, {Up}{Down}, DBVictory when it's all done. Hopefully this works for you!
(Note that I can't test my code before posting, so beware of bugs! -Flarebrass Amatzikahni)
Magnic
Posts: 7
Joined: 25 Apr 2016, 17:42

Re: Help with specific game script

03 May 2016, 16:44

ok, i know it were a few days, excuse me for that :oops: . I've been kind of busy as of lately.
I used windowspy and that's what i got:
>>>>>>>>>>( Window Title & Class )<<<<<<<<<<<
DBVictory: Series [S3]
ahk_class dbv

>>>>>>>>>>>>( Mouse Position )<<<<<<<<<<<<<
On Screen: 683, 577 (less often used)
In Active Window: 691, 585

>>>>>>>>>( Now Under Mouse Cursor )<<<<<<<<

Color: 0xF0F0F0 (Blue=F0 Green=F0 Red=F0)

>>>>>>>>>>( Active Window Position )<<<<<<<<<<
left: -8 top: -8 width: 1296 height: 1010

>>>>>>>>>>>( Status Bar Text )<<<<<<<<<<

>>>>>>>>>>>( Visible Window Text )<<<<<<<<<<<

>>>>>>>>>>>( Hidden Window Text )<<<<<<<<<<<

>>>>( TitleMatchMode=slow Visible Text )<<<<

>>>>( TitleMatchMode=slow Hidden Text )<<<<
Magnic
Posts: 7
Joined: 25 Apr 2016, 17:42

Re: Help with specific game script

04 May 2016, 15:01

...is anyone out there? Is it too old for anyone to even consider looking into this thread?
Magnic
Posts: 7
Joined: 25 Apr 2016, 17:42

Re: Help with specific game script

05 May 2016, 03:24

Ok, i reread what is over my comment. I tried that script and nothing happens.
Thats how it looks like now:
SetKeyDelay, 0, 30
SetTitleMatchMode, 2
SetTimer, keys, 300000

F6::toggle := !toggle

keys:
if (toggle)
{
Critical, On
ControlSend, ahk_class dbv, {Up}{Down}, DBVictory: Series [S3]
Critical, Off
}
return
I click f6 and nothing happen. Even after i shorten time to 1s, there is still nothing.
User avatar
Flarebrass
Posts: 104
Joined: 20 Nov 2015, 13:13
Location: USA
Contact:

Re: Help with specific game script

05 May 2016, 05:30

ahk_class deals with the window, not the control. If WindowSpy isn't telling you the program's control and my script is giving a blank variable, then the control cannot be determined and you will need to use another method. You can try removing the control altogether and doing a ControlSend directly to the window and see if that works: ControlSend,, {Up}{Down}, DBVictory: Series. You might also need to mess with what is being sent using some of the techniques within this thread.

What you're trying to do is much more advanced than a simple Send command, so you will have to do some research and testing on your own. If you're not a programmer, that makes the task much more difficult. In addition, most of us don't have that application and can't test it explicitly for functionality, so we can only suggest solutions for you to try out. My best recommendation is to get the program to recognize a simple Send command before messing with ControlSend since there are more things which can go wrong:

Code: Select all

SetKeyDelay, 0, 30
F6::Send, {Up}{Down}
Esc::ExitApp
Load this code, make DBVictory the active window so that keyboard inputs are recognized properly, then press F6 and see if it sends the up arrow followed by the down arrow. If not, then the ControlSend script I wrote won't function regardless of the arguments because the method is buggy for your game.
(Note that I can't test my code before posting, so beware of bugs! -Flarebrass Amatzikahni)

Return to “Gaming”

Who is online

Users browsing this forum: Elish, Google [Bot], Spawnova and 7 guests