Jump to content

Recommended Posts

Posted

Okay so just delete the WEnd command, and it all looks good?

I don't know about the rest of your code, but it looks like you have enabled the AdLib every 50 minutes, and created valid code to run for that function. The best thing is to ask for advice on the method to do something here and try it yourself. You actually learn a lot more by trying something instead of having others debug your code. Not to sound rude (because that's not my intended tone), but a few of the errors I've corrected for you the built-in debugger would have mentioned.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

  • Replies 80
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted

I don't know about the rest of your code, but it looks like you have enabled the AdLib every 50 minutes, and created valid code to run for that function. The best thing is to ask for advice on the method to do something here and try it yourself. You actually learn a lot more by trying something instead of having others debug your code. Not to sound rude (because that's not my intended tone), but a few of the errors I've corrected for you the built-in debugger would have mentioned.

No I understand. Thanks a lot for taking the time to help me out. One more question you said a built-in debugger. Where is that located? I don't see any debugger in my files.

Thanks a lot!

Posted

One more question you said a built-in debugger. Where is that located? I don't see any debugger in my files.

I mean if you try and run code with errors in it, you'll get a message at the first error AutoIt encounters that causes the script to stop running. For example, try putting the following line into an au3 file, and running it (see below). You'll get a nice little message telling you on what line the problem is, and the nature of the problem. It catches a lot of silly mistakes.

;example of bad code AutoIt will report:
WEnd

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Posted

I mean if you try and run code with errors in it, you'll get a message at the first error AutoIt encounters that causes the script to stop running. For example, try putting the following line into an au3 file, and running it (see below). You'll get a nice little message telling you on what line the problem is, and the nature of the problem. It catches a lot of silly mistakes.

CODE 

;example of bad code AutoIt will report:

WEnd

Okay I understand now, Thanks a lot. I'm gonna get to bed, and check out the script tommrow and tell you how it works.

Once again, Thanks a lot!

Posted (edited)

Good luck with the rest of it. And remember: learning a new programming language isn't usually easy, but the best thing you can do is try some code out and see what it does. Some simple tips that may make learning about new functions you read in the manual eaisier:

  • Don't try out new functions in a large project. Create a very simple "test" program to see how the functions work. Keep it simiple, and have it tell you what parts of the program you are about to run. You can eaisily spot errors this way, and adjust your test code so you better understand the function.
  • Practice understanding error message. Some of them will not make sense, so often if you "break" some working (and simple!) code, you can learn what kinds of error messages you may get for various problems.
  • Of course, becomming familiar with the power of the lanauge is important. Try reading about new commands and creating small functions to make them work. Keep it simple until you understand how to use them.
Edited to fix my BB Code sytax Edited by pekster

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Posted

Thanks for the tips pek! I have a problem with the script though (I think I can fix it). I need it to pause (After fifty minutes). Wait sixty seconds and then do the My_AdLib_Function() (With the /logout and such.) If I have any questions I'll ask.

Okay and I have another question. Is it possible to have multiple My_AdLib_Function() in your script? Like one logging out every 50 minutes and another doing something else every 30 minutes?

Thanks

Posted

Okay I looked around and I can't find anything about this. I need a command to pause the whole script (automatically, after every 50 minutes). Then sleep for 60 seconds. Then do to My_AdLib_Function() and continue normally.

Is this possible? Would I need another My_AdLib_Function()?

Thanks

Posted

As far as I know, you can only have one active adlib function. You use adlibDisable and adlibEnable to swith to a different function....

To pause after every 50 minutes, look at TimerStop in the help file:

