Sign in to follow this  
Followers 0
Guest LonestarDragon

Help Tweeking My Script

4 posts in this topic

Returnin once again with my noobieness to introduce my first full and working script. I would like to add a few things though if anyone is able to help me out.

1) For some reason the mouse clicks don't always "register" (best decription i could come up for it) like they are supposed to. I'll see the mouse move over to the part of the screen it's supposed to click, but doesn't, then move on to the next step in the scipt.

2) I would like to add a pause command to this script. I'm a noobie and I've looked at the examples given in the help file but still can't figure this out. If it's possible I would like it to pause the script and switch to a different window of my choice. This would help greatly in hiding the fact that I'm playing this game at work. =)

3) I would also like to get any feedback for ways I can change the script so that it might run better and/or other commands I can use in place of the ones I have.

Thank you to anyone who takes there time to review this post and reply to it. Please try to be as detailed as possible with your replies as again I am a noob.

D.Y.

My First Script

Run("C:\Documents and Settings\v022006\My Documents\Instructions\dabykt2.exe")

;This is the trainer for the game

MouseClickDrag("left", 426,284,63,12,10)

;This drags the trainer window and positions it in the

top left corner of the desktop

MouseMove(47, 767, 10)

;I was unable to get the Run command to work with

the game .exe file so I went through these mouse....

Sleep(700)

;clicks to to open the program from the start menu

MouseClick("left")

MouseMove(89,484,10)

Sleep(700)

MouseMove(230,333,10)

Sleep(700)

MouseMove(476,380,10)

Sleep(700)

Mouseclick("left",640,413,2,5)

;You'll notice with with just about all my mouse clicks

that there are always 2-5 clicks

MouseClickDrag("left",744,98,849,10,10)

;For some reason if I do only 1 or 2 it doesn't always

register the click on my screen

$i = 0

;the last command move the game window to the

top right corner of the screen

Do

MouseMove(620,402,10)

;This moves the mouse over the game window

While PixelGetColor (620,402) <> 1408150

;This checks the pixel at the x,y, location to see

if it's the given dec. color

Sleep(100)

Wend

MouseClick("left" ,620,402,5,5)

;Once the pixel is the correct color it will click the

duel option on the screen

Sleep(100)

; "Note" the window info program would not list

any control ID's for the game window which is why

I'm moving the mouse around instead

MouseMove(625,449,10)

While PixelGetColor (625,449) <> 3604479

;This waits until the next screen pops up

Sleep(100)

Wend

MouseClick("left" ,625,449,5,5)

;This chooses the type of duel

MouseMove(617,328,10)

While PixelGetColor (617,328) <> 15854407

;This waits until the next screen pops up

Sleep(100)

Wend

Sleep(1000)

MouseClick("left" ,592,470,5,5)

;At this point you play rock, paper, scissors to

see who goes first

While PixelGetColor (991,476) <> 0

;I've set this part of the scipt up to repeat itself

until it gets to the main dueling table

Sleep(100)

;I didnt feel like putting a huge amount of time

trying to get the script to realize if it lost, tied, or

won the R.P.S match

MouseClick("left" ,592,470,5,5)

Wend

;Once it's to the table screen it move on to the next set of commands

Sleep(4000)

ControlClick("YuGiOh Kaiba's Revenge +2 Trainer","Insta Win",1000,"left",5)

;This switches over to the trainer and activates the

Instant win cheat, then switches back to the game window

WinActivate("Yu-Gi-Oh! Power of Chaos")

MouseMove(574, 492)

While PixelGetColor (574,492) <> 14985074

;This waits until the next screen pops up

Sleep(100)

Wend

MouseClick("left",659,489,5,5)

;This clicks the no options for saving a replay of the duel

Sleep(5000)

MouseClick("left",659,489,5,5)

;This waits until the scoreboard pops up then moves

on to the card swap screen before the next duel

Sleep(3000)

MouseMove(340,595,5)

;This Chooses not to change any of your cards and begin the duel again

