AutoHotkey Community

It is currently May 27th, 2012, 1:21 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 23 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: May 6th, 2005, 5:42 am 
Offline

Joined: May 6th, 2005, 5:09 am
Posts: 37
I had a friend help me make this script and I was wondering if it was clean, and if they are any bugs..

This script is made to use with halo. It uses "http://www.halostats.com/downloads/launcher.html" this is to launch halo from the browser. We are useing this script to do the necesry commands to run our server.
We have been haveing problems useing this to type text & commands into halo, as it will start typeing text before the text box is open, thus messing up the command, so we are useing the timers, and I was wondering is there a better way then the timers? Also is every thing in the code clean, and optimized?

Here is some basic Halo info:
To type to everyone in halo we would press "t" and to talk to our team we would press "y".
To get to the rcon you press "~".
And here are some of the rcon commands
http://www.bungie.net/Games/HaloPC/page ... eadme#rcon

To make a long story short I was wondering how to make sure the text get's into the input screen without the message or command to be cut up, and I am asking is the code clean and what to optimise. So please help me.

Code:
#z::Run, http://www.ferretwarez.com/ewclan/
#x::Run, halo://205.234.159.13:2304

#c::
InputBox, password, Team Speak - Pass, Please Enter Password, hide
if ErrorLevel <> 0
            MsgBox, CANCEL was pressed.
else
            Run,teamspeak://ServerIp/nickname=nick?password=pass?channel=chan?channelpassword="%password%""

^!n::
IfWinExist, AutoHotkey.ini - Notepad
            WinActivate
else
            Run, C:\Program Files\AutoHotkey\AutoHotkey.ini
return

IfWinNotExist, Autohotkey.ini - Notepad
            Run, C:\Program Files\AutoHotkey\AutoHotkey.ini

$Numpad1:: Send,\
$Numpad1 Up:: SetTimer, Alert1, 100
return

 

Alert1:
Send rcon password sv_players
SetTimer, Alert1, Off
return

$Numpad2:: Send,\
$Numpad2 Up:: SetTimer, Alert2, 100
return

Alert2:
SendRaw rcon password sv_kick
SetTimer, Alert2, Off
return

$Numpad3:: Send,\
$Numpad3 Up:: SetTimer, Alert3, 100
return

Alert3:
SendRaw rcon password sv_ban
SetTimer, Alert3, Off
return

$Numpad4:: Send,\
$Numpad4 Up:: SetTimer, Alert4, 100
return

Alert4:
SendRaw rcon password sv_map_reset
SetTimer, Alert4, Off
return

$Numpad5:: Send,\
$Numpad5 Up:: SetTimer, Alert5, 100
return

Alert5:
SendRaw rcon password sv_map_next
SetTimer, Alert5, Off
return

$Numpad6:: Send,\
$Numpad6 Up:: SetTimer, Alert6, 100
return

Alert6:
SendRaw rcon password sv_mapcycle_begin
SetTimer, Alert6, Off
return

$Numpad7:: Send,T
$Numpad7 Up:: SetTimer, Alert7, 100
return

Alert7:
SendRaw,...STOP I'm using this Hog for Defense!!!
Send,{enter}
SetTimer, Alert7, Off
return

$Numpad8:: Send,T
$Numpad8 Up:: SetTimer, Alert8, 100
return

Alert8:
SendRaw,...Watch the language, Please!!!
Send,{enter}
SetTimer, Alert8, Off
return

$Numpad9:: Send,T
$Numpad9 Up:: SetTimer, Alert9, 100
return

Alert9:
SendRaw,...Next time you will be BANNED from the server!!!
Send,{enter}
SetTimer, Alert9, Off
return

<^>!$Numpad1:: Send,\
<^>!$Numpad1 Up:: SetTimer, Alert10, 100
return

Alert10:
SendRaw rcon password sv_ban 1
SetTimer, Alert10, Off
return

<^>!$Numpad2:: Send,\
<^>!$Numpad2 Up:: SetTimer, Alert11, 100
return

Alert11:
SendRaw rcon password sv_ban 2
SetTimer, Alert11, Off
return

<^>!$Numpad3:: Send,\
<^>!$Numpad3 Up:: SetTimer, Alert12, 100
return

Alert12:
SendRaw rcon password sv_ban 3
SetTimer, Alert12, Off
return

