Jump to content

converting V2 script to v3 script


Recommended Posts

Hi i just signed up for the forums. I have never used V3 Autoit, and was wondering how to translate the following script into V3 scripting:

WinActivate, SwgClient

Sleep, 5000

start:

IfWinExist,Run,,Exit

RightClick, 281, 308

Sleep, 1000

LeftClick, 393, 240

Sleep, 1000

IfWinExist,Run,,Exit

goto, start

if anyone can help me out, thanks in advance.

if anyone has any links to commands for v3 autoit that would be cool too.

This isn't a finished macro either.. here is what i am aiming for:

activate:

"if the run window exists, Goto, activate"

WinActivate, SwgClient

Sleep, 5000

start:

"if the run window exists, Goto, activate"

RightClick, 281, 308

Sleep, 1000

"if the run window exists, Goto, activate"

LeftClick, 393, 240

Sleep, 1000

goto, start

this is setup so that if the window IS active that it will basically pause itself, and when i close the window, it will basically restart and go back to macro.

Thank you all! :lmao:

Link to comment
Share on other sites

Read the AutoIt help file! http://www.autoitscript.com/autoit3/docs/

Of particular interest: http://www.autoitscript.com/autoit3/docs/intro/v264users.htm

If you ran the AutoIt3 installer, there should be a shortcut on your Start Menu. Also look for "v2 to v3 converter" in the Extras folder:

;   V2.64 to V3.0.100 (Version 1.0.6)
;   Converted with AutoItV2toV3 [Version 1.0.6]
;   (C) Copyright 2004 J-Paul Mesnage.

WinActivate ( 'SwgClient' )
Sleep ( 5000 )

while (1)   ; start : beginning of loop OR Func start ()
    if WinExists ( 'Run', '' ) then
        Exit 
    endif
    MouseClick( "right", 281, 308 )
    Sleep ( 1000 )
    MouseClick( "left", 393, 240 )
    Sleep ( 1000 )
    if WinExists ( 'Run', '' ) then
        Exit 
    endif
wend        ; start
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

ya that code you showed me is confusing... i want to add more functionality to the commands but don't know how to enter them...

if WinExists ( 'Run', '{What could go here?} ' ) then {What can go after this?}

while (1) ; start : beginning of loop OR Func start ()

and what does the above line mean in it's entirety???

i am a fast learner and fairly intelligent, but sometimes kinda hard headed :lmao:

so in this instance...... call me stupid o:)

Link to comment
Share on other sites

how exactly does the endif statement work? am i on the wrong page with this? is the Endif just like a closing tag for the if statement?

and like with my original post, i need to be able to pause the macro and then have it start from the absolute beginning

Edited by Beemer101
Link to comment
Share on other sites

how exactly does the endif statement work?  am i on the wrong page with this?  is the Endif just like a closing tag for the if statement?

and like with my original post, i need to be able to pause the macro and then have it start from the absolute beginning

<{POST_SNAPBACK}>

I don't know your computer programming skill. But the AutoIt language follow the current one as Visual basic, C, ... .

So your question show you have to read more book about programming.

I have not a good one as never be a good teacher.

Sorry for not helping more :lmao:

Link to comment
Share on other sites

its not to hard to learn when i first saw v3 i went "woah! its alot harder now" but then i saw some basic examples and tryed some stuff and it basicly just doesnt have goto, has ( ) around everything, and has more functions.

here is a if then elseif else statement that you can put functions into

If $thing1 = $thing2 Then
   Do somthing
Elseif $thing1 = $thing3 Then
   Do something else
Else
   Do what happens if nothing above happens
EndIf

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Link to comment
Share on other sites

ok i have been reading up some last night, and then reading the replies this morning.

Jpm- i kinda got used to V2 and i have never used basic. i am pretty fluent with HTML, some ASP, and very little PHP.

Xenogis- ok while reading what you wrote and the code, i tried to compute that. now my final question on the code you wrote is:

If $thing1 = $thing2 Then
   Do somthing
Elseif $thing1 = $thing3 Then
   Do something else
Else
   Do what happens if nothing above happens
EndIf

now "Do" is basically like the GOTO command only i'm guessing that you have to enter the paramater differently... can anyone give me an example on this?

basic diagram:

Part1:
If Winexist ( 'Run' ,, ,,) Then
     Do Part1
command1
command 2

Part2:
If Winexist ( 'Run' ,, ,,) Then
     Do Part1
command1
command2
command3
command4
If Winexist ( 'Run' ,, ,,) Then
     Do Part1
Do Part2

thank you for trying to help me, i will continue trying to learn more from the net, and probably burn out later today o:):lmao:

Link to comment
Share on other sites

i think i may have confused you, "Do" wasn't a function in what i wrote let me show you an example of a working if then else statement

$thing1 = InputBox ( "Thing1", "What is thing1?" )
If $thing1 = "A box" Then
   MsgBox ( "Thing1", "Thing1 triggered this message box" )
ElseIf $thing1 = "Somthing" Then
   InputBox ( "Thing1", "Thing1 triggered this input box" )
Else
   MsgBox ( "Thing1", "Thing1 triggered these message boxes" )
   MsgBox ( "Thing1", "Thing1 triggered these message boxes" )
EndIf

i hope that helps, and about what you wrote, that is still mostly v2 syntax, in v3 you would write that like this

If WinExists ( "Run" ) Then
   Part1()
   Part2()
EndIf

Func Part1()
   If WinExists ( "Run" ) Then
      command1()
      command2()
   EndIf
