Hi, little help please.

Discuss, ask for help, share ideas, give suggestions, read tutorials, and tell us about bugs you have found with MicroMacro in here.

Do not post RoM-Bot stuff here. There is a subforum for that.
Forum rules
This is a sub-forum for things specific to MicroMacro.

This is not the place to ask questions about the RoM bot, which uses MicroMacro. There is a difference.
Post Reply
Message
Author
so2easy
Posts: 34
Joined: Fri Jan 09, 2009 7:51 am

Hi, little help please.

#1 Post by so2easy » Mon Feb 08, 2010 2:27 am

Im trying to make a script that will auto-restart a certain program for me in some time interval.
Like 5hours.

Code: Select all

function main()

  while(1) do

  printf("Hello to auto-restart script.\n");
  printf("Press SPACE BAR to terminate script.\n");
  mouseSet(1310, 101);
  mouseLClick();
  mouseLClick();
  rest( 20000 );
  mouseSet(910, 46); 
  mouseLClick();
  rest( 2000 );
  mouseSet(1080, 130); 
  mouseLClick();
  rest( 2000 );
  mouseSet(264, 94);  
  mouseLClick();
  rest( 2000 );
  mouseSet(547, 318);  
  mouseLClick();
  rest( 2000 );
  mouseSet(1348, 10); 
  mouseLClick();
  rest( 2000 );
  mouseSet(872, 543);  
  mouseLClick();
  rest( 20000 );
   

    if( keyPressedLocal(key.VK_SPACE) ) then
      break;
    end
  end
 
  printf("Goodbye!\n");
 
end
 
 
-- startMacro will now call main() within a protected environment for us.
startMacro(main);
This is what ive done, what i can do atm.
Any better ideas, or mistakes i made?


Anyway i can make this run in background while im watching a movie or something? Will be awesome.

so2easy
Posts: 34
Joined: Fri Jan 09, 2009 7:51 am

Re: Hi, little help please.

#2 Post by so2easy » Tue Feb 09, 2010 12:12 pm

This is what im using atm.

Code: Select all

 local lastUpdateTime = 0;

while(true) do
  if( os.difftime(os.time(), lastUpdateTime) > 60*60*3 ) then
    lastUpdateTime = os.time();

  logMessage("");

  printf("Hello to auto-restart script.\n");
  printf("Press SPACE BAR to terminate script.\n");
  mouseSet(1310, 101);
  mouseLClick();
  mouseLClick();
  rest( 20000 );
  mouseSet(910, 46); 
  mouseLClick();
  rest( 2000 );
  mouseSet(1080, 130); 
  mouseLClick();
  rest( 2000 );
  mouseSet(264, 94); 
  mouseLClick();
  rest( 2000 );
  mouseSet(547, 318); 
  mouseLClick();
  rest( 2000 );
  mouseSet(1348, 10); 
  mouseLClick();
  rest( 2000 );
  mouseSet(872, 543);  
  mouseLClick();

     if( keyPressedLocal(key.VK_SPACE) ) then
      printf("Goodbye!\n");
        break;

    end
    
  end

  yrest(100); 

end
Trying to make it better with time.. currently am staring at the lua webpage trying to make it somehow attach to the program and when the process closes to start it.. not on timer.

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: Hi, little help please.

#3 Post by Administrator » Tue Feb 09, 2010 7:55 pm

so2easy wrote: Trying to make it better with time.. currently am staring at the lua webpage trying to make it somehow attach to the program and when the process closes to start it.. not on timer.
system().

Code: Select all

if( string.find(system('tasklist /fi "imagename eq whatever.exe" /NH'), "No tasks are running", true) ) then
  -- The program is not running. Do something.
end

so2easy
Posts: 34
Joined: Fri Jan 09, 2009 7:51 am

Re: Hi, little help please.

#4 Post by so2easy » Wed Feb 10, 2010 11:39 am

Code: Select all

scripts\tashakdve.lua:1: attempt to call global 'system' (a nil value)
This is probably some really stupid error but cant seem to fix it. :D

Code: Select all

if( string.find(system('tasklist /fi "Blablabla.exe" /NH'), "No tasks are running", true) ) then

  logMessage("");

while(true) do

  printf("Hello to auto-restart script.\n");
  printf("Press SPACE BAR to terminate script.\n");
  mouseSet(1310, 101);
  mouseLClick();
  mouseLClick();
  rest( 20000 );
  mouseSet(910, 46); 
  mouseLClick();
  rest( 2000 );
  mouseSet(1080, 130); 
  mouseLClick();
  rest( 2000 );
  mouseSet(264, 94);  
  mouseLClick();
  rest( 2000 );
  mouseSet(547, 318);  
  mouseLClick();
  rest( 2000 );
  mouseSet(1348, 10); 
  mouseLClick();
  rest( 2000 );
  mouseSet(872, 543);  
  mouseLClick();

     if( keyPressedLocal(key.VK_SPACE) ) then
       break;

    end
     printf("Goodbye!\n");
  end

  yrest(100); -- minimize CPU usage when not busy

end

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: Hi, little help please.

#5 Post by Administrator » Wed Feb 10, 2010 12:06 pm

You're using an outdated version of MicroMacro. Also, I made an error in the example I gave. You should just get rid of the 'true' from the string.find() call.

so2easy
Posts: 34
Joined: Fri Jan 09, 2009 7:51 am

Re: Hi, little help please.

#6 Post by so2easy » Wed Feb 10, 2010 7:59 pm

After update:

Code: Select all

ERROR: The search filter cannot be recognized.

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: Hi, little help please.

#7 Post by Administrator » Wed Feb 10, 2010 8:53 pm

You put:

Code: Select all

tasklist /fi "Blablabla.exe" /NH
There is a reason I formatted it the way I did in my example. You must have:

Code: Select all

tasklist /fi "imagename eq Blablabla.exe" /NH

so2easy
Posts: 34
Joined: Fri Jan 09, 2009 7:51 am

Re: Hi, little help please.

#8 Post by so2easy » Thu Feb 11, 2010 3:26 pm

Oh, i probably deleted it by mistake. Anyway fixed now.. but i think my syntax is wrong or i am missing to add something.

On stopped program - no process:
INFO: No tasks running with the specified criteria.
On runnign program - finds process and doesnt do anything.

Code: Select all

if( string.find(system('tasklist /fi "imagename eq Blablabla.exe" /NH'), "No tasks are running") ) then

  printf("Hello to auto-restart script.\n");
  printf("Press SPACE BAR to terminate script.\n");
  mouseSet(1310, 101);
  mouseLClick();
  mouseLClick();
  rest( 20000 );
  mouseSet(910, 46); 
  mouseLClick();
  rest( 2000 );
  mouseSet(1080, 130); 
  mouseLClick();
  rest( 2000 );
  mouseSet(264, 94);  
  mouseLClick();
  rest( 2000 );
  mouseSet(547, 318);  
  mouseLClick();
  rest( 2000 );
  mouseSet(1348, 10); 
  mouseLClick();
  rest( 2000 );
  mouseSet(872, 543);  
  mouseLClick();

    end

  yrest(100); -- minimize CPU usage when not busy

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: Hi, little help please.

#9 Post by Administrator » Thu Feb 11, 2010 5:15 pm

And why did you put that where you did? It's a simple check of whether or not the program is running, which is what you asked for. You put the code that you want to run when the program is/is not running inside there, not the whole script.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests