AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Halo Taunts

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
AgentSmith15



Joined: 06 May 2005
Posts: 37

PostPosted: Sun Feb 05, 2006 3:38 am    Post subject: Halo Taunts Reply with quote

This script pulls taunts from a txt file on the c:/ drive, and enters them into Halo.
If the script can be optimized please so.
Also this script wasn't written by me, but by my clan mate Gort.

Code:

my_var := True
Loop, Read, C:\taunts.txt
  {
    taunts%A_Index% := A_LoopReadLine
    tcnt := A_Index
  }

!NumpadEnter::
  {

    Random, rvar, 1, %tcnt%
    elem := taunts%rvar%


    StringLen, length, elem
    If length > 62
      {
        StringLeft, element, elem, 0
        Loop, Parse, elem, %A_Space%
          {
            myindex := A_Index
            StringLen, length, element
            StringLen, length2, A_LoopField
            If length2 + length > 63
              {
                Send,t
                Sleep, 100
                Send, %element%{Enter}
                StringLeft, element, elem, 0
                element := A_LoopField
              }
            Else
              {
                If myindex = 1
                  {
                    element := A_LoopField
                  }
                Else
                  {
                    element :=  element " " A_LoopField
                  }
              }
          }
        StringLen, length, element
        If length > 1
          {
            Send,t
            Sleep, 100
            Send, %element%{Enter}
          }
      }
    Else
      {
        Send,t
        Sleep, 100
        Send, %elem% {Enter}
      }

  }
Return


You can download the script from the address below.
http://www.savefile.com/files/5498010
Code:
Back to top
View user's profile Send private message
AgentSmith15



Joined: 06 May 2005
Posts: 37

PostPosted: Sun Feb 05, 2006 7:36 am    Post subject: Reply with quote

I would like some help with this script. It doesn't cut off at the end of a word for some reason. And ' or " seems to mess it up?
Back to top
View user's profile Send private message
toralf as guest
Guest





PostPosted: Sun Feb 05, 2006 9:11 am    Post subject: Reply with quote

Have you tried this?
Code:
my_var := True
Loop, Read, C:\taunts.txt
  {
    taunts%A_Index% := A_LoopReadLine
    tcnt := A_Index
  }
Return

!NumpadEnter::
        Send,t
        Sleep, 100
        ClipBoard = %elem%
        Send, ^v{Enter}
Return


I will move this topic to the "Ask for Help" section, since this is were it belongs, I think.

Ciao
toralf
Back to top
toralf



Joined: 31 Jan 2005
Posts: 3842
Location: Bremen, Germany

PostPosted: Sun Feb 05, 2006 9:21 am    Post subject: Reply with quote

Regarding your original code. You have an endless loop if the length is longer then 63 since a "break" is missing. And I don't understand what that sections is supposed to do.
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
AgentSmith15



Joined: 06 May 2005
Posts: 37

PostPosted: Sun Feb 05, 2006 8:51 pm    Post subject: Reply with quote

toralf wrote:
Regarding your original code. You have an endless loop if the length is longer then 63 since a "break" is missing. And I don't understand what that sections is supposed to do.

It is supposed to break up text that is longer than 63 characters.

It reads what I have in a text file and starts typing it, if longer than 63 characters is presses enter then types the rest.. Basically so I can type long messages in Halo, which limits the amount of characters you can type at a time.
Back to top
View user's profile Send private message
toralf



Joined: 31 Jan 2005
Posts: 3842
Location: Bremen, Germany

PostPosted: Sun Feb 05, 2006 10:56 pm    Post subject: Reply with quote

try this:
Code:
!NumpadEnter::
  Random, rvar, 1, %tcnt%
  String := taunts%rvar%
  Loop{
      If (StrLen(String) > 62){
          StringLeft, Left, String , 62
          Pos := InStr(Left, A_Space, "", 0)
          If Pos {
              StringLeft, ClipBoard, Left, %pos%
              StringTrimLeft, String ,String, %pos%
              Send,t
              Sleep, 100
              Send, ^v{Enter}
          }Else{
              ClipBoard := Left
              StringTrimLeft, String ,String, 62
              Send,t
              Sleep, 100
              Send, ^v{Enter}
             }
      }Else
          Break
    }
  Send,t
  Sleep, 100
  ClipBoard := String
  Send, ^v{Enter}
Return

_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
AgentSmith15



Joined: 06 May 2005
Posts: 37

PostPosted: Mon Feb 06, 2006 12:47 am    Post subject: Reply with quote

That didn't work for some reason?


What it seemed to me was press t and then press enter? And did only that.


Code:
my_var := True
Loop, Read, C:\taunts.txt
  {
    taunts%A_Index% := A_LoopReadLine
    tcnt := A_Index
  }