<^>!$Numpad4:: Send,\
<^>!$Numpad4 Up:: SetTimer, Alert13, 100
return

Alert13:
SendRaw rcon password sv_ban 4
SetTimer, Alert13, Off
return

<^>!$Numpad5:: Send,\
<^>!$Numpad5 Up:: SetTimer, Alert14, 100
return

Alert14:
SendRaw rcon password sv_ban 5
SetTimer, Alert14, Off
return

<^>!$Numpad6:: Send,\
<^>!$Numpad6 Up:: SetTimer, Alert15, 100
return

Alert15:
SendRaw rcon password sv_ban 6
SetTimer, Alert15, Off
return

<^>!$Numpad7:: Send,\
<^>!$Numpad7 Up:: SetTimer, Alert16, 100
return

Alert16:
SendRaw rcon password sv_ban 7
SetTimer, Alert16, Off
return

<^>!$Numpad8:: Send,\
<^>!$Numpad8 Up:: SetTimer, Alert17, 100
return

Alert17:
SendRaw rcon password sv_ban 8
SetTimer, Alert17, Off
return

<^>!$Numpad9:: Send,\
<^>!$Numpad9 Up:: SetTimer, Alert18, 100
return

Alert18:
SendRaw rcon password sv_ban 9
SetTimer, Alert18, Off
return

<^>!$Numpad0:: Send,\
<^>!$Numpad0 Up:: SetTimer, Alert19, 100
return

Alert19:
SendRaw rcon password sv_ban 10
SetTimer, Alert19, Off
return

<^>!$Insert:: Send,\
<^>!$Insert Up:: SetTimer, Alert20, 100
return

Alert20:
SendRaw rcon password sv_ban 11
SetTimer, Alert20, Off
return

<^>!$Home:: Send,\
<^>!$Home Up:: SetTimer, Alert21, 100
return

Alert21:
SendRaw rcon password sv_ban 12
SetTimer, Alert21, Off
return

<^>!$PgUp:: Send,\
<^>!$PgUp Up:: SetTimer, Alert22, 100
return

Alert22:
SendRaw rcon password sv_ban 13
SetTimer, Alert22, Off
return

<^>!$Delete:: Send,\
<^>!$Delete Up:: SetTimer, Alert23, 100
return

Alert23:
SendRaw rcon password sv_ban 14
SetTimer, Alert23, Off
return

<^>!$End:: Send,\
<^>!$End Up:: SetTimer, Alert24, 100
return

Alert24:
SendRaw rcon password sv_ban 15
SetTimer, Alert24, Off
return

<^>!$PgDn:: Send,\
<^>!$PgDn Up:: SetTimer, Alert25, 100
return

Alert25:
SendRaw rcon password sv_ban 6
SetTimer, Alert25, Off
return

^!$NumpadAdd:: SetTimer, Alert26, 1000000
^!$NumpadAdd Up:: SetTimer, Alert27, 1010000
return

Alert26:
Send, T
return

Alert27:
SendRaw, http://www.ferretwarez.com/ewclan
Send {enter}
return

^!$NumpadSub:: SetTimer, Alert27, Off
^!$NumpadSub Up:: SetTimer, Alert26, Off
return


Last edited by AgentSmith15 on May 6th, 2005, 8:18 pm, edited 3 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 6th, 2005, 8:49 am 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
Hi AgentSmith 15,

I had a look at your script. It would be greate if you could edit your post to ease reading for all users. E.g. remove all irrelevant empty lines and comments and use identations.
E.g. like this:
Code:
$Numpad1:: Send,\
$Numpad1 Up:: SetTimer, Alert1, 100

Alert1:
  Send rcon password sv_players
  SetTimer, Alert1, Off
return


Here are my comments to your code.
To simplify the code you might as well use this:
Code:
$Numpad1::
  Send,\
  Sleep, 100
  Send rcon password sv_players
return
*not tested*

Or this::
Code:
$Numpad1::
  Send,\
  SetTimer, Alert1, 100
return

Alert1:
  Send rcon password sv_players
  SetTimer, Alert1, Off
return
*not tested*

As for recourses you might be better of with timers, I suspect. I never used scripts with games. Test what fits your needs.

Does your input window have a title bar or can it be identified by something else? Then you might be able to detect it via IfWinActive etc.
This might help you to get rid of the timers or sleep. Someone else might help in this case, since I have never used it.

