Sign in to follow this  
Followers 0
nyxx24

Running one auto it script within another

6 posts in this topic

Hey All,

What I want to know is can I run one autoit script within another, and if so what would I serach in the help file..

The script in question does several things within a while loop and when it gets to one point it repeats the same 15-20 different steps 3 times I am going to increase this to 9 times and I was wondering if I put those 15-20 steps in a seperate script could I have script one pause and run script #2 9 times then continue with the rest of script 1.

I don't think an array would help because the 15-20 steps are all different...

Why? to shorten the script instead of pasting the same thing 9 times.. so I can do it tht way but was looking for an easier neater way to do so..

So if so please point me in the right direction in the help file or other posts so I can try and figure it out :)

Thanks

Share this post


Link to post
Share on other sites



what about a function ?


Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Share this post


Link to post
Share on other sites

What you are probally actually looking for is a function. something like

Winexists("Something")
ThisisaFunc()
do something here
ThisisaFunc()

func ThisisaFunc()
do something here 2
endfunc

But to answer your question it is possible to run a script within a script, I usually use

ShellExecuteWait(@ProgramFilesDir&'\AutoIt3\Aut2Exe\Aut2exe.exe', ' /in C:\AutoIt_Scripts\Script.au3')

Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance.

Share this post


Link to post
Share on other sites

Ok,

I have posted the code below, the section I wish to repeat I have only shown one time.. between the long comment lines that look like this => ;QQQQQQQQQQQQQQQQQQQ

I want to repeat that multiple times in this case 9 times without having to make the code incredibly long. This is the section that I want to know if I can put it into a seperate file and then have it run however many times in this case 9 times then have this script continue to the end loop and do it all over again..

CODE

; Press Esc to terminate script, Pause/Break to "pause"

Global $Paused

HotKeySet("{PAUSE}", "TogglePause")

HotKeySet("{END}", "Terminate")

WinWait("***","")

If Not WinActive("***","") Then WinActivate("***","")

WinWaitActive("***","")

Dim $X = 0, $MouseClick[5][4]=[ _

[random (1073, 1075), random (264, 266), random (1102, 1104), random (274, 276)], _

[random (1073, 1075), random (283, 285), random (1102, 1104), random (293, 295)], _

[random (1073, 1075), random (302, 304), random (1102, 1104), random (312, 314)], _

[random (1073, 1075), random (321, 323), random (1102, 1104), random (331, 333)], _

[random (1073, 1075), random (340, 342), random (1102, 1104), random (350, 352)]]

While 1

If $X = 5 Then $X = 0

;Server downtime check

If @HOUR>=05 and @HOUR<=07 Then Exit

;Wait

Sleep(Random(2000,2500))

;UD

Send("{ALTDOWN}u{ALTUP}")

MouseClick("left",random (14, 16),random (1015, 1017),(1),(1))

Sleep(Random(400,500))

;UDW

Sleep(Random(23000,28000))

;LO

MouseClick("left",random(1381, 1383), random(118, 119),(1),(7))

Sleep(Random(400,500))

MouseClick("left",random(1411, 1413), random(125, 127),(1),(7))

Sleep(Random(400,500))

;BWTZ

MouseClick("right", $MouseClick[$X][0], $MouseClick[$X][1])

Sleep(Random(400,500))

MouseClick("left", $MouseClick[$X][2], $MouseClick[$X][3])

;WW

Sleep(Random(74000,75000))

;Pixel search if negative then proceed if negative then skip to leave

PixelSearch(1397, 216, 1397, 216, 0XBFBFBF, 100)

If @error Then

;AA

MouseClick("left",random(1480, 1482), random(174, 176),(1),(7))

Sleep(Random(100,200))

MouseClick("left",random(1385, 1387), random(86, 88),(1),(7))

Sleep(Random(100,200))

;AW

Sleep(Random(180000,185000))

;QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ

;TA1

MouseClick("left",random(1478, 1480), random(175, 177),(1),(7))

Sleep(Random(400,500))

MouseClick("left",random(1526, 1528), random(90, 92),(1),(7))

Sleep(Random(400,500))

;TA2

MouseClick("left",random(1478, 1480), random(193, 195),(1),(7))

Sleep(Random(400,500))

MouseClick("left",random(1526, 1528), random(90, 92),(1),(7))

Sleep(Random(400,500))

;TA3

MouseClick("left",random(1478, 1480), random(212, 214),(1),(7))

Sleep(Random(400,500))

MouseClick("left",random(1526, 1528), random(90, 92),(1),(7))

Sleep(Random(400,500))

;ATA

MouseClick("left",random(1383, 1385), random(88, 90),(1),(7))

Sleep(Random(400,500))

;AW

Sleep(Random(18000,19000))

;AM1

Send("{F1}")

Sleep(Random(400,500))

;SA2

MouseClick("left",random(1157, 1159), random(66, 68),(1),(7))

Sleep(Random(1500,2000))

;AM2

Send("{F2}")

Sleep(Random(400,500))

;SA3

MouseClick("left",random(1075, 1077), random(66, 68),(1),(7))

Sleep(Random(1500,2000))

;AM3

Send("{F3}")

Sleep(Random(400,500))

;MW1

Sleep(Random(61000,62000))

;U3

MouseClick("left",random(1526, 1528), random(90, 92),(1),(7))

Sleep(Random(400, 500))

;U2

MouseClick("left",random(1157, 1159), random(66, 68),(1),(7))

Sleep(Random(400, 500))

MouseClick("left",random(1526, 1528), random(90, 92),(1),(7))

Sleep(Random(400, 500))

;U1

MouseClick("left",random(1271, 1273), random(66, 68))

Sleep(Random(400, 500))

MouseClick("left",random(1526, 1528), random(90, 92),(1),(7))

Sleep(Random(400, 500))

;DAML

Send("{F1}")

Sleep(Random(400,500))

Send("{F2}")

Sleep(Random(400,500))

Send("{F3}")

Sleep(Random(400,500))

;Pause

Sleep(Random(400, 500))

;DAIML

MouseClick("right",random(481, 483), random(133, 135))

Sleep(Random(400, 500))

MouseClick("right",random(581, 583), random(133, 135))

Sleep(Random(400, 500))

;QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ

;BOB

MouseClick("right", $MouseClick[$X][0], $MouseClick[$X][1])

Sleep(Random(400,500))

MouseClick("left", $MouseClick[$X][2], $MouseClick[$X][3])

;W

Sleep(Random(15000,16000))

;SWTD

MouseClick("right",random(1073, 1075), random(589, 591),(1),(7))

Sleep(Random(400,500))

MouseClick("left",random(1102, 1104), random(631, 633),(1),(7))

Sleep(Random(400,500))

;WW

Sleep(Random(74000,75000))

;RD

MouseClick("right",random(1073, 1075), random(589, 591),(1),(7))

Sleep(Random(400,500))

MouseClick("left",random(1102, 1104), random(617, 619),(1),(7))

Sleep(Random(400,500))

;DW

Sleep(Random(25000,30000))

;SA

MouseMove(random(1334, 1336), random(907, 909), 7)

Sleep(Random(400,500))

MouseDown("right")

MouseUp("right")

MouseMove(random(1364, 1366), random(917, 919), 7)

Sleep(Random(400,500))

MouseDown("left")

MouseUp("left")

;DL

MouseMove(random(1062, 1064), random(747, 749), 7)

Sleep(Random(400,500))

MouseDown("left")

MouseMove(random(343, 345), random(392, 394), 7)

Sleep(Random(400,500))

MouseUp("left")

;W

Sleep(Random(400,500))

;DL2

MouseMove(random(1136, 1138), random(747, 749), 7)

Sleep(Random(400,500))

MouseDown("left")

MouseMove(random(343, 345), random(392, 394), 7)

Sleep(Random(400,500))

MouseUp("left")

Else

EndIf

Sleep(Random(400,500))

;===End

$X += 1

WEnd

Func TogglePause()

$Paused = NOT $Paused

While $Paused

sleep(100)

ToolTip('Script is "Paused"',(1),(4),(1),(7))

WEnd

ToolTip("")

EndFunc

Func Terminate()

Exit 0

EndFunc

Share this post


Link to post
Share on other sites

Something like this.

You can change the func name if you wish...

; Press Esc to terminate script, Pause/Break to "pause"
Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{END}", "Terminate")

WinWait("***","")
If Not WinActive("***","") Then WinActivate("***","")
WinWaitActive("***","")

Dim $X = 0, $MouseClick[5][4]=[ _
[random (1073, 1075), random (264, 266), random (1102, 1104), random (274, 276)], _
[random (1073, 1075), random (283, 285), random (1102, 1104), random (293, 295)], _
[random (1073, 1075), random (302, 304), random (1102, 1104), random (312, 314)], _
[random (1073, 1075), random (321, 323), random (1102, 1104), random (331, 333)], _
[random (1073, 1075), random (340, 342), random (1102, 1104), random (350, 352)]]

While 1
If $X = 5 Then $X = 0

;Server downtime check
If @HOUR>=05 and @HOUR<=07 Then Exit

;Wait
Sleep(Random(2000,2500))

;UD
Send("{ALTDOWN}u{ALTUP}")
MouseClick("left",random (14, 16),random (1015, 1017),(1),(1))
Sleep(Random(400,500))

;UDW
Sleep(Random(23000,28000))

;LO
MouseClick("left",random(1381, 1383), random(118, 119),(1),(7))
Sleep(Random(400,500))
MouseClick("left",random(1411, 1413), random(125, 127),(1),(7))
Sleep(Random(400,500))

;BWTZ
MouseClick("right", $MouseClick[$X][0], $MouseClick[$X][1])
Sleep(Random(400,500))
MouseClick("left", $MouseClick[$X][2], $MouseClick[$X][3])

;WW
Sleep(Random(74000,75000))

;Pixel search if negative then proceed if negative then skip to leave
PixelSearch(1397, 216, 1397, 216, 0XBFBFBF, 100)
If @error Then