!NumpadEnter::
  Random, rvar, 1, %tcnt%
  String := taunts%rvar%
  Loop{
      If (StrLen(String) > 62){
          StringLeft, Left, String , 62
          Pos := InStr(Left, A_Space, "", 0)
          If Pos {
              StringLeft, ClipBoard, Left, %pos%
              StringTrimLeft, String ,String, %pos%
              Send,t
              Sleep, 100
              Send, ^v{Enter}
          }Else{
              ClipBoard := Left
              StringTrimLeft, String ,String, 62
              Send,t
              Sleep, 100
              Send, ^v{Enter}
             }
      }Else
          Break
    }
  Send,t
  Sleep, 100
  ClipBoard := String
  Send, ^v{Enter}
Return
Back to top
View user's profile Send private message
AgentSmith15



Joined: 06 May 2005
Posts: 37

PostPosted: Mon Feb 06, 2006 3:52 am    Post subject: Reply with quote

Oh I see...

I don't think you can copy and paste in this game. You have to type :/
Back to top
View user's profile Send private message
toralf



Joined: 31 Jan 2005
Posts: 3842
Location: Bremen, Germany

PostPosted: Mon Feb 06, 2006 12:58 pm    Post subject: Reply with quote

then replace the "Clipboard" and "^v" with the appropiate %var%
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
AgentSmith15



Joined: 06 May 2005
Posts: 37

PostPosted: Fri Feb 10, 2006 5:24 am    Post subject: Reply with quote

toralf wrote:
then replace the "Clipboard" and "^v" with the appropiate %var%

Could you please explain that a little better?
Back to top
View user's profile Send private message
toralf



Joined: 31 Jan 2005
Posts: 3842
Location: Bremen, Germany

PostPosted: Fri Feb 10, 2006 10:59 am    Post subject: Reply with quote

The code I have you is using the clipboard to hold the texct and only send Ctrl+V to the window. Since this is not working, as you said. You have to send the text directly and can't use the clipboard. Search through the code for "clipboard =" the string that is put on the clipboard you have to remember and put into the next "Send ^v" command (replacing the "^v"). The "clipboard =" line you can remove.
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
AgentSmith15



Joined: 06 May 2005
Posts: 37

PostPosted: Fri Feb 10, 2006 7:51 pm    Post subject: Reply with quote

ohhhh okay I got this
Code:

my_var := True
Loop, Read, C:\taunts.txt
  {
    taunts%A_Index% := A_LoopReadLine
    tcnt := A_Index
  }

  SetKeyDelay [, 50, 10]
 
!NumpadEnter::
  Random, rvar, 1, %tcnt%
  String := taunts%rvar%
  Loop{
      If (StrLen(String) > 62){
          StringLeft, Left, String , 62
          Pos := InStr(Left, A_Space, "", 0)
          If Pos {
              StringLeft, ClipBoard, Left, %pos%
              StringTrimLeft, String ,String, %pos%
              Send,t
              Sleep, 100
              SendRaw, %String%
           Send, {Enter}
          }Else{
              ClipBoard := Left
              StringTrimLeft, String ,String, 62
              Send,t
              Sleep, 100
              SendRaw, %String%
           Send, {Enter}
             }
      }Else
          Break
    }
  Send,t
  Sleep, 100

  SendRaw, %String%
           Send, {Enter}
Return


I made that send raw because I think there could be somthing messing up the text. For example it's repeating lines, I pressed the hot key in notepad and this is what it does..

It would type this if I only pressed the hotkey once

Quote:
tmoney!
tmoney!


or

Quote:
tgum-ball machine because it didn't take food stamps!
tgum-ball machine because it didn't take food stamps!

So I have no idea why the script is messing up the lines. Is it possible that the way it was saved as a varible only lets it print one line or small fragments of a line?

This is a example of the line that got messed up

Quote:
Yo' momma's so poor, she got arrested for breaking the gum-ball machine because it didn't take food stamps!
Back to top
View user's profile Send private message
toralf



Joined: 31 Jan 2005
Posts: 3842
Location: Bremen, Germany

PostPosted: Sat Feb 11, 2006 2:58 pm    Post subject: Reply with quote

you mixed several things up and didn't cleaned the code correctly.
Code:
my_var := True
Loop, Read, C:\taunts.txt
  {
    taunts%A_Index% := A_LoopReadLine
    tcnt := A_Index
  }
Return

!NumpadEnter::
  SetKeyDelay , 50, 10
  Random, rvar, 1, %tcnt%
  String := taunts%rvar%
  Loop{
      If (StrLen(String) > 62){
          StringLeft, Left, String , 62
          Pos := InStr(Left, A_Space, "", 0)
          If Pos {
              StringLeft, Left, Left, %pos%
              StringTrimLeft, String ,String, %pos%
              Send,t
              Sleep, 100
              SendRaw, %Left%
              Send, {Enter}
          }Else{
              StringTrimLeft, String ,String, 62
              Send,t
              Sleep, 100
              SendRaw, %Left%
              Send, {Enter}
             }
      }Else
          Break
    }
  Send,t
  Sleep, 100
  SendRaw, %String%
  Send, {Enter}
Return
From now on I expect you to find your own way. Good luck.
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group