Jump to content

Help Send a text from gui


Recommended Posts

Hi,

Im trying to make a little (2 lines) chat spammer for game guild wars, but i need some help with the code, here it is:

#include <GUIConstants.au3>
Opt("SendKeyDelay", 5)
Opt("SendCapslockMode", 1)

GUICreate("GW Chat Spammer",800, 100)
GUISetState (@SW_SHOW)
GUICtrlCreateLabel ("Spam Text 1:",  5, 5)
GUIStartGroup()
$All1 = GUICtrlCreateRadio ("All", 80, 3, 50, 20)
$Trade1 = GUICtrlCreateRadio ("Trade", 150, 3, 50, 20)
$Text1 = GUICtrlCreateInput ("", 5,  25, 700, 20)
GUICtrlCreateLabel ("Spam Text 2:",  5, 50)
GUIStartGroup()
$All2 = GUICtrlCreateRadio ("All", 80, 48, 50, 20)
$Trade2 = GUICtrlCreateRadio ("Trade", 150, 48, 50, 20)
$Text2 = GUICtrlCreateInput ("", 5,  70, 700, 20)
$Button = GUICtrlCreateButton ("SPAM",  725, 25, 60, 60)
$spam1 = GUICtrlRead($Text1)
$spam2 = GUICtrlRead($Text2)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Button
                WinActivate("Guild Wars", "")
                WinSetOnTop ("Guild Wars", "", 1)
                WinWaitActive ("Guild Wars", "")
            Send("{CapsLock on}")
                        If GUICtrlRead($All1) = $GUI_Checked Then Send("{!}")
                If GUICtrlRead($Trade1) = $GUI_Checked Then Send("{$}")
                If $spam1 <> "" Then Send("{ENTER}")
                Sleep(1000)
                Send($spam1)
                If $spam1 <> "" Then Send("{ENTER}")
                If GUICtrlRead($All2) = $GUI_Checked Then Send("{!}")
                If GUICtrlRead($Trade2) = $GUI_Checked Then Send("{$}")
                If $spam2 <> "" Then Send("{ENTER}")
                Sleep(1000)
                Send($spam2)
                If $spam2 <> "" Then Send("{ENTER}")
                WinSetOnTop ("Guild Wars", "", 0)
    EndSelect
Wend

The {!} and {$} is the channel im spamming at ! for "All (general)" channel and $ for "Trade" channel.

The "If $spam1 <> "" Then Send("{ENTER}")" before and after the spam message is to activate/deactivate the chat text insertion.

The problem here is that it goes ok on $GUI_Checked thing (it switch channels) but it doesnt type the text i typed on the gui.

One other minor problem is that the capslock thing is not working at all.

Can you guys help me with that ?

Thx a lot !

Edited by Lord Zion
Link to comment
Share on other sites

look into using ControlSend($window,$wintext,$controlID,$text,0)

It's more reliable than

WinActivate($window)

Send($text,0)

ProTip: You can use nulls for $wintext and $controlID

Example:

Func _cs($screen, $text, $option = 0)
    ControlSend($screen, "", "PCSWS:Pres:004000001", $text, $option)
EndFunc   ;==>_cs

Also, look into slowing the text insertion down even more than 5. Your keypress delay may also need a tweak or two. Make sure all those basic items have been played with first.

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

See if thats is what you told me to do:

#include <GUIConstants.au3>
Opt("SendKeyDelay", 10)
Opt("SendCapslockMode", 1)

Dim $window = "Guild Wars"

GUICreate("GW Chat Spammer",800, 100)
GUISetState (@SW_SHOW)
GUICtrlCreateLabel ("Spam Text 1:",  5, 5)
GUIStartGroup()
$All1 = GUICtrlCreateRadio ("All", 80, 3, 50, 20)
$Trade1 = GUICtrlCreateRadio ("Trade", 150, 3, 50, 20)
$Text1 = GUICtrlCreateInput ("", 5,  25, 700, 20)
GUICtrlSetState($All1, $GUI_CHECKED)
GUICtrlCreateLabel ("Spam Text 2:",  5, 50)
GUIStartGroup()
$All2 = GUICtrlCreateRadio ("All", 80, 48, 50, 20)
$Trade2 = GUICtrlCreateRadio ("Trade", 150, 48, 50, 20)
$Text2 = GUICtrlCreateInput ("", 5,  70, 700, 20)
GUICtrlSetState($All2, $GUI_CHECKED)
$Button = GUICtrlCreateButton ("SPAM",  725, 25, 60, 60)
$spam1 = GUICtrlRead($Text1)
$spam2 = GUICtrlRead($Text2)



