Results 1 to 7 of 7

Thread: If(IsKeyDown)Then + Repeat

  1. #1
    Join Date
    Jan 2007
    Location
    the middle of know-where
    Posts
    1,308
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default If(IsKeyDown)Then + Repeat

    Alright, I am trying to make a script fix/improve a script that a few people are working on... but I got a little stumped and need some help. I have searched the tuts and cannot seem to find what I am looking for. This is something along the lines of what I have and need.

    I started out with:
    SCAR Code:
    if(IsFKeyDown(5))then
      begin
       x:=0;
        AddToReport('mytext');
         x:=x+1;
      end;

    Well.. I ran into the problem of 'F' keys being used... So I wanted to switch off to using control+number commands as to fix the problem of actually inserting a number into the field when I click a number... This is what I have:

    SCAR Code:
    if(IsKeyDown(Chr(49)))then
      begin
       x:=0;
        AddToReport('mytext');
         x:=x+1;
      end;

    ... but I need it to be something along the lines of:

    SCAR Code:
    if(IsKeyDown("control"+Chr(49)))then
      begin
       x:=0;
        AddToReport('mytext');
         x:=x+1;
      end;

    My second problem came at the end of the script. I am needing the script to wait for my next command before it continues. Well, I will post the short version of what I am trying. I have been getting frustrated and now changed what I have tried to this:

    SCAR Code:
    Procedure procedurex;
    Begin
     if(IsKeyDown(Chr(49)))then
      begin
       x:=0;
        AddToReport('mytext');
         x:=x+1;
      end;

     if(IsKeyDown(Chr(50)))then
      begin
      x:=0;
       AddToReport ('mytext2');
        x:=x+1;
      end;

    Procedure thisone;
    begin
     repeat
       procedurex;
     until(x>0);
    end;

    Begin
    SetupSRL;
      thisone;
    theproggyrepoty;
    End.

    I tried this in the end of the script earlier:

    SCAR Code:
    Begin
    repeat
     repeat
      procedurex;
     until(x>0);
    until(IsFKeyDown(5)); //end when F5 is pressed.
    end.

    That epic failed...it just added "mytext" to the report until it timed out... so my two questions are:

    1. How to say if(IsKeyDown(Ctrl + Chr(49)))then
    2. How to have the script repeat until I say done (F5)...

    Please if you don't have the knowledge of how to help or any idea of where/who to ask ... then don't post... because I don't want to have to read the useless posts in this thread...

    V/Respectfully,
    anonymity
    On vacation in NeverLand,
    Code:
    typedef int bool;
    enum { false, true };

  2. #2
    Join Date
    May 2008
    Posts
    1,345
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    If IsKeyDown(50) And IsKeyDown(49) Then

    And's are awesome .

    To the second question:

    SCAR Code:
    Repeat
      //Code here
    Until(IsFkeyDown(5))

    Put the loops in the procedures and have it break on some conditions.

  3. #3
    Join Date
    Jan 2007
    Location
    the middle of know-where
    Posts
    1,308
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Sandstorm View Post
    SCAR Code:
    If IsKeyDown(50) And IsKeyDown(49) Then

    And's are awesome .
    Ok… that does not fix the problem… I when I compute… it still sends the key into the selected field… that is why I am looking for a “crtl + chr(49)” command….yes the use of And was awesome…

    Quote Originally Posted by Sandstorm View Post
    To the second question:

    SCAR Code:
    Repeat
      //Code here
    Until(IsFkeyDown(5))

    Put the loops in the procedures and have it break on some conditions.
    Hmm…. I tried that… but still it wont wait for me… it will either repeat to oblivion or I can only play it once…
    Thanks for help try.
    *******************************************
    Quote Originally Posted by radragon16 View Post
    If (IsFKeyDown(5)) And IsKeyDown(Char(49)) then
    begin
    x:=0;
    AddToReport('mytext');
    x:=x+1;
    end
    Well…close… but it still sends the “Char(49) into field… I that is why I asked for the “Ctrl+Chr(49)”….

    Quote Originally Posted by radragon16 View Post
    As for the check to continue until you press F5 just do a key pressed check and if it returns true call TerminateScript.
    Yes… good idea … but still gives me the repeating until timeout…

    Quote Originally Posted by radragon16 View Post
    Edit: Aww he beat me to it. lol
    Thanks for help try.
    All help is asked for..

    V/Respectfully,
    anonymity
    On vacation in NeverLand,
    Code:
    typedef int bool;
    enum { false, true };

  4. #4
    Join Date
    Oct 2006
    Location
    ithurtsithurtsithurtsithurts
    Posts
    2,930
    Mentioned
    7 Post(s)
    Quoted
    135 Post(s)

    Default

    Try
    SCAR Code:
    If (IsKeyDown(VK_CRTL)) And IsKeyDown(Char(49)) then

    Oh, and to fix your infinite repetition thing, try removing the x:=0; part.

  5. #5
    Join Date
    Jan 2007
    Location
    the middle of know-where
    Posts
    1,308
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by senrath View Post
    Try
    SCAR Code:
    If (IsKeyDown(VK_CRTL)) And IsKeyDown(Char(49)) then

    Oh, and to fix your infinite repetition thing, try removing the x:=0; part.
    SCAR Code:
    Unknown identifier 'VK_CRTL' in script

    Also, when I put the x:=0 to try and make the script add to one and stop for the next command ... without it ... it went on until it timed out.
    On vacation in NeverLand,
    Code:
    typedef int bool;
    enum { false, true };

  6. #6
    Join Date
    Oct 2006
    Location
    ithurtsithurtsithurtsithurts
    Posts
    2,930
    Mentioned
    7 Post(s)
    Quoted
    135 Post(s)

    Default

    Quote Originally Posted by anonymity View Post
    Unknown identifier 'VK_CRTL' in script

    Also, when I put the x:=0 to try and make the script add to one and stop for the next command ... without it ... it went on until it timed out.
    Whoopsie, I misspelled it. It's supposed to be VK_CTRL, not VK_CRTL.

    And the script works fine for me as is with the IsFKeyDown(5) terminating it.

  7. #7
    Join Date
    Jan 2007
    Location
    the middle of know-where
    Posts
    1,308
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by senrath View Post
    Whoopsie, I misspelled it. It's supposed to be VK_CTRL, not VK_CRTL.
    ...still not for me...

    Quote Originally Posted by senrath View Post
    And the script works fine for me as is with the IsFKeyDown(5) terminating it.
    Yes.. it will terminate... but how to keep it going without a one time run... here is a better version of the script... ..maybe easier to see:

    SCAR Code:
    {*************************}
    {**** Ctrl + 1 = set 1****} //what I want to happen
    {**** Ctrl + 2 = set 2****} //what I want to happen
    {**** Ctrl + 3 = set 3****} //what I want to happen
    {**** Ctrl + 4 = set 4****} //what I want to happen
    {*************************}

    Program HelpGet;
    {.include srl/srl.scar}

    Var
    x : Integer;

    Procedure procedurex;
    Begin
     if(IsKeyDown(Chr(49)))then
      begin
       x:=0;
        AddToReport('my text 1');
         x:=x+1;
      end;

     if(IsKeyDown(Chr(50)))then
      begin
      x:=0;
       AddToReport ('my text 2');
        x:=x+1;
      end;

     if(IsKeyDown(Chr(51)))then
      begin
      x:=0;
       AddToReport ('my text 3');
        x:=x+1;
      end;

     if(IsKeyDown(Chr(52)))then
      begin
      x:=0;
       AddToReport ('my text 4');
        x:=x+1;
      end;

    end;

    procedure proggy;
    begin
      Writeln('');
      Writeln('');
      Writeln('|*********************************************|');
      Writeln('Did this ' + IntToStr(x) + ' Times' + '');
      Writeln('Ran For ' +  TimeRunning);
      Writeln('|*********************************************|');
      Writeln('');
      Writeln('');
    end;


    Procedure thisone;
    begin
     repeat
       procedurex;
     until(x>0);
    end;

    Begin
    SetupSRL;
      thisone;
    proggy;
    End.

    // Repeat
    // Until(IsFKeyDown(5)); //End when F5 is pressed.

    And...I am not sure that I did the proggy properly ...I know this should just be easier than I am making it... but I don't know what to do ... again...

    1. How to say if(IsKeyDown(Ctrl + Chr(49)))then

    2. How to have the script run one command at a time until I say done (F5)...
    - without repeating that one command over and over and cannot terminate....
    On vacation in NeverLand,
    Code:
    typedef int bool;
    enum { false, true };

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. IsKeyDown
    By 666d3v1l666 in forum OSR Help
    Replies: 6
    Last Post: 08-29-2008, 11:34 AM
  2. iskeydown - need help
    By l33t_h4x0r in forum OSR Help
    Replies: 5
    Last Post: 12-16-2007, 11:31 PM
  3. What's IsKeyDown in C++ and how do I use it?
    By PwNZoRNooB in forum C/C++ Help and Tutorials
    Replies: 10
    Last Post: 08-14-2007, 05:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •