Jump to content

Error with my notepad input


Recommended Posts

Hi basicly i'm trying to create so when I click a button a notepad opens and types in stuff. I've successfuly done 2 buttons one of them opening a Internet page and the other opening a notepad and typing in copyright information.

I'm trying to do the next button, but I can't figure out how to input into a notepad exactly this.

"clients.txt"
{
    "version"   "1"

    // This key group lists all your client players
    "players"
    {
        // This must be a unique client name
        "Admin1"
        {
            // Client real name
            "name"  "Admin1"
            // Steam ID for client
            "steam" "STEAM_x:x:xxxxxx"
            "groups"
            {
                "Admin" "Serveradmin"
                "Immunity"  "Serveradmin"
            }
        }
    }

    // These are global groups of flags that can be assigned to clients
    "groups"
    {
        "Immunity"
        {
            "Serveradmin"   "a b c d e f g h i j k l m n o p q r s t u v x y afk ping autojoin grav Immunity"
            "Clanmember"    "a b c h k n afk ping grav autojoin Immunity"
        }
        "Admin"
        {
            "Serveradmin"   "A B C T U V W X Y Z a b c d o p q q2 q3 r z admin client grav pban spray"
            "Clanmember"    "B D E F a b c o q q2 q3 s t v w x y admin pban spray"
        }
    }

}

I need the exact amount of spaces and every symbol. But there's an error.

Here is my current source.

; A simple custom messagebox that uses the MessageLoop mode

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

_Main()

Func _Main()
    Local $YesID, $NoID, $ExitID, $msg

    GUICreate("C:SS Help Program v2", 400, 200)

    GUICtrlCreateLabel("Please pick an option below", 10, 10)
    $YesID = GUICtrlCreateButton("Copyright Information", 270, 5, 110, 25)
    $NoID = GUICtrlCreateButton("Open C:SS Forum", 10, 30, 130, 20)
    $ExitID = GUICtrlCreateButton("Create clients.txt", 10, 50, 160, 20)

    GUISetState() ; display the GUI

    Do
        $msg = GUIGetMsg()

        Select
            Case $msg = $YesID
                Run("notepad.exe")
                winWaitActive("Untitled - Notepad")
                send("Copyright information for C:SS Help program v1{enter}")
                send("{enter}")
                send("All work {&} coding copright 2009 © SuddenGunfire")
                send("This program was made for the users of counterstrikesource.com{enter}")
                send("Please don't sell or take credit for this program.{enter}")
                send("If this program is taken credit for I will stop making them{!}{enter}")
                send("{enter}")
                send("I'm not the owner of counterstrikesource.com I do not work for them{enter}")
                send("I simply am a user there.")
Sleep(500)
Send("+{UP 2}")
Sleep(500)
WinWaitClose("Untitled - Notepad")
            Case $msg = $NoID
                ShellExecute ("http://www.counterstrikesource.com")
            Case $msg = $ExitID
                Run("notepad.exe")
                WinWaitActive("Untitled - Notepad")
                Send("{"}clients.txt{"}{enter}")
                send("{")
                send("{enter}")
                send("  "version"   "1"{enter}")
            Case $msg = $GUI_EVENT_CLOSE
                MsgBox(0, "You clicked on", "Close")
        EndSelect
    Until $msg = $GUI_EVENT_CLOSE Or $msg = $ExitID
EndFunc  ;==>_Main

This area of code I think needs work:

Run("notepad.exe")
                WinWaitActive("Untitled - Notepad")
                Send("{"}clients.txt{"}{enter}")
                send("{")
                send("{enter}")
                send("  "version"   "1"{enter}")

Thanks in advance.

Link to comment
Share on other sites

Hi basicly i'm trying to create so when I click a button a notepad opens and types in stuff. I've successfuly done 2 buttons one of them opening a Internet page and the other opening a notepad and typing in copyright information.

I'm trying to do the next button, but I can't figure out how to input into a notepad exactly this.