While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Button
                WinActivate("Guild Wars", "")
                WinSetOnTop ("Guild Wars", "", 1)
                WinWaitActive ("Guild Wars", "")
            Send("{CapsLock on}")
                If GUICtrlRead($All1) = $GUI_Checked Then Send("{!}")
                          If GUICtrlRead($Trade1) = $GUI_Checked Then Send("{$}")
                          If $spam1 <> "" Then Send("{ENTER}")
                          Sleep(1000)
                          _cs($window, $spam1)
                          If $spam1 <> "" Then Send("{ENTER}{#}")
                        If GUICtrlRead($All2) = $GUI_Checked Then Send("{!}")
                          If GUICtrlRead($Trade2) = $GUI_Checked Then Send("{$}")
                        If $spam2 <> "" Then Send("{ENTER}")
                          Sleep(1000)
                          _cs($window, $spam2)
                          If $spam2 <> "" Then Send("{ENTER}{#}")
                      WinSetOnTop ("Guild Wars", "", 0)
    EndSelect
Wend

Func _cs($screen,$text,$option=1)
   ControlSend($screen, "", "", $text, $option)
EndFunc

It still doesnt type the text on the gui.

I changed the option to 1 because i need strings to be sent raw because i use lots of "+" and "-" on the messages

Can you please explain what is "$screen" and "$text" on the func _cs ?

Should i make _cs1 to spam text1 and _cs2 to spam text2 ?

I also increased the type delay to 10.