MouseClick("left",340,595,5,5)

While PixelGetColor (991,476) <> 0

;At this point lines 45-59 are repeated into line 62-75

because the overall winner of the duel is

detemined by a 2 out of 3 falls match, there

are a few adjusts to the sleep time because of

a few different screens that pop up

Sleep(100)

Wend

Sleep(4000)

ControlClick("YuGiOh Kaiba's Revenge +2 Trainer","Insta Win",1000,"left",5)

WinActivate("Yu-Gi-Oh! Power of Chaos")

MouseMove(574, 492)

While PixelGetColor (574,492) <> 14985074

Sleep(100)

Wend

MouseClick("left",659,489,5,5)

Sleep(6000)

MouseClick("left",659,489,5,5)

Sleep(10000)

MouseClick("left",659,489,5,5)

;At this point you receive your new cards for

winning the match, wanting all these cards is why I

made this script

Sleep(14000)

$i = $i + 1

;This adds one to the value of $i

Until $i = 2

;This finishes up the loop and will repeat lines 27

through 79 until the value of $i = 2 or whatever number

you insert

WinClose("Yu-Gi-Oh! Power of Chaos")

;This closes the game when the script is done

WinClose("YuGiOh Kaiba's Revenge +2 Trainer")

;This closes the game when the script is done

Share this post


Link to post
Share on other sites



Because your code is coloured, and not wrapped in code /code tags, Not many will want to take a serious look at it. It will be easier on us if you re-post with your code in the correct format. Simply put a [.code] tag at the front of your code and a [./code] at the end of it. (just don't include the periods)


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

Run("C:\Documents and Settings\v022006\My Documents\Instructions\dabykt2.exe")
MouseClickDrag("left", 426,284,63,12,10)
MouseMove(47, 767, 10)
Sleep(700)
MouseClick("left")
MouseMove(89,484,10)
Sleep(700)
MouseMove(230,333,10)
Sleep(700)
MouseMove(476,380,10)
Sleep(700)
Mouseclick("left",640,413,2,5)
MouseClickDrag("left",744,98,849,10,10)
$i = 0
Do
MouseMove(620,402,10)
While PixelGetColor (620,402) <> 1408150
Sleep(100)
Wend
MouseClick("left" ,620,402,5,5)
Sleep(100)
MouseMove(625,449,10)
While PixelGetColor (625,449) <> 3604479
Sleep(100)
Wend
MouseClick("left" ,625,449,5,5)
MouseMove(617,328,10)
While PixelGetColor (617,328) <> 15854407
Sleep(100)
Wend
Sleep(1000)
MouseClick("left" ,592,470,5,5)
While PixelGetColor (991,476) <> 0
Sleep(100)
MouseClick("left" ,592,470,5,5)
Wend
Sleep(4000)
ControlClick("YuGiOh Kaiba's Revenge +2 Trainer","Insta Win",1000,"left",5)
WinActivate("Yu-Gi-Oh! Power of Chaos")
MouseMove(574, 492)
While PixelGetColor (574,492) <> 14985074
Sleep(100)
Wend
MouseClick("left",659,489,5,5)
Sleep(5000)
MouseClick("left",659,489,5,5)
Sleep(3000)
MouseMove(340,595,5)
MouseClick("left",340,595,5,5)
While PixelGetColor (991,476) <> 0
Sleep(100)
Wend
Sleep(4000)
ControlClick("YuGiOh Kaiba's Revenge +2 Trainer","Insta Win",1000,"left",5)
WinActivate("Yu-Gi-Oh! Power of Chaos")
MouseMove(574, 492)
While PixelGetColor (574,492) <> 14985074
Sleep(100)
Wend
MouseClick("left",659,489,5,5)
Sleep(6000)
MouseClick("left",659,489,5,5)
Sleep(10000)
MouseClick("left",659,489,5,5)
Sleep(14000)
$i = $i + 1
Until $i = 2
WinClose("Yu-Gi-Oh! Power of Chaos")
WinClose("YuGiOh Kaiba's Revenge +2 Trainer")

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Ok, to answer your second question:

Turn your main block of code into a function and then use a toggle switch to send the script into an empty loop.

The example script will run until you hit the ESC key. the PAUSE key will throw it into the empty loop.

Example:

HotKeySet("{esc}","MyExit")
HotKeySet("{pause}","_Pause")

$paused = 1

; primary data loop
While 1
    Sleep(10)
    If $paused = 1 Then
        Do
            Sleep(10)
        Until $paused = 0
    EndIf
    _Main()
WEnd

Func MyExit()
    Exit
EndFunc

Func _Pause(ByRef $paused)
    If $paused = 0 Then 
        $paused = 1
    Else
        $paused = 0
    EndIf
EndFunc

Func _Main()
Run("C:\Documents and Settings\v022006\My Documents\Instructions\dabykt2.exe")
MouseClickDrag("left", 426, 284, 63, 12, 10)
MouseMove(47, 767, 10)
Sleep(700)
MouseClick("left")
MouseMove(89, 484, 10)
Sleep(700)
MouseMove(230, 333, 10)
Sleep(700)
MouseMove(476, 380, 10)
Sleep(700)
MouseClick("left", 640, 413, 2, 5)
MouseClickDrag("left", 744, 98, 849, 10, 10)
$i = 0
Do
   MouseMove(620, 402, 10)
   While PixelGetColor(620, 402) <> 1408150
      Sleep(100)
   WEnd
   MouseClick("left", 620, 402, 5, 5)
   Sleep(100)
   MouseMove(625, 449, 10)
   While PixelGetColor(625, 449) <> 3604479
      Sleep(100)
   WEnd
   MouseClick("left", 625, 449, 5, 5)
   MouseMove(617, 328, 10)
   While PixelGetColor(617, 328) <> 15854407
      Sleep(100)
   WEnd
   Sleep(1000)
   MouseClick("left", 592, 470, 5, 5)
   While PixelGetColor(991, 476) <> 0
      Sleep(100)
      MouseClick("left", 592, 470, 5, 5)
   WEnd
   Sleep(4000)
   ControlClick("YuGiOh Kaiba's Revenge +2 Trainer", "Insta Win", 1000, "left", 5)
   WinActivate("Yu-Gi-Oh! Power of Chaos")
   MouseMove(574, 492)
   While PixelGetColor(574, 492) <> 14985074
      Sleep(100)
   WEnd
   MouseClick("left", 659, 489, 5, 5)
   Sleep(5000)
   MouseClick("left", 659, 489, 5, 5)
   Sleep(3000)
   MouseMove(340, 595, 5)
   MouseClick("left", 340, 595, 5, 5)
   While PixelGetColor(991, 476) <> 0
      Sleep(100)
   WEnd
   Sleep(4000)
   ControlClick("YuGiOh Kaiba's Revenge +2 Trainer", "Insta Win", 1000, "left", 5)
   WinActivate("Yu-Gi-Oh! Power of Chaos")
   MouseMove(574, 492)
   While PixelGetColor(574, 492) <> 14985074
      Sleep(100)
   WEnd
   MouseClick("left", 659, 489, 5, 5)
   Sleep(6000)
   MouseClick("left", 659, 489, 5, 5)
   Sleep(10000)
   MouseClick("left", 659, 489, 5, 5)
   Sleep(14000)
   $i = $i + 1
Until $i = 2
WinClose("Yu-Gi-Oh! Power of Chaos")
WinClose("YuGiOh Kaiba's Revenge +2 Trainer")
EndFunc

The better way to do it would probably make an Adlib function since you need to be able to pause it at any time.

Adlib function example follows:

Same code as before, except add the following. Adlibenable goes at the top, the function goes at the bottom.

AdlibEnable("_Paused",500)

Func _Paused()
   If $paused = 1 then
      Do
         Sleep(10)
      Until $paused = 0
   EndIf
EndFunc
Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0