Snook Posted October 25, 2005 Share Posted October 25, 2005 Ok i run a game server on a remote computer and play the game on another what i would like to do is like i say "next" autoit would see it in the servers gui chat and then click the next button but on the other hand i dont just want anyone being able to do this.I'm still new to autoit did a few very basic scripts so far but need pointed in the right direction for this.. Link to comment Share on other sites More sharing options...
Nuffilein805 Posted October 25, 2005 Share Posted October 25, 2005 how bout this?send this to your servernext|itsme|mypassthe server has to:$a = stringsplit($incoming_message, "|") if iniread ("someinifile.ini", "Users", $a[2], "") = $a[3] then ;do your next-operation endifi'd do it this way - safest 1 my little chatmy little encryption toolmy little hidermy unsafe clickbot Link to comment Share on other sites More sharing options...
PaulDG Posted October 25, 2005 Share Posted October 25, 2005 Does the server log the GUI Chat to a file? maybe AI could parse that file and then react. You would probably have to keep a unique userid so that it could be sure it was coming from you and not someone else. What Game is it? Or if the server has an rcon, AI could interact with that via tcpip... Link to comment Share on other sites More sharing options...
LxP Posted October 29, 2005 Share Posted October 29, 2005 Welcome to the forums!Your first task is to write a script that clicks the Next button. Once you have completed that, you have one of two options:Take a look at PsExec. This would allow you from your computer to instruct the server computer to run the AutoIt script. This would be the simplest solution because you don't need to implement AutoIt logic to watch a chat window, determine what text has been added and parse that text for commands.Do the whole lot via AutoIt. This will require much more effort. You will need to write code that monitors the chat window for changes, most likely using ControlGetText() and a loop. You could do this by determining how many characters already sit in the chat window and waiting until this number changes, at which point you know that you must check the text. You could determine what text is new (and then act on just that) by comparing the lengths of the old text and the new text. This of course requires that AutoIt can in fact see the text (it cannot do so for windows that don't use standard Microsoft controls). Try opening AutoIt Window Info on the server computer and inspecting the chat window for chat text. Link to comment Share on other sites More sharing options...
Snook Posted October 29, 2005 Author Share Posted October 29, 2005 Ok now as everyone can tell im new but here is what im wanting to do here is the server gui with the command im wanting so when that is said i want this to happenMouseClick("left", 545, 755)so I have read around in the helpfile and think I have it pin ponited to ControlGetText but I need help in writing it now the chatbox there is Control ID 1034 ClassNameNN ListBox2 now here is what I have started;Waits for Server WindowWinWaitActive("NASCAR SimRacing Dedicated Server");Welcome Message RepeatedWhile 1ControlSend("NASCAR SimRacing Dedicated Server", "", "Edit1", "YOUR TEXT HERE")Sleep(3000)ControlSend("NASCAR SimRacing Dedicated Server", "", "Edit1", "YOUR TEXT HERE")Sleep(75000)WEndNow is that even right I dont know but seems to work Link to comment Share on other sites More sharing options...
LxP Posted October 29, 2005 Share Posted October 29, 2005 From your screenshot it looks like you want a script that does this:Wait for the server window to exist.Send out a welcome message via chat every 75 seconds or so.Monitor the chat window for certain incoming data.Perform actions when that data is received.Based on that information I would start by having the following information handy:; Server window identifier Global Const $SERVER_WINDOW = 'NASCAR SimRacing Dedicated Server' ; Control IDs of window controls to manipulate Global Const $CHAT_INPUT = 'ListBox2' Global Const $CHAT_OUTPUT = '(enter control ID of chat entry line here)' Global Const $CHAT_SEND = '(enter control ID of Send Chat Button here)' Global Const $NEXT_SESSION = '(enter control ID of Next Session button here)' Global Const $NEXT_EVENT = '(enter control ID of Next Event button here)'I have defined $NEXT_SESSION and $NEXT_EVENT above because it looks like you'll want to click them via the script, and using ControlClick() is a better way to achieve this than MouseClick().Instead of immediately posting a code loop that will monitor the chat window for changes, I'll come back later with a user-defined function that you can use because watching a text control for updates is a (sort of) popular request and such a UDF wouldn't hurt.In the meantime though, here's how I would do what you have written above (if you're interested):; Server window identifier Global Const $SERVER_WINDOW = 'NASCAR SimRacing Dedicated Server' ; Control IDs of window controls to manipulate Global Const $CHAT_OUTPUT = '(enter control ID of chat entry line here)' Global Const $CHAT_SEND = '(enter control ID of Send Chat Button here)' ; Not using WinWaitActive() because the window doesn't have to be active for the script to work WinWait($SERVER_WINDOW) While 1 Chat('YOUR TEXT HERE') Chat('YOUR TEXT HERE') Sleep(75000) WEnd Func Chat($Msg) ControlSetText($SERVER_WINDOW, '', $CHAT_OUTPUT, $Msg) ControlClick($SERVER_WINDOW, '', $CHAT_SEND) EndFunc Link to comment Share on other sites More sharing options...
LxP Posted October 29, 2005 Share Posted October 29, 2005 Uh oh. I just noticed from your code that the chat display is a list box and not a standard multi-line text field. Grabbing text from list boxes is trickier than grabbing text from text fields (and I don't have any experience with this as yet). I think I might go to bed first. Link to comment Share on other sites More sharing options...
Snook Posted October 29, 2005 Author Share Posted October 29, 2005 (edited) Based on that information I would start by having the following information handy: ; Control IDs of window controls to manipulate Global Const $CHAT_INPUT = 'ListBox2' Global Const $CHAT_OUTPUT = 'Edit1' Global Const $CHAT_SEND = 'Button9' Global Const $NEXT_SESSION = 'Button1' Global Const $NEXT_EVENT = 'Button2' and the Sleep(75000) was wrong think I wanted it for like every 15 mins so maybe this would be better Sleep(900000) Edited October 29, 2005 by Snook Link to comment Share on other sites More sharing options...
Nuffilein805 Posted October 29, 2005 Share Posted October 29, 2005 omg don't do such a long sleep it will slow down your whole prog if you need such a long sleep do it by counting e.g. $a = 0 do $a = $a + 1 sleep (5000) if $a = 180 then ;send your message $a = 0 endif until 1 = 2 my little chatmy little encryption toolmy little hidermy unsafe clickbot Link to comment Share on other sites More sharing options...
Valik Posted October 29, 2005 Share Posted October 29, 2005 omg don't do such a long sleepit will slow down your whole progif you need such a long sleep do it by countingCare explaining this (wrong) logic? Link to comment Share on other sites More sharing options...
LxP Posted October 30, 2005 Share Posted October 30, 2005 (edited) Well, I just spent an hour or more trying to work out how to read the information I needed from ListBoxes...Here's my code. Give it a run and let me know how it goes. I obviously can't test it here.Note: I programmed this for use with the beta version.Edit: Code now terminates when the server window disappears.; Removed (it was long outdated) Edited November 5, 2005 by LxP Link to comment Share on other sites More sharing options...
Snook Posted October 30, 2005 Author Share Posted October 30, 2005 (edited) Â Â Â Â Â Â Â Â Line80 $Counter +=1 $Counter^Error Error:Expected a "=" operator in assignment statement Now i have no idea about this I got lost but im trying to understand alittle of this and I and many fellow racers appreciate all the help Edited October 30, 2005 by Snook Link to comment Share on other sites More sharing options...
Snook Posted October 30, 2005 Author Share Posted October 30, 2005 (edited) As LxP said must use Autoit BetaWorks like a champ so far now just how did he do it lol Edited October 30, 2005 by Snook Link to comment Share on other sites More sharing options...
LxP Posted October 30, 2005 Share Posted October 30, 2005 $Counter += 1 is beta-accepted shorthand for $Counter = $Counter + 1. You may have been able to change that and run the script under v3.1.1 with no problems, but in my opinion the beta is superior in every single way anyway.To help you better understand how the script works, here is its logic:Define all IDs in appropriately named constants. This ensures that you'll know exactly which controls are being manipulated later and it means that you would only ever have to correct one location if you misspell a control ID.Define some settings and declare some variables that will be used.Do the following until the server window disappears (I have since modified the code to do it like this):Send two chat messages if it's been 75 seconds since the last time (or if the messages have not been sent at all yet).While there are unread lines in the chat window:Grab the next one.Ignore it if it doesn't start with some special string (which means it may be a command).Otherwise, trim off the bit at the start and read the rest, doing certain actions depending on the content.Briefly pause. There's no need to constantly check the window as fast as possible -- that would steal resources from the server itself which is a Bad Thing. Link to comment Share on other sites More sharing options...
Snook Posted October 30, 2005 Author Share Posted October 30, 2005 Ok Now the Next thing in the screenshot under clients shows name and there ping now i want that to be public so anyone can type !ping and it will return there ping kinda like !ping then it will say Your ping is <10ms> Also on the other hand i would think there would be a need to restrict how many times in such amount of time they can doit you know some people like to take things overboard kinda like me and this and that client box is ListBox1 control id 1033 ok so i think i need to start here and add something like this Global Const $Client_INPUT = 'ListBox1' at the top now where to go from here Link to comment Share on other sites More sharing options...
LxP Posted October 30, 2005 Share Posted October 30, 2005 The script logic will need to be modified slightly because you wouldn't be able to rely on the username as part of the command signal.StringRegExp() would be a very handy and efficient way to determine if a chat line is a command, and then return both the username and the command if so.Restricting the number of times that a user can send commands within a timeframe is possible but it would require a decent amount of code. You'd need multi-dimensional arrays to keep track of usernames and command tallies. I'll leave that to you. Link to comment Share on other sites More sharing options...
Snook Posted October 31, 2005 Author Share Posted October 31, 2005 ok now let me see im try to allow other ppl to use the commands so I thought I would setup a ini with the allowed users now where am I going wrong here this is the line it looking for when i type the command right Global Const $CMD_PREFIX = 'Snook: !' Correct no? so if i replace that with $CMD_PREFIX = IniRead("C:\Temp\myfile.ini", "section2", "key", "NotFound") not work or do i need to just give up on this stuff am i even on the right track ini [sectionName] Key=Value was taken from helpfile Link to comment Share on other sites More sharing options...
Nuffilein805 Posted October 31, 2005 Share Posted October 31, 2005 Care explaining this (wrong) logic?np, you will slow down the reaction-time of your program using a long sleep (or do you disagree with that) my little chatmy little encryption toolmy little hidermy unsafe clickbot Link to comment Share on other sites More sharing options...
LxP Posted October 31, 2005 Share Posted October 31, 2005 I think Valik means that the following two pieces of code are exactly identical in terms of function: $a = 0 do $a = $a + 1 sleep (5000) if $a = 180 then ;send your message $a = 0 endif until 1 = 2 While 1 Sleep(15 * 60 * 1000) ; Send your message WEnd Link to comment Share on other sites More sharing options...
Nuffilein805 Posted October 31, 2005 Share Posted October 31, 2005 for sure? never tried it this way! is it just a giant sleep or is it 15 * 60 sleeps of 1sec? cause if you sleep such a long time your server won't do anything in that time than sleep, snore, ... my little chatmy little encryption toolmy little hidermy unsafe clickbot Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now