Any suggestions on the capslock thing ? (doesnt really matter, but i'd like to learn where im mistaking.

Thanks again !

Edited by Lord Zion
Link to comment
Share on other sites

ControlSend

Opt() - Specifically "SendKeyDelay" and "SendKeyDownDelay"

Functions

It still doesnt type the text on the gui.

I changed the option to 1 because i need strings to be sent raw because i use lots of "+" and "-" on the messages

Can you please explain what is "$screen" and "$text" on the func _cs ?

Should i make _cs1 to spam text1 and _cs2 to spam text2 ?

I also increased the type delay to 10.

Any suggestions on the capslock thing ? (doesnt really matter, but i'd like to learn where im mistaking.

Thanks again !

$screen and $text on the func _cs is a variable or literal that you pass to the function for it to use internally.

No, you shouldn't make _cs1 and _cs2 because the variables $spam1 and $spam2 take care of that.

Let me dig for a moment.

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

I see the bug.

Why are you reading your $spam1 and $spam2 before the GUI is created and not when the "SPAM" button is pressed?

#include <GUIConstants.au3>
opt("SendKeyDelay", 10)
opt("SendCapslockMode", 1)
Dim $window = "Guild Wars"
GUICreate("GW Chat Spammer", 800, 100)
GUICtrlCreateLabel("Spam Text 1:", 5, 5)
GUIStartGroup()
$All1 = GUICtrlCreateRadio("All", 80, 3, 50, 20)
$Trade1 = GUICtrlCreateRadio("Trade", 150, 3, 50, 20)
$Text1 = GUICtrlCreateInput("", 5, 25, 700, 20)
GUICtrlSetState($All1, $GUI_CHECKED)
GUICtrlCreateLabel("Spam Text 2:", 5, 50)
GUIStartGroup()
$All2 = GUICtrlCreateRadio("All", 80, 48, 50, 20)
$Trade2 = GUICtrlCreateRadio("Trade", 150, 48, 50, 20)
$Text2 = GUICtrlCreateInput("", 5, 70, 700, 20)
GUICtrlSetState($All2, $GUI_CHECKED)
$Button = GUICtrlCreateButton("SPAM", 725, 25, 60, 60)
$spam1 = GUICtrlRead($Text1)  ; these need to be read AFTER $Button is pressed
$spam2 = GUICtrlRead($Text2)  ; these need to be read AFTER $Button is pressed
GUISetState(@SW_SHOW)
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Button
            WinActivate("Guild Wars", "")
            WinSetOnTop("Guild Wars", "", 1)
            WinWaitActive("Guild Wars", "")
            Send("{CapsLock on}")
            If GUICtrlRead($All1) = $GUI_CHECKED Then Send("{!}")
            If GUICtrlRead($Trade1) = $GUI_CHECKED Then Send("{$}")
            If $spam1 <> "" Then Send("{ENTER}")
            Sleep(1000)
            _cs($window, $spam1)
            If $spam1 <> "" Then Send("{ENTER}{#}")
            If GUICtrlRead($All2) = $GUI_CHECKED Then Send("{!}")
            If GUICtrlRead($Trade2) = $GUI_CHECKED Then Send("{$}")
            If $spam2 <> "" Then Send("{ENTER}")
            Sleep(1000)
            _cs($window, $spam2)
            If $spam2 <> "" Then Send("{ENTER}{#}")
            WinSetOnTop("Guild Wars", "", 0)
    EndSelect
WEnd
Func _cs($screen, $text, $option = 1)
    ControlSend($screen, "", "", $text, $option)
EndFunc   ;==>_cs

Your problem with Capslock is a syntax error. It should read Send("{CapsLock DOWN}")

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

Ok, i got it !

Still have a few minor problems which are:

Its not sending all the letters, if i type 123456789 it only types random parts of that, im still trying to set the delay, but i have tried so far 1, 2, 3, 5, 10, 50 and 100 and no success.

Is the Opt("SendKeyDelay", X) setting the delay for string input on the gui or the delay for the string input of ControlSend or both ?

CapsLock DOWN works to turn it on, but i tried CapsLock OFF, UP and TOGGLE to turn it off but no success.

Again, thx a lot !

Edited by Lord Zion
Link to comment
Share on other sites

Post your working code?

And it's "{CapsLock UP}"

Sure, here is the working code:

#include <GUIConstants.au3>


Opt("SendKeyDelay", 10)
HotKeySet("^{NUMPADSUB}", "Kill")
HotKeySet("^{SPACE}", "Window")

Dim $window = "Guild Wars"


GUICreate("GW Chat Spammer", 800, 100)
GUICtrlCreateLabel("Spam Text 1:", 5, 5)
GUIStartGroup()
$All1 = GUICtrlCreateRadio("All", 80, 3, 50, 20)
$Trade1 = GUICtrlCreateRadio("Trade", 150, 3, 50, 20)
$Text1 = GUICtrlCreateInput("", 5, 25, 700, 20)
GUICtrlSetState($All1, $GUI_CHECKED)
GUICtrlCreateLabel("Spam Text 2:", 5, 50)
GUIStartGroup()
$All2 = GUICtrlCreateRadio("All", 80, 48, 50, 20)
$Trade2 = GUICtrlCreateRadio("Trade", 150, 48, 50, 20)
$Text2 = GUICtrlCreateInput("", 5, 70, 700, 20)
GUICtrlSetState($All2, $GUI_CHECKED)
$Button = GUICtrlCreateButton("SPAM", 725, 25, 60, 60)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Button
        If ProcessExists("gw.exe") = 0 Then
            MsgBox(0, "Warning", "Guild Wars is not running.")
            Exit
                EndIf
            $spam1 = GUICtrlRead($Text1)
                    $spam2 = GUICtrlRead($Text2)
            WinActivate("Guild Wars", "")
            WinSetOnTop("Guild Wars", "", 1)
            WinWaitActive("Guild Wars", "")
            Send("{CapsLock DOWN}")
            If GUICtrlRead($All1) = $GUI_CHECKED Then Send("{!}")
            If GUICtrlRead($Trade1) = $GUI_CHECKED Then Send("{$}")
            If $spam1 <> "" Then _cs($window, $spam1)
            If $spam1 <> "" Then Send("{ENTER}")
            Sleep(1000)
            If GUICtrlRead($All2) = $GUI_CHECKED Then Send("{!}")
            If GUICtrlRead($Trade2) = $GUI_CHECKED Then Send("{$}")
            If $spam2 <> "" Then _cs($window, $spam2)
            If $spam2 <> "" Then Send("{ENTER}")
            Send("{#}")
            Send("{ENTER}")
            Send("{CapsLock OFF}")
            WinSetOnTop("Guild Wars", "", 0)
    EndSelect
WEnd
Func _cs($screen, $text, $option = 1)
    ControlSend($screen, "", "", $text, $option)
EndFunc  ;==>_cs

Func Window()
    If $t = 0 Then
        WinSetState ("Guild Wars", "", @SW_HIDE)
                $t = 1
    Else
        WinActivate("Guild Wars", "")
;      WinMove("Guild Wars", "", 0, 0, 1152, 922)
              WinSetState ("Guild Wars", "", @SW_SHOW) 
        $t = 0
    EndIf
EndFunc

Func Kill()
  WinClose("Guild Wars", "")
  ProcessClose("Gw.exe")
EndFunc

Added a few little things, like show/hide and kill process.

The thing i was mistaking is that when i send the {!} and {$} it already atcivates the chat input didnt need the {ENTER} b4 the spam message.

I will try the {CapsLock UP} to see if it works.

Take a look and see if you can help with the delay problem please.

Thx again for your awesome help !

Link to comment
Share on other sites

Ok, i got it !

Is the Opt("SendKeyDelay", X) setting the delay for string input on the gui or the delay for the string input of ControlSend or both ?

Both Send() and ControlSend() use these option keys.

SendKeyDelay is the period of time between simulated keypresses.

SendKeyDownDelay is the period of time the simulated keypresses are "held down"

As indicated in the help file, some games require these settings to be tweaked with for a keypress to proplerly register.

edit: Fixed a fumble-fingered typo.

One thing that I just realized. You changed the $option = 0 to $option = 1 in my function....

You didn't have to do that, you could have just used _cs($window, $spam1, 1) to change the value of the OPTIONAL variable that was set. If you don't specifiy a value for an optional value, it defaults to whatever is after the assignment symbol.

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

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...