As for shorten the whole script, you could use functions, e.g.:
Code:
<^>!$Numpad1::SendPasswordSVBAN(1)
<^>!$Numpad2::SendPasswordSVBAN(2)
<^>!$Numpad3::SendPasswordSVBAN(3)
<^>!$Numpad4::SendPasswordSVBAN(4)
<^>!$Numpad5::SendPasswordSVBAN(5)

SendPasswordSVBAN(id):
  Send,\
  Sleep, 100
  Send, rcon password sv_ban %id%
return
*not tested*
You can simplify the rest of your hotkeys the same way. But as for performance, you have to test.

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 6th, 2005, 4:01 pm 
Offline

Joined: May 6th, 2005, 5:09 am
Posts: 37
Quote:
Does your input window have a title bar or can it be identified by something else? Then you might be able to detect it via IfWinActive etc.
This might help you to get rid of the timers or sleep. Someone else might help in this case, since I have never used it.


I wouldn't know, nothing pops up. How would I find out?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 6th, 2005, 5:30 pm 
Offline

Joined: May 6th, 2005, 5:09 am
Posts: 37
So I will be testing it, but it should look like.
Code:
#z::Run, http://www.ferretwarez.com/ewclan/
#x::Run, halo://205.234.159.13:2304

#c::
InputBox, password, Team Speak - Pass, Please Enter Password, hide
if ErrorLevel <> 0
            MsgBox, CANCEL was pressed.
else
             Run,teamspeak://ServerIp/nickname=nick?password=pass?channel=chan?channelpassword="%password%""

^!n::
IfWinExist, AutoHotkey.ini - Notepad
            WinActivate
else
            Run, C:\Program Files\AutoHotkey\AutoHotkey.ini
return

IfWinNotExist, Autohotkey.ini - Notepad
            Run, C:\Program Files\AutoHotkey\AutoHotkey.ini

$Numpad1::
  Send,\
  Sleep, 100
  Send rcon password sv_players
return

$Numpad2::
  Send,\
  Sleep, 100
  SendRaw rcon password sv_kick
return

$Numpad3::
  Send,\
  Sleep, 100
  SendRaw rcon password sv_ban
return

$Numpad4::
  Send,\
  Sleep, 100
  SendRaw rcon password sv_map_reset
return

$Numpad5::
  Send,\
  Sleep, 100
  SendRaw rcon password sv_map_next
return

$Numpad6::
  Send,\
  Sleep, 100
  SendRaw rcon password sv_mapcycle_begin
return

$Numpad7:: Send,T
  Send,\
  Sleep, 100
  SendRaw,...STOP I'm using this Hog for Defense!!!
  Send,{enter}
return

$Numpad8:: Send,T
  Send,\
  Sleep, 100
  SendRaw,...Watch the language, Please!!!
  Send,{enter}
return

$Numpad9:: Send,T
  Send,\
  Sleep, 100
  SendRaw,...Next time you will be BANNED from the server!!!
  Send,{enter}
return

<^>!$Numpad1::Send Password SV_BAN(1)
<^>!$Numpad2::Send Password SV_BAN(2)
<^>!$Numpad3::Send Password SV_BAN(3)
<^>!$Numpad4::Send Password SV_BAN(4)
<^>!$Numpad5::Send Password SV_BAN(5)
<^>!$Numpad6::Send Password SV_BAN(6)
<^>!$Numpad7::Send Password SV_BAN(7)
<^>!$Numpad8::Send Password SV_BAN(8)
<^>!$Numpad9::Send Password SV_BAN(9)
<^>!$Numpad0::Send Password SV_BAN(10)
<^>!$Insert::Send Password SV_BAN(11)
<^>!$Home::Send Password SV_BAN(12)
<^>!$PgUp::Send Password SV_BAN(13)
<^>!$Delete::Send Password SV_BAN(14)
<^>!$End::Send Password SV_BAN(15)
<^>!$PgDn::Send Password SV_BAN(16)

 
SendPasswordSV_BAN(id):
  Send,\
  Sleep, 100
  Send, rcon password sv_ban %id%
return


I know there are errors near the end of the code, and I left it that way :wink:


Last edited by AgentSmith15 on May 6th, 2005, 8:49 pm, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 6th, 2005, 7:31 pm 
Offline

Joined: May 6th, 2005, 5:09 am
Posts: 37
Okay I am getting some problems

When I press Numpad 7 - 9 it type's "T" but not the rest of the sentence for some reason?
What the number pad keys 7 - 9 should type
First one is 7 second is 8 third 9

T...STOP I'm using this Hog for Defense!!!
T...Watch the language, Please!!!
T...Next time you will be BANNED from the server!!!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 6th, 2005, 7:46 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
Hi,

Put the send,T into the second line. If you follow the hotkey :: with a command, AHK thinks it is a one-liner. If nothing is after the :: AHK will execute till "return". E.g.:
Code:
$Numpad7::
  Send,T
  Send,\
  Sleep, 100
  SendRaw,...STOP I'm using this Hog for Defense!!!
  Send,{enter}
return


There is an error in the following. The text after the hotkey is the name of the function and not the command:
Code:
Instead of This:
<^>!$Numpad1::Send Password SV_BAN(1)

it should be this:
<^>!$Numpad1::SendPasswordSV_BAN(1)

Since it should call this function: 
SendPasswordSV_BAN(id):
You could as well give the function a different name. I gave it that name on purpose, so that its name represents what it is doing.

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 6th, 2005, 7:52 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
AgentSmith15 wrote:
Quote:
Does your input window have a title bar or can it be identified by something else? Then you might be able to detect it via IfWinActive etc.
This might help you to get rid of the timers or sleep. Someone else might help in this case, since I have never used it.


I wouldn't know, nothing pops up. How would I find out?


You wrote in your first post
Quote:
We have been haveing problems useing this to type text & commands into halo, as it will start typeing text before the text box is open, thus messing up the command,

What is this text box, you talk about. Does it have a title? Is it a special class (use WinSpy to find out)?

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 6th, 2005, 8:21 pm 
Offline

Joined: May 6th, 2005, 5:09 am
Posts: 37
Well I could show a screen shot
here it is...
Image

How am I sposed to use WinSpy when it takes the full screen?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 6th, 2005, 8:54 pm 
Offline

Joined: May 6th, 2005, 5:09 am
Posts: 37
Okay I got some screen shots but I don't know what to really do, cause you were a little vague.
Click on the thumbnail to maximise the pic
Image
Image

I think it's this window
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 6th, 2005, 9:27 pm 
Offline

Joined: May 6th, 2005, 5:09 am
Posts: 37
I'm getting this error though :(
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 7th, 2005, 3:00 am 
Offline

Joined: May 6th, 2005, 5:09 am
Posts: 37
ah, I didn't have the latest release.
Here is the same error though
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 7th, 2005, 1:57 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
I'm sorry, since functions are new to AHK. I mixed the formats.
Code:
;This is the format of a subroutine (and not what you want):
SendPasswordSV_BAN:
  Send,\
  Sleep, 100
  Send, rcon password sv_ban %id%
return

;This is the format of a function (and this is how it should be in your code)
SendPasswordSV_BAN(id)
{
  Send,\
  Sleep, 100
  Send, rcon password sv_ban %id%
}


As I said before i'm not familiar with manipulating windows (or games). Therefore I can't help you with identifiing the text box. But with the information you have, you could kindly ask people like Rajat, Serenity or Lazlo to assist you on this topic. They might have an idea to solve it.

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 7th, 2005, 11:46 pm 
Offline

Joined: May 6th, 2005, 5:09 am
Posts: 37
Rajat, Serenity or Lazlo....
Yea I would like any help I can get 8)

How do you spose I can get ahold of them...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 8th, 2005, 1:00 am 
Offline

Joined: November 8th, 2004, 12:46 am
Posts: 1271
Can you get the game to run in a window and not full screen? If so, then try using Window Spy (not WinSpy) that comes with AutoHotkey, its simpler to see if there is a window/control to work with. WinSpy is better for more advanced stuff like PostMessage.

One tip, when a message box is focused you can use Ctrl+C to copy the text it contains to the clipboard to save you posting screenshots of the message box errors.

_________________
"Anything worth doing is worth doing slowly." - Mae West
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 8th, 2005, 3:57 am 
Offline

Joined: May 6th, 2005, 5:09 am
Posts: 37
LOL, that is what you said in another thread...

I think there is a way to change the properties or something to run in a window...
But I don't know how :(


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 23 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, chaosad, oldbrother and 19 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group