LYK WHATS WRONG DUDE

Discussion in 'Code Snippets and Tutorials' started by Phee, May 5, 2009.

  1. Phee

    Phee Moderator
    Staff Member

    Joined:
    Aug 18, 2007
    Messages:
    6,206
    Likes Received:
    101
    Code (Text):
    1. program TopChop;
    2.  
    3. var
    4. x,y: Integer;
    5.  
    6.  
    7. begin
    8. if(FindColor(x,y,65400,0,0,470,200)) then
    9.  begin
    10.   SendKeys(' ');
    11.  end;
    12. repeat
    13. until(FindColor(x,y,26316,0,0,400,400));
    14. end.
    hmmmm?
     
  2. tharoux

    tharoux Level IV

    Joined:
    Dec 30, 2006
    Messages:
    2,733
    Likes Received:
    126
    Location:
    In front of my PC, Montreal
    Did some corrections
    Mainly, I doubt senkeys(' ') will work and you're not looping in the first part until the bar meet the green zone
    Try this.... it may not work right, I just wrote this based on yours and didn't tested it.

    Code (Text):
    1. program TopChop;
    2.  
    3. Var
    4. x,y: Integer;
    5.  
    6.  
    7. Begin
    8.   Repeat
    9.     Wait(100);
    10.   Until(FindColor(x,y,65400,0,0,470,200));
    11.   KeyDown(32);
    12.   Wait(100);
    13.   KeyUp(32);
    14.   Repeat
    15.     Wait(100);
    16.   Until(FindColor(x,y,26316,0,0,400,400));
    17. End.
     
  3. Phee

    Phee Moderator
    Staff Member

    Joined:
    Aug 18, 2007
    Messages:
    6,206
    Likes Received:
    101
    Doesn't the end; end the if statement and then it loops through? Sorry, I'm new to this.

    And yay it works! But what's this whole KeyDown, Wait, and KeyUp business? I get why Key Down is necessary, but why does it have to wait? Or is that how long it presses it for?

    Blah It also oftentimes goes when the bar is completely in the red, and other times it works perfectly. I tried changing the color but it still does it.

    Thanks youuu <3
     
  4. tharoux

    tharoux Level IV

    Joined:
    Dec 30, 2006
    Messages:
    2,733
    Likes Received:
    126
    Location:
    In front of my PC, Montreal
    The reason I put a wait between the 2 keys is because sometimes, it may happen to fast for the system to pickup. That's just from my experience tho. But I prefer not taking any chance ;) and don't forget the keyup. I once did and it happens to be in a loop and it was the "enter" key. Try to do something while someone press the key :arf:
    I'll take a look if I have time 2morrow and see why the script is working sporadicly.
     
  5. Royal

    Royal Level IV

    Joined:
    Jun 20, 2007
    Messages:
    907
    Likes Received:
    99
    Location:
    Virgnia
    Code (Text):
    1. program SlapChop;
    2.  
    3. var
    4. x,y: Integer;
    5.  
    6.  
    7. begin
    8. if(FindColor(x,y,65400,0,0,470,200)) then
    9. begin
    10.   SendKeys(' ');
    11. end;
    12. repeat
    13. until(FindColor(x,y,26316,0,0,400,400));
    14. end.
    Fixed.