;AA
MouseClick("left",random(1480, 1482), random(174, 176),(1),(7))
Sleep(Random(100,200))
MouseClick("left",random(1385, 1387), random(86, 88),(1),(7))
Sleep(Random(100,200))

;AW
Sleep(Random(180000,185000))

   ;QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ
For $icc = 1 To 9
    RandomMoves()
Next



;BOB
MouseClick("right", $MouseClick[$X][0], $MouseClick[$X][1])
Sleep(Random(400,500))
MouseClick("left", $MouseClick[$X][2], $MouseClick[$X][3])

;W
Sleep(Random(15000,16000))

;SWTD
MouseClick("right",random(1073, 1075), random(589, 591),(1),(7))
Sleep(Random(400,500))
MouseClick("left",random(1102, 1104), random(631, 633),(1),(7))
Sleep(Random(400,500))

;WW
Sleep(Random(74000,75000))

;RD
MouseClick("right",random(1073, 1075), random(589, 591),(1),(7))
Sleep(Random(400,500))
MouseClick("left",random(1102, 1104), random(617, 619),(1),(7))
Sleep(Random(400,500))

;DW
Sleep(Random(25000,30000))

;SA
MouseMove(random(1334, 1336), random(907, 909), 7)
Sleep(Random(400,500))
MouseDown("right")
MouseUp("right")
MouseMove(random(1364, 1366), random(917, 919), 7)
Sleep(Random(400,500))
MouseDown("left")
MouseUp("left")

;DL
MouseMove(random(1062, 1064), random(747, 749), 7)
Sleep(Random(400,500))
MouseDown("left")
MouseMove(random(343, 345), random(392, 394), 7)
Sleep(Random(400,500))
MouseUp("left")

;W
Sleep(Random(400,500))

;DL2
MouseMove(random(1136, 1138), random(747, 749), 7)
Sleep(Random(400,500))
MouseDown("left")
MouseMove(random(343, 345), random(392, 394), 7)
Sleep(Random(400,500))
MouseUp("left")

Else
EndIf

Sleep(Random(400,500))

;===End

$X += 1
WEnd

Func TogglePause()
$Paused = NOT $Paused
While $Paused
sleep(100)
ToolTip('Script is "Paused"',(1),(4),(1),(7))
WEnd
ToolTip("")
EndFunc

Func Terminate()
Exit 0
EndFunc


Func RandomMoves()
   ;QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ

;TA1
MouseClick("left",random(1478, 1480), random(175, 177),(1),(7))
Sleep(Random(400,500))
MouseClick("left",random(1526, 1528), random(90, 92),(1),(7))
Sleep(Random(400,500))

;TA2
MouseClick("left",random(1478, 1480), random(193, 195),(1),(7))
Sleep(Random(400,500))
MouseClick("left",random(1526, 1528), random(90, 92),(1),(7))
Sleep(Random(400,500))

;TA3
MouseClick("left",random(1478, 1480), random(212, 214),(1),(7))
Sleep(Random(400,500))
MouseClick("left",random(1526, 1528), random(90, 92),(1),(7))
Sleep(Random(400,500))

;ATA
MouseClick("left",random(1383, 1385), random(88, 90),(1),(7))
Sleep(Random(400,500))

;AW
Sleep(Random(18000,19000))

;AM1
Send("{F1}")
Sleep(Random(400,500))

;SA2
MouseClick("left",random(1157, 1159), random(66, 68),(1),(7))
Sleep(Random(1500,2000))

;AM2
Send("{F2}")
Sleep(Random(400,500))

;SA3
MouseClick("left",random(1075, 1077), random(66, 68),(1),(7))
Sleep(Random(1500,2000))

;AM3
Send("{F3}")
Sleep(Random(400,500))

;MW1
Sleep(Random(61000,62000))

;U3
MouseClick("left",random(1526, 1528), random(90, 92),(1),(7))
Sleep(Random(400, 500))

;U2
MouseClick("left",random(1157, 1159), random(66, 68),(1),(7))
Sleep(Random(400, 500))
MouseClick("left",random(1526, 1528), random(90, 92),(1),(7))
Sleep(Random(400, 500))

;U1
MouseClick("left",random(1271, 1273), random(66, 68))
Sleep(Random(400, 500))
MouseClick("left",random(1526, 1528), random(90, 92),(1),(7))
Sleep(Random(400, 500))

;DAML
Send("{F1}")
Sleep(Random(400,500))
Send("{F2}")
Sleep(Random(400,500))
Send("{F3}")
Sleep(Random(400,500))

;Pause
Sleep(Random(400, 500))

;DAIML
MouseClick("right",random(481, 483), random(133, 135))
Sleep(Random(400, 500))
MouseClick("right",random(581, 583), random(133, 135))
Sleep(Random(400, 500))
EndFunc

Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance.

Share this post


Link to post
Share on other sites

Found it by search

After the first ;QQQQQQQQQQQQQ

Added

$i = 0

While $i < 9 ; 9 is the number of loops

;main script body

Before the last ;QQQQQQQQQQQQ

Added

$i = $i + 1

WEnd ; end loop

And it seems to be working :)

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