Jump to content


Photo

Need Help - Repeat 2 commands every 2 secs


  • Please log in to reply
24 replies to this topic

#1 Blacky

Blacky
  • Members
  • 12 posts

Posted 13 April 2012 - 06:10 PM

Hey,
I didn't find anything scripted like I need it and I am bad in writing scripts.
If you would help me it would be awesome. I really need it for the game I play.

I need a function like this:

I press a button combination to de/activate the script, e.g. "ctrl+y".
Then the script activates the "F1" key and after 0.5 sec delay the "Left Mouse Button".
Then this key combination should be repeated every 2 seconds.


Regards,
Blacky

#2 janopn

janopn
  • Members
  • 691 posts

Posted 13 April 2012 - 06:20 PM

Hi!
Your code could be:

Settimer, routine, 2000
Settimer, routine, off
enabled=

^Y::
if !enabled
{
enabled = 1
Settimer, routine, on
}
else
{
enabled=
Settimer, routine, off
}
return

routine:
Send, {F1}
Sleep, 500
Click
return


#3 Ohnitiel

Ohnitiel
  • Members
  • 664 posts

Posted 13 April 2012 - 06:22 PM

janopn was faster than me it seems...

Toggle = 0

SetTimer, macro, 2000

^y::
Toggle := !Toggle
return

macro:
If toggle
{
     Send, {F1}
     Sleep 500
     Click
}
return

But I recommend you read the tutorials, Autohotkey language is really simple and you should be capable of making these scripts with ease after reading it.

#4 Blacky

Blacky
  • Members
  • 12 posts

Posted 13 April 2012 - 06:45 PM

Thank you, it works, but sadly not in the game. :(

#5 Ohnitiel

Ohnitiel
  • Members
  • 664 posts

Posted 13 April 2012 - 06:49 PM

Thank you, it works, but sadly not in the game. :(

Try using other send methods (sendevent, sendinput, sendplay)

#6 janopn

janopn
  • Members
  • 691 posts

Posted 13 April 2012 - 06:51 PM

Hi Blacky!
You should change the Send method.
Try with Sendplay instead of Send.

Also you should try with ControlSend, or holding the key (logically) por a while.

I leave you an example of the last one:

If toggle
{
     Send, {F1 down}
     Sleep, 100
     Send, {F1 up}
     Sleep 500
     Click down
     Sleep, 100
     Click up
}


#7 Blacky

Blacky
  • Members
  • 12 posts

Posted 13 April 2012 - 07:00 PM

Sendevent, Sendinput, Sendplay, ControlSend, everything does not work. It just keeps working on desktop, but not in the Game.

#8 janopn

janopn
  • Members
  • 691 posts

Posted 13 April 2012 - 07:20 PM

Sendevent, Sendinput, Sendplay, ControlSend, everything does not work. It just keeps working on desktop, but not in the Game.


AHK does not work in all the games.
ControlSend didn't work either?
Are you using it correctly?

Please, check the documentation of ControlSend.

If does not work, please, leave us your code.

#9 Blacky

Blacky
  • Members
  • 12 posts

Posted 13 April 2012 - 08:22 PM

I actually don't understand a word about the ControlSend. I think I am just too stupid.

#10 janopn

janopn
  • Members
  • 691 posts

Posted 13 April 2012 - 08:50 PM

I actually don't understand a word about the ControlSend. I think I am just too stupid.


Or you are just not trying.
Controlsend, unlikely other send ways, sends keypresses directly to a program/aplication.

So you have to specify which program/aplication you want to send the Key.

Try this one:

Settitlematchmode 2
ControlSend,, {F1}, Title of the window of the game

The parameter "Title of the window of the game" should be replaced with the actual title of the window of the game.
The settitlematchmode 2 allows you to just write part of the title, and not the whole.

For example.. if window's name is "World of Warcraft", you could write

Settitlematchmode 2
ControlSend,, {F1}, Warcraft


#11 Blacky

Blacky
  • Members
  • 12 posts

Posted 13 April 2012 - 09:05 PM

I got this now, but it doesn't work.

Toggle = 0

SetTimer, macro, 2000

^y::
Toggle := !Toggle
return

macro:
If toggle
{
     ControlSend,, {F1}, Ragnarok
     Sleep 500
     Click
}
return


Edit: I was told that my game has to be in window mode and that there is a problem with the solution. Is that right?

#12 Blacky

Blacky
  • Members
  • 12 posts

Posted 14 April 2012 - 06:41 PM

Can someone help me?

#13 Blacky

Blacky
  • Members
  • 12 posts

Posted 15 April 2012 - 03:07 PM

bump

#14 Tilter_of_Windmills

Tilter_of_Windmills
  • Members
  • 323 posts

Posted 15 April 2012 - 03:25 PM

I have found that a script can work in a game, but not in an online gaming site like Voobly, for instance. You might just have to play the game the way it was intended to be played. Maybe that's not so bad...

#15 Blacky

Blacky
  • Members
  • 12 posts

Posted 15 April 2012 - 05:02 PM

That is bad, I really would like to use it. I mean in 4h every 2 sec using the same keys is really annoying.

I just don't understand why it doesn't work. I mean I just want to simulate my keys.