Global $startTime = TimerStart()
AdlibEnable(myAdlib", 60000);run every minute

;sample body of script
While 1
sleep(100)
WEnd

Func myAdlib()
   If TimerStop($startTime) > (50 * 60 * 1000); 50min x 60sec/min x 1000millisecs/sec
      sleep(60000);pause 60 seconds
      $startTimer = TimerStart()
   EndIf
EndFunc
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Posted

Is it possible to have multiple My_AdLib_Function() in your script? Like one logging out every 50 minutes and another doing something else every 30 minutes?

Why not create 2 timers and test for them both in your AdLib function? This is a short example template I designed to illustrate my point:

;code at the beginning of your script

$Timer30Minutes = TimerStart()
$Timer50Minutes = TimerStart()
AdLibEnable("timers", 500);call the timers function to check for various times

;other code here, to do stuff outside of your AdLib functions

Func timers()
  If TimerStop($Timer30Minutes) > 30 * 60 * 1000 Then
   ;do 30 minute stuff
    $Timer30Minutes = TimerStart()
  EndIf
  If TimerStop($Timer50Minutes)> 50 * 60 * 1000 Then
   ;do 50 minute stuff
    $Timer50Minutes = TimerStart()
  EndIf
EndFunc

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Posted

Okay, Thank you both! I have been working on this and testing for about four hours and I still can't get anywhere :/.

Here is what I have:

$Timer50Minutes = TimerStart()
AdLibEnable("timers", 500);call the timers function to check for various times

Sleep(100000);give time to open FFXI 
$fisha = 2; 
$event = 0; 
$bite = 0; 
$failsafe=0; 
$nobait = 0; 
WinWaitActive("FFXiApp");

While $fisha > 1 
AutoItSetOption("SendKeyDelay", 40); 
Send ("!1"); fishing macro 
$event = 0; 
$failsafe = 0; 
$nobait = 0; 

Do 
Sleep(250); 

If PixelGetColor(22,994) = 16777215 AND PixelGetColor(108,996) = 16777215 AND PixelGetColor(228,997) = 16777215 Then 
AutoItSetOption("SendKeyDelay", 40); 
Sleep(Random(3000,3200)); 
Send("{ENTER}"); 
Sleep(5400); 
EndIf 

If PixelGetColor(43,997) = 16777215 AND PixelGetColor(83,998) = 16777215 AND PixelGetColor(175,999) = 16777215 Then 
Sleep(Random(5100,5400));You lost your catch. Finish and speed things up a little. 
$event = 1; 
EndIf 

If PixelGetColor(37,1000) = 16777215 AND PixelGetColor(77,1000) = 16777215 AND PixelGetColor(180,998) = 16777215 Then 
Sleep(Random(5100,5400));You didn't catch anything. Finish and speed things up a little. 
$event = 1; 
EndIf 

If PixelGetColor(47,1000) = 16777215 AND PixelGetColor(142,999) = 16777215 AND PixelGetColor(330,997) = 16777215 Then 
$nobait = 1;You ran out of bait so let's get ready to change it. 
EndIf 

If PixelGetColor(43,995) = 16777215 AND PixelGetColor(71,997) = 16777215 AND PixelGetColor(84,995) = 16777215 Then 
autosort() 
Sleep(Random(2100,2200)); 
$event = 1;You caught something so now autosort, sleep a bit, and finish the event. 
EndIf 


$failsafe = $failsafe+1; 
If $failsafe = 175 Then 
$event = 1; 
EndIf 

Until $event = 1 

sleep(2000); 

If $nobait = 1 Then 
Send("!2");change bait 
EndIf 

WEnd 

Func autosort() 
Sleep(9000); 
AutoItSetOption("SendKeyDelay", 0235); 
AutoItSetOption("SendKeyDownDelay", 0100); 
Send ("!i"); 
Sleep(0250); 
Send ("{NUMPADADD}"); 
Sleep (0250); 
Send ("{ENTER}"); 
sleep(0350); 
Send ("{UP}"); 
sleep(0350); 
Send ("{ENTER}"); 
sleep(0250); 
Send ("{ESCAPE}"); 
sleep(0250); 
Send ("{ESCAPE}"); 
Sleep (0250);

EndFunc

Func timers()
If TimerStop($Timer50Minutes)> 50 * 60 * 1000 Then
 Send("/logout")
 Send("{ENTER}")
 Sleep(35000);wait 35 seconds before continuing
 Send("{ENTER}");
 Sleep(7000);wait 7 seconds
 Send("{ENTER}");
 Sleep(7000);wait 7 seconds
 Send("{ENTER}");
 Sleep(7000);wait 7 seconds
 Send("{ENTER}");
 Sleep(3000 * 1000);wait 50 minutes and then do it all again
  $Timer50Minutes = TimerStart()
 EndIf

EndFunc

Okay here is what I am doing in the game. I am fishing, and while the pole is in the water if it does this command:

/logout

It will not work, so then it will have to loop for another 50 minutes and hope the pole is not in the water for it to work. I am trying to make it so it still does the command where it would logout and such, but when it activates the command I want it to do the following:

1. Shut the code off for awhile, everything but the part that logs me out. (Then when the pole is out of the water, it will not put it in automatically again.)

2. Wait 30 seconds before doing the /logout etc. commands. (To give it time for the pole to get out of the water.)

3. Do the /logout etc. command.

4. Resume all back to normal and it will start over again.

Is this possible to do? I worked on it for while now, and I am still confused about what to do.

Thanks

Posted (edited)

1. Shut the code off for awhile, everything but the part that logs me out. (Then when the pole is out of the water, it will not put it in automatically again.)

2. Wait 30 seconds before doing the /logout etc. commands. (To give it time for the pole to get out of the water.)

3. Do the /logout etc. command.

4. Resume all back to normal and it will start over again.

If you want to disable the AdLib section, use the line AdLibDisable() which will stop the AdLib function from checking the timer. Then, when you wish to start that code sequence again (the 50 minute timer part) re-enable the AdLib how you did it the first time. If you do this, you may want to set the timer over again with $Timer50Minutes = TimerStart() so that it waits 50 minutes as opposed to 50 minutes minus however much was already taken off the 50 minute period.

If you don't need to run other code, just use the Sleep() function to sleep for 30 seconds (or 30 * 1000 ms.) If you do want to run other code durring this time, you can create an AdLib for that code, or use an infinate loop to do your code durring this time, and then exit if the timer value is greater than 30 seconds past when you started it. See the example below.

If it works now, you should just be able to basically copy and paste the commands you wish to use for this part.

If you mean to re-enable your original AdLib function, do so at this point. See also #1 where I mentioned resetting the timer so you get the full 50 minutes.Example for #2:

$Timer30Seconds = TimerStart()
While 1
;some stuff you need to do while you wait for 30 seconds goes here
  Sleep(100);prevent maxing out the CPU

;exit the loop if we have been in it for more than 30 seconds:
  If TimerStop($Timer30Seconds) > 30 * 1000 Then ExitLoop
WEnd

Edit:I forgot to include a Sleep command inside of the While loop. Please make this a habbit to prevent maxing out your CPU while you wait for time to expire. Running code as fast as the CPU can is usually a bad idea inside of an infinate loop.

Edited by pekster

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Posted

Okay I tested it out.

The good:

1. It now will logout right. It disables the rest of the script and logs out.

The bad:

1. When it is logged back in it doesn't "restart" the script. I even put that commad in.

I don't see why it isn't working. Any ideas?

NOTE!: I changed the Sleep to only 110 seconds for testing purposes.

$Timer50Minutes = TimerStart()
AdLibEnable("timers", 500);call the timers function to check for various times

Sleep(60000);give time to open FFXI 
$fisha = 2; 
$event = 0; 
$bite = 0; 
$failsafe=0; 
$nobait = 0; 
WinWaitActive("FFXiApp");

While $fisha > 1 
AutoItSetOption("SendKeyDelay", 40); 
Send ("!1"); fishing macro 
$event = 0; 
$failsafe = 0; 
$nobait = 0; 

Do 
Sleep(250); 

If PixelGetColor(22,994) = 16777215 AND PixelGetColor(108,996) = 16777215 AND PixelGetColor(228,997) = 16777215 Then 
AutoItSetOption("SendKeyDelay", 40); 
Sleep(Random(3000,3200)); 
Send("{ENTER}"); 
Sleep(5400); 
EndIf 

If PixelGetColor(43,997) = 16777215 AND PixelGetColor(83,998) = 16777215 AND PixelGetColor(175,999) = 16777215 Then 
Sleep(Random(5100,5400));You lost your catch. Finish and speed things up a little. 
$event = 1; 
EndIf 

If PixelGetColor(37,1000) = 16777215 AND PixelGetColor(77,1000) = 16777215 AND PixelGetColor(180,998) = 16777215 Then 
Sleep(Random(5100,5400));You didn't catch anything. Finish and speed things up a little. 
$event = 1; 
EndIf 

If PixelGetColor(47,1000) = 16777215 AND PixelGetColor(142,999) = 16777215 AND PixelGetColor(330,997) = 16777215 Then 
$nobait = 1;You ran out of bait so let's get ready to change it. 
EndIf 

If PixelGetColor(43,995) = 16777215 AND PixelGetColor(71,997) = 16777215 AND PixelGetColor(84,995) = 16777215 Then 
autosort() 
Sleep(Random(2100,2200)); 
$event = 1;You caught something so now autosort, sleep a bit, and finish the event. 
EndIf 


$failsafe = $failsafe+1; 
If $failsafe = 175 Then 
$event = 1; 
EndIf 

Until $event = 1 

sleep(2000); 

If $nobait = 1 Then 
Send("!2");change bait 
EndIf 

WEnd 

Func autosort() 
Sleep(9000); 
AutoItSetOption("SendKeyDelay", 0235); 
AutoItSetOption("SendKeyDownDelay", 0100); 
Send ("!i"); 
Sleep(0250); 
Send ("{NUMPADADD}"); 
Sleep (0250); 
Send ("{ENTER}"); 
sleep(0350); 
Send ("{UP}"); 
sleep(0350); 
Send ("{ENTER}"); 
sleep(0250); 
Send ("{ESCAPE}"); 
sleep(0250); 
Send ("{ESCAPE}"); 
Sleep (0250);

EndFunc

Func timers()
If TimerStop($Timer50Minutes)> 110000 Then
AdLibDisable()
 Sleep(30000);wait 30 seconds for rod to reel in
 Send("/logout")
 Send("{ENTER}")
 Sleep(35000);wait 35 seconds before continuing
 Send("{ENTER}");
 Sleep(7000);wait 7 seconds
 Send("{ENTER}");
 Sleep(7000);wait 7 seconds
 Send("{ENTER}");
 Sleep(7000);wait 7 seconds
 Send("{ENTER}");
 Sleep(3000 * 1000);wait 50 minutes and then do it all again
  $Timer50Minutes = TimerStart()
 Adlibenable()
 EndIf

EndFunc
Posted

Okay i keep getting an error..I have this:

$Timer50Minutes = TimerStart()
AdLibEnable("timers", 500);call the timers function to check for various times

Sleep(60000);give time to open FFXI

$fisha = 2; 
$event = 0; 
$bite = 0; 
$failsafe=0; 
$nobait = 0; 
WinWaitActive("FFXiApp");

While $fisha > 1 
AutoItSetOption("SendKeyDelay", 40); 
Send ("!1"); fishing macro 
$event = 0; 
$failsafe = 0; 
$nobait = 0; 

Do 
Sleep(250); 

If PixelGetColor(22,994) = 16777215 AND PixelGetColor(108,996) = 16777215 AND PixelGetColor(228,997) = 16777215 Then 
AutoItSetOption("SendKeyDelay", 40); 
Sleep(Random(3000,3200)); 
Send("{ENTER}"); 
Sleep(5400); 
EndIf 

If PixelGetColor(43,997) = 16777215 AND PixelGetColor(83,998) = 16777215 AND PixelGetColor(175,999) = 16777215 Then 
Sleep(Random(5100,5400));You lost your catch. Finish and speed things up a little. 
$event = 1; 
EndIf 

If PixelGetColor(37,1000) = 16777215 AND PixelGetColor(77,1000) = 16777215 AND PixelGetColor(180,998) = 16777215 Then 
Sleep(Random(5100,5400));You didn't catch anything. Finish and speed things up a little. 
$event = 1; 
EndIf 

If PixelGetColor(47,1000) = 16777215 AND PixelGetColor(142,999) = 16777215 AND PixelGetColor(330,997) = 16777215 Then 
$nobait = 1;You ran out of bait so let's get ready to change it. 
EndIf 

If PixelGetColor(43,995) = 16777215 AND PixelGetColor(71,997) = 16777215 AND PixelGetColor(84,995) = 16777215 Then 
autosort() 
Sleep(Random(2100,2200)); 
$event = 1;You caught something so now autosort, sleep a bit, and finish the event. 
EndIf 


$failsafe = $failsafe+1; 
If $failsafe = 175 Then 
$event = 1; 
EndIf 

Until $event = 1 

sleep(2000); 

If $nobait = 1 Then 
Send("!2");change bait 
EndIf 

WEnd 

Func autosort() 
Sleep(9000); 
AutoItSetOption("SendKeyDelay", 0235); 
AutoItSetOption("SendKeyDownDelay", 0100); 
Send ("!i"); 
Sleep(0250); 
Send ("{NUMPADADD}"); 
Sleep (0250); 
Send ("{ENTER}"); 
sleep(0350); 
Send ("{UP}"); 
sleep(0350); 
Send ("{ENTER}"); 
sleep(0250); 
Send ("{ESCAPE}"); 
sleep(0250); 
Send ("{ESCAPE}"); 
Sleep (0250);

EndFunc

Func timers()
If TimerStop($Timer50Minutes)> 110000 Then
AdLibDisable()
 Sleep(30000);wait 30 seconds for rod to reel in
 Send("/logout")
 Send("{ENTER}")
 Sleep(35000);wait 35 seconds before continuing
 Send("{ENTER}");
 Sleep(7000);wait 7 seconds
 Send("{ENTER}");
 Sleep(7000);wait 7 seconds
 Send("{ENTER}");
 Sleep(7000);wait 7 seconds
 Send("{ENTER}");
  Sleep(20000);wait 20 seconds and then start script again
  Adlibenable()
  Sleep(1000 * 3000); Wait 50 minutes and start over again
  $Timer50Minutes = TimerStart()
  EndIf

EndFunc

The error message is:

Line 109

Adlibenable ()

^ ERROR

Error: Incorrect number of parameters in function call.

Any idea on what is wrong, I am puzzled.

Thank you.

Posted

Okay, now it doesn't give me the error code anymore, but it still won't resume the script again?

Here is what I have:

$Timer50Minutes = TimerStart()
AdLibEnable("timers", 500);call the timers function to check for various times

Sleep(60000);give time to open FFXI

$fisha = 2; 
$event = 0; 
$bite = 0; 
$failsafe=0; 
$nobait = 0; 
WinWaitActive("FFXiApp");

While $fisha > 1 
AutoItSetOption("SendKeyDelay", 40); 
Send ("!1"); fishing macro 
$event = 0; 
$failsafe = 0; 
$nobait = 0; 

Do 
Sleep(250); 

If PixelGetColor(22,994) = 16777215 AND PixelGetColor(108,996) = 16777215 AND PixelGetColor(228,997) = 16777215 Then 
AutoItSetOption("SendKeyDelay", 40); 
Sleep(Random(3000,3200)); 
Send("{ENTER}"); 
Sleep(5400); 
EndIf 

If PixelGetColor(43,997) = 16777215 AND PixelGetColor(83,998) = 16777215 AND PixelGetColor(175,999) = 16777215 Then 
Sleep(Random(5100,5400));You lost your catch. Finish and speed things up a little. 
$event = 1; 
EndIf 

If PixelGetColor(37,1000) = 16777215 AND PixelGetColor(77,1000) = 16777215 AND PixelGetColor(180,998) = 16777215 Then 
Sleep(Random(5100,5400));You didn't catch anything. Finish and speed things up a little. 
$event = 1; 
EndIf 

If PixelGetColor(47,1000) = 16777215 AND PixelGetColor(142,999) = 16777215 AND PixelGetColor(330,997) = 16777215 Then 
$nobait = 1;You ran out of bait so let's get ready to change it. 
EndIf 

If PixelGetColor(43,995) = 16777215 AND PixelGetColor(71,997) = 16777215 AND PixelGetColor(84,995) = 16777215 Then 
autosort() 
Sleep(Random(2100,2200)); 
$event = 1;You caught something so now autosort, sleep a bit, and finish the event. 
EndIf 


$failsafe = $failsafe+1; 
If $failsafe = 175 Then 
$event = 1; 
EndIf 

Until $event = 1 

sleep(2000); 

If $nobait = 1 Then 
Send("!2");change bait 
EndIf 

WEnd 

Func autosort() 
Sleep(9000); 
AutoItSetOption("SendKeyDelay", 0235); 
AutoItSetOption("SendKeyDownDelay", 0100); 
Send ("!i"); 
Sleep(0250); 
Send ("{NUMPADADD}"); 
Sleep (0250); 
Send ("{ENTER}"); 
sleep(0350); 
Send ("{UP}"); 
sleep(0350); 
Send ("{ENTER}"); 
sleep(0250); 
Send ("{ESCAPE}"); 
sleep(0250); 
Send ("{ESCAPE}"); 
Sleep (0250);

EndFunc

Func timers()
If TimerStop($Timer50Minutes)> 110000 Then
AdLibDisable()
 Sleep(30000);wait 30 seconds for rod to reel in
 Send("/logout")
 Send("{ENTER}")
 Sleep(35000);wait 35 seconds before continuing
 Send("{ENTER}");
 Sleep(7000);wait 7 seconds
 Send("{ENTER}");
 Sleep(7000);wait 7 seconds
 Send("{ENTER}");
 Sleep(7000);wait 7 seconds
 Send("{ENTER}");
  Sleep(20000);wait 20 seconds and then start script again
  Adlibenable("timers", 500)
  Sleep(1000 * 3000); Wait 50 minutes and start over again
  $Timer50Minutes = TimerStart()
  EndIf

EndFunc

I was wondering what does the ("timers", 500) do in Adlibenable? What does it mean?

Posted

I was wondering what does the ("timers", 500) do in Adlibenable? What does it mean?

That tells the program to enable running the "timers" function every 500 milliseconds (or half a second.) It will pause the main body of your script at this time, and run the AdLib code. Once that is done, it will resume execution right where it left off.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Posted

Here is what I have:

...

Why are you using AdLibDisable() and AdLibEnable() inside your timers function? The only way to get to that function is through the AdLib, so you should never call these from inside of it. Also, I would guess that your script appears to hang because the SLeep(1000 * 3000) command is used inside the timers function. That basically will cause the script to stop for 50 minutes (and do nothing else) at the end of the timers function when the Timer50Minutes is larger than 50 minutes. I don't think this is what you want.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

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
×
×
  • Create New...