 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Endusa
Joined: 09 May 2008 Posts: 21
|
Posted: Wed Jul 23, 2008 9:28 pm Post subject: random moves (up, down, left, right) |
|
|
Hi, I wonder if someone could help me with this....I want a script tha press randomly up, down, left and right....Is for character of game move ramdomly...
I realy dont have any idea how to do it.....I think something like this
| Code: |
x::
loop 15,
{
y = random [,up ,down ,left, right]
Send, {%y% down}{%y% up}
sleep 100
}
Loop 3,
{
PixelSearch, Px, Py, 17, 142, 551, 546, 0xDBBCB5, 3, Fast
Send, {f2 down}{f2 up}
sleep, 100
Send, {f2 down}{f2 up}
sleep, 2000
Click, %Px%, %Py%
}
|
but it didīt works |
|
| Back to top |
|
 |
SpiderGames
Joined: 09 Jun 2008 Posts: 284 Location: Canada
|
Posted: Wed Jul 23, 2008 9:34 pm Post subject: |
|
|
This mgiht not be th best answer. But here it is...
| Code: |
Loop,
{
Random, fish, 1, 4
if %fish% = 1
Send, {Up}
if %fish% = 2
Send, {Down}
if %fish% = 3
Send, {Left}
if %fish% = 4
Send, {Right}
}
!x::
ExitApp |
_________________ http://www.spider-games77.piczo.com
Join the Elite few... |
|
| Back to top |
|
 |
Endusa
Joined: 09 May 2008 Posts: 21
|
Posted: Wed Jul 23, 2008 9:37 pm Post subject: |
|
|
| It realy works for me, but is the best way of doing it? |
|
| Back to top |
|
 |
Krogdor
Joined: 18 Apr 2008 Posts: 908 Location: The Interwebs
|
Posted: Wed Jul 23, 2008 9:40 pm Post subject: |
|
|
| Endusa wrote: | | It realy works for me, but is the best way of doing it? |
Pretty much... The random command only supports numbers, so you then have to convert that into a key name. A bit shorter would be to do:
| Code: | Random, Key, 1, 4
Key := (Key = 1 ? "Left" : (Key = 2 ? "Right" : (Key = 3 ? "Down" : "Up"))) |
|
|
| Back to top |
|
 |
SpiderGames
Joined: 09 Jun 2008 Posts: 284 Location: Canada
|
Posted: Wed Jul 23, 2008 9:44 pm Post subject: |
|
|
| Quote: | Code (Copy):
Random, Key, 1, 4
Key := (Key = 1 ? "Left" : (Key = 2 ? "Right" : (Key = 3 ? "Down" : "Up")))
|
Told yeah _________________ http://www.spider-games77.piczo.com
Join the Elite few... |
|
| Back to top |
|
 |
Endusa
Joined: 09 May 2008 Posts: 21
|
Posted: Wed Jul 23, 2008 10:04 pm Post subject: |
|
|
Thanks for your help. However, I dont no why, the game doest recibe de keys...
It recibes clicks, send, {f2 up} {f2 down}, etc...
but i canīt make the caracter to move...
I try something easy like
x::
Send, {up}
sleep, 300
Send, {up}
return
but nothing......any idea of whats going on? |
|
| Back to top |
|
 |
SpiderGames
Joined: 09 Jun 2008 Posts: 284 Location: Canada
|
|
| Back to top |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 1128
|
Posted: Wed Jul 23, 2008 10:51 pm Post subject: |
|
|
| Code: | Sendmode, Input
SetKeyDelay, 10, 100
Keys = {Up},{down},{left},{right}
StringSplit, key, keys, `,
Loop
{
Random, key, 1, %key0%
Send, % "{blind}" key%key%
Sleep 1000
} |
_________________ My Home Thread
More Common Answers: 1. It's in the FAQ 2. Ternary ( ? : ) guide 3. Post code with [code][/code] tags |
|
| Back to top |
|
 |
Sivvy
Joined: 21 Jul 2008 Posts: 311 Location: Calgary, AB, Canada
|
Posted: Wed Jul 23, 2008 11:05 pm Post subject: |
|
|
| From what I read a while ago in the docs, SendPlay seems to be the preferable method of input when it comes to games, while SendInput is preferable for everything else. Maybe try SendPlay. |
|
| Back to top |
|
 |
Endusa
Joined: 09 May 2008 Posts: 21
|
Posted: Thu Jul 24, 2008 2:06 am Post subject: |
|
|
thanks all of you...we solve it....the way of doing it was with sentmode, event. So the code is like this:
| Code: |
x::
Sendmode, event
Send, {f10 down}{f10 up}
SetKeyDelay, 10, 100
Keys = {Up},{down},{left},{right}
StringSplit, key, keys, `,
Loop,
{
Random, key, 1, %key0%
Send, % "{blind}" key%key%
Sleep 1000
}
|
|
|
| Back to top |
|
 |
Endusa
Joined: 09 May 2008 Posts: 21
|
Posted: Thu Jul 24, 2008 2:25 am Post subject: |
|
|
okay, I want to complate things now....I just want that when random chose a direction, for ejemple, "up", it pressed 4 times conticutive.....su it coud be in a random way something like this:
up,up,up,up,down,down,down,down,left,left,left,left,down,down,down,down,up,up,up,up,right,right,right,right, |
|
| Back to top |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 1128
|
Posted: Thu Jul 24, 2008 3:30 am Post subject: |
|
|
| Code: | | Keys = {Up 4},{down 4},{left 4},{right 4} |
_________________ My Home Thread
More Common Answers: 1. It's in the FAQ 2. Ternary ( ? : ) guide 3. Post code with [code][/code] tags |
|
| Back to top |
|
 |
Krogdor
Joined: 18 Apr 2008 Posts: 908 Location: The Interwebs
|
Posted: Thu Jul 24, 2008 3:32 am Post subject: |
|
|
| Code: |
x::
Sendmode, event
Send, {f10 down}{f10 up}
SetKeyDelay, 10, 100
Keys = {Up},{down},{left},{right}
StringSplit, key, keys, `,
Loop,
{
Random, key, 1, %key0%
Send, % "{blind} {" key%key% " 4}"
Sleep 1000
}
|
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|