"clients.txt"
 {
     "version"  "1"
 
     // This key group lists all your client players
     "players"
     {
         // This must be a unique client name
         "Admin1"
         {
             // Client real name
             "name" "Admin1"
             // Steam ID for client
             "steam"    "STEAM_x:x:xxxxxx"
             "groups"
             {
                 "Admin"    "Serveradmin"
                 "Immunity" "Serveradmin"
             }
         }
     }
 
     // These are global groups of flags that can be assigned to clients
     "groups"
     {
         "Immunity"
         {
             "Serveradmin"  "a b c d e f g h i j k l m n o p q r s t u v x y afk ping autojoin grav Immunity"
             "Clanmember"   "a b c h k n afk ping grav autojoin Immunity"
         }
         "Admin"
         {
             "Serveradmin"  "A B C T U V W X Y Z a b c d o p q q2 q3 r z admin client grav pban spray"
             "Clanmember"   "B D E F a b c o q q2 q3 s t v w x y admin pban spray"
         }
     }
 
 }

I need the exact amount of spaces and every symbol. But there's an error.

Here is my current source.

; A simple custom messagebox that uses the MessageLoop mode
 
 #include <GUIConstantsEx.au3>
 
 Opt('MustDeclareVars', 1)
 
 _Main()
 
 Func _Main()
     Local $YesID, $NoID, $ExitID, $msg
 
     GUICreate("C:SS Help Program v2", 400, 200)
 
     GUICtrlCreateLabel("Please pick an option below", 10, 10)
     $YesID = GUICtrlCreateButton("Copyright Information", 270, 5, 110, 25)
     $NoID = GUICtrlCreateButton("Open C:SS Forum", 10, 30, 130, 20)
     $ExitID = GUICtrlCreateButton("Create clients.txt", 10, 50, 160, 20)
 
     GUISetState(); display the GUI
 
     Do
         $msg = GUIGetMsg()
 
         Select
             Case $msg = $YesID
                 Run("notepad.exe")
                 winWaitActive("Untitled - Notepad")
                 send("Copyright information for C:SS Help program v1{enter}")
                 send("{enter}")
                 send("All work {&} coding copright 2009 © SuddenGunfire")
                 send("This program was made for the users of counterstrikesource.com{enter}")
                 send("Please don't sell or take credit for this program.{enter}")
                 send("If this program is taken credit for I will stop making them{!}{enter}")
                 send("{enter}")
                 send("I'm not the owner of counterstrikesource.com I do not work for them{enter}")
                 send("I simply am a user there.")
 Sleep(500)
 Send("+{UP 2}")
 Sleep(500)
 WinWaitClose("Untitled - Notepad")
             Case $msg = $NoID
                 ShellExecute ("http://www.counterstrikesource.com")
             Case $msg = $ExitID
                 Run("notepad.exe")
                 WinWaitActive("Untitled - Notepad")
                 Send("{"}clients.txt{"}{enter}")
                 send("{")
                 send("{enter}")
                 send(" "version"   "1"{enter}")
             Case $msg = $GUI_EVENT_CLOSE
                 MsgBox(0, "You clicked on", "Close")
         EndSelect
     Until $msg = $GUI_EVENT_CLOSE Or $msg = $ExitID
 EndFunc ;==>_Main

This area of code I think needs work:

Run("notepad.exe")
                 WinWaitActive("Untitled - Notepad")
                 Send("{"}clients.txt{"}{enter}")
                 send("{")
                 send("{enter}")
                 send(" "version"   "1"{enter}")

Thanks in advance.

I would think it would be easier to do it another way. Have a text file client.txt, when you want to open notepad copy this file to some convenient folder and run notepad like this

Run('notepad.exe "' & $SomeFolderPath & '\client.txt"')
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

The whole point is the user doesn't have clients.txt so that's why I need to be able for it to auto write it.

Well you didn''t given enough information for people to give an appropriate answer and you told us there was an error but not what the error is. Please give us a chance :)

Is it acceptable for you to use fileinclude for example?

Or you could use this approach to include the text file as a variable in your au3 script and write that to a file or write the string to notepad.

For the text you want to send you could create an array of variables using Function _FileReadToArray_FileReadToArray and write an include file with a list of defined variables for each line, then add them all together for one new string plus @CRLF for each line end and send the string to notepad with ControlSetText.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...