EndFunc

Func Part2()
   If WinExists ( "Run" ) Then
      command1()
      command2()
      command3()
      command4()
   EndIf
EndFunc

if you want more help feel free to ask

EDIT: here is your code in v3

WinActivate ( "SwgClient" )
Sleep ( "5000" )

If WinExists ( "Run" ) Then
   Start()
EndIf

Func Start()
   If WinExists ( "Run" ) Then
      MouseClick ( "right",  281, 308 )
      Sleep ( "1000" )
      MouseClick ( "left", 393, 240 )
      Sleep ( "1000" )
   EndIf
EndFunc

if you need help understanding i will gladly help you

Edited by Xenogis

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Link to comment
Share on other sites

its fine if you PM me, i will probably reply faster too because i get an email and a message pops up on my screen

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Link to comment
Share on other sites

Func Begin()
   If WinExists ( "Run" ) Then
    Begin()
   Else
    WinActivate ( "SwgClient" )
    Sleep ( "5000" )
   EndIf
   If Not WinExists ( "Run" ) Then
    Start()
EndFunc

Func Start()
   If WinExists ( "Run" ) Then
    Begin()
   Else
      MouseClick ( "right",  281, 308 )
      Sleep ( "1000" )
      MouseClick ( "left", 393, 240 )
      Sleep ( "1000" )
   EndIf
   If Not WinExists ( "Run" ) Then
    Start()
   EndIf
EndFunc

ok this is setup for Star Wars Galaxies (a full screen game), so when i want to pause it i am "supposed" to press the windows key + r to bring up the Run window, and basically pause the macro (while i leave the game and return to the desktop) and then when i am done i can close the Run window, and the SWG will automatically come back to Full screen, and the macro should go back to the mouse clicking.

If i am wrong or have unneeded code, please tell me.

Thanks yet again,

Beemer

(P.S. i am going to test the macro right now)

Link to comment
Share on other sites

i think that will work (btw good job and learning to use NOT in ifs and elses so fast that took me almost a year to learn)

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Link to comment
Share on other sites

thank you..... only there is one problem lol.... after fixing the macro a littler more (had to end all my If's lol) i tried to start the macro and nothing happened...

not sure why.... just nothing happens

any ideas?

the else's and if's, i had a little bit of xp with, when i was trying to learn php while my boss was designing a new web site.

Link to comment
Share on other sites

ok i fixed the macro and now it runs.....

apparently the macro can't start with the function line? but i think i understand that it can't execute a function without being told to ( gee i hope that sounds right lol)

now my problem is the mouse.... it moves slowly, i only need it to move instantly to the position and click, i think i have seen commands on how to fix this so i will go and try to search out the answer.

The following was placed at the beginning of the macro to make it operate:

If Not WinExists ( "Run" ) Then
Begin()
EndIf
Link to comment
Share on other sites

Can you post all of your code please?

"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.
Link to comment
Share on other sites

to make it move fast make the clicks like this

MouseClick ( "Left", X, Y, 1, 0 )

the 1 means it clicks once and the zero means it goes as fast as possible

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Link to comment
Share on other sites

ok as requested here is my code so far:

If WinExists ( "Run" ) Then
    Pause()
Else
    Begin()
EndIf

Func Begin()
       WinActivate ( "SwgClient" )
    Sleep ( "5000" )
   If Not WinExists ( "Run" ) Then
    Start()
   EndIf
EndFunc

Func Start()
   If WinExists ( "Run" ) Then
    Pause()
   Else
      MouseClick ( "right" , 281, 308 , 1 , 1 ) 
      Sleep ( "1200" )
      MouseClick ( "left" , 393, 245 , 1 , 1 ) 
      Sleep ( "1200" )
   EndIf
   Start()
EndFunc

Func Pause()
   Sleep ( "1200" )
   If WinExists ( "Run" ) Then
    Pause()
   Else
    Begin()
   EndIf
EndFunc

;MouseClick ( "right", 281, 308 )
;MouseClick ( "left", 393, 240 )

lol Xenogis i actually did find the commands for the mouse clicking and got it working, i was blind to it at first but then i went back and saw it.

thanks :lmao:

EDIT: My V3 script keeps overloading on the Start() function... the pauses aren't big enough? how big do they need to be? or can i just copy and paste the clicks, and pauses to make it longer???

Edited by Beemer101
Link to comment
Share on other sites

i've been looking at the code i can't figure that out, if i had the game i could do more for you.

EDIT: maybe you could add another sleep after the endif in the start() function

Edited by Xenogis

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Link to comment
Share on other sites

  • 1 year later...

I have made for starwars galaxies

Sleep(9000)

Send(3)

Sleep(1200)

MouseClick("right", 60, 80, 1, 1)

Sleep(500)

Send(2)

Sleep(1200)

MouseClick("right", 500, 500, 1, 1)

Sleep(2000)

MouseClick("left", 50, 55)

Sleep(110)

MouseClick("left", 50, 55)

Sleep(110)

MouseClick("left", 50, 55)

Sleep(110)

MouseClick("left", 50, 55)

Sleep(110)

MouseClick("left", 50, 55)

Sleep(110)

MouseClick("left", 50, 55)

Sleep(110)

MouseClick("left", 50, 55)

Sleep(110)

MouseClick("left", 50, 55)

Sleep(110)

MouseClick("left", 50, 55)

Sleep(500)

but the MouseClick("right/left"etc..) wont go threw half the time(as if the server isnt reading it) what am I doing wrong?

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...