Sign in to follow this  
Followers 0
Åmbrosius

First Scripts, did I go pearshaped?

10 posts in this topic

#1 ·  Posted (edited)

Hi all, just found AutoIt on Monday, while looking for a way to help install my apps for unattended installations, and I've gotta say I love it, works like a charm. Great fun too.

It only took me a few minutes to do the Tutorials in the help file, and making my own was simple. Anyway, I got bored after about ten install scripts, so I started messing around, at the request of my little brother, with an MSN 'Spammer' I suppose you'd call it, as he was getting frustrated with getting dragged into conversations, so wanted a revenge toy. :D

Anyway, as is my habbit, I took a simple idea, and kept throwing bits at it till it was hopelessly overcomplicated, but it's more fun that way. Anyway thanks to a brilliantly written helpfile, and this forum, I got it finished and it works, technically, sluggish an unresponsive at times, but it does the job.

; ----------------------------------------------------------------------------
; AutoIt Version: 3.1.1 Beta
; Author:         Åmbrosius
; ----------------------------------------------------------------------------

; Call Constants Inclusion
#include <GuiConstants.au3>
AutoItSetOption("SendKeyDelay", 1)

; Set Deafult Variables
$InputFig_1 = 500
$SlideFig_1 = 500
$TempFig_1 = 500
$InputFig_2 = 0
$SlideFig_2 = 0
$TempFig_1 = 0
$Switch = 0
$RepeatType = "MSec"
$SendType = "Text"
$DurationType = "Infinite"
$RepeatRate = 500
$SendText = "You've been SPAMMED :P"
$SpammerCount = 1

Global $Duration, $RunCount, $Percent, $Factor, $Target, $SendType, $SendText

; Define & Create the GUI
; Set GUI Label and Window Size
GuiCreate("MSN SPAMBOT v2.0", 400, 454,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
; Create Target Selection Control
$Label_1 = GuiCtrlCreateLabel("TARGET:", 18, 15, 60, 20)
$Combo_1 = GuiCtrlCreateCombo("Please Select Your Target  (Press 'Refresh' to Re-Load)", 70, 10, 320, 220)
; Create Content Controls
$Edit_1 = GuiCtrlCreateEdit("You've been SPAMMED :P", 10, 86, 380, 100)
$Group_1 = GuiCtrlCreateGroup("SEND TYPE :", 10, 36, 380, 40)
    $Radio_1 = GuiCtrlCreateRadio("TEXT", 20, 49, 60, 20)
    $Radio_2 = GuiCtrlCreateRadio("NUDGE", 165, 49, 60, 20)
    $Radio_3 = GuiCtrlCreateRadio("COMBO", 320, 49, 60, 20)
        GUICtrlSetState($Radio_1, $GUI_CHECKED)
; Create Repetition Speed Controls
$Group_2 = GuiCtrlCreateGroup("REPEAT RATE", 10, 191, 380, 40)
    $Radio_4 = GuiCtrlCreateRadio("Milli-SECONDS", 20, 204, 90, 19)
    $Radio_5 = GuiCtrlCreateRadio("SECONDS", 175, 204, 70, 19)
    $Radio_6 = GuiCtrlCreateRadio("MINUTES", 310, 204, 70, 19)
        GUICtrlSetState($Radio_4, $GUI_CHECKED)
$Slider_1 = GuiCtrlCreateSlider(3, 240, 332, 40)
$Input_1 = GUICtrlCreateInput ($InputFig_1, 340, 248, 50, 20, $ES_READONLY)
    $UpDown_1 = GUICtrlCreateUpdown($Input_1, $UDS_NOTHOUSANDS)
        GUICtrlSetLimit($Slider_1, 5000,1)
        GUICtrlSetData($Slider_1, $SlideFig_1)
        GUICtrlSetLimit($UpDown_1, 5000,1)
        GUICtrlSetData($Input_1, $InputFig_1)
; Create Duration Time Controls
$Group_3 = GuiCtrlCreateGroup("DURATION :", 10, 279, 380, 40)
    $Radio_7 = GuiCtrlCreateRadio("INFINITE", 20, 292, 70, 20)
    $Radio_8 = GuiCtrlCreateRadio("SEC", 135, 292, 70, 19)
    $Radio_9 = GuiCtrlCreateRadio("MIN", 225, 292, 70, 19)
    $Radio_10 = GuiCtrlCreateRadio("NUMBER", 315, 292, 70, 20)
        GUICtrlSetState($Radio_7, $GUI_CHECKED)
$Slider_2 = GuiCtrlCreateSlider(3, 328, 332, 40)
$Input_2 = GUICtrlCreateInput ($InputFig_2, 340, 336, 50, 20, $ES_READONLY)
    $UpDown_2 = GUICtrlCreateUpdown($Input_2, $UDS_NOTHOUSANDS)
        GUICtrlSetState($Slider_2, $GUI_DISABLE)
        GUICtrlSetState($Input_2, $GUI_DISABLE)
; Create Action Control Buttons & Progress Bar
$Progress_1 = GuiCtrlCreateProgress(10, 375, 380, 40, $PBS_SMOOTH )
    GUICtrlSetData($Progress_1,100)
$Button_1 = GuiCtrlCreateButton("&Send", 10, 426, 70, 20)
$Button_2 = GuiCtrlCreateButton("S&top", 94, 426, 70, 20)
    GUICtrlSetState($Button_2, $GUI_DISABLE)
$Button_3 = GuiCtrlCreateButton("Re&fresh", 236, 426, 70, 20)
$Button_4 = GuiCtrlCreateButton("E&xit", 320, 426, 70, 20)

; Init Populate the Target List
ListMSN()

; Parse for GUI Activity
GuiSetState()
While 1 
    Switch GuiGetMsg()
        ; Standard Windows 'X' Icon
        Case $GUI_EVENT_CLOSE
                Exit(0)
        ; Radio Button = Send Type : Text
        Case $Radio_1
            GUICtrlSetState($Edit_1, $GUI_ENABLE)
            $SendType = "Text"
        ; Radio Button = Send Type : Nudge
        Case $Radio_2
            GUICtrlSetState($Edit_1, $GUI_DISABLE)
            $SendType = "Nudge"
        ; Radio Button = Send Type : Combination
        Case $Radio_3
            GUICtrlSetState($Edit_1, $GUI_ENABLE)
            $SendType = "Combo"
        ; Radio Button = Repeat Rate : Milli-Seconds
        Case $Radio_4
            $SlideFig_1 = 500
            GUICtrlSetLimit($Slider_1, 5000,1)
            GUICtrlSetData($Slider_1,$SlideFig_1)
                $InputFig_1 = 500
                GUICtrlSetData($Input_1, $InputFig_1)
                GUICtrlSetLimit($UpDown_1, 5000,1)
                $RepeatType = "MSec"
        ; Radio Button = Repeat Rate : Seconds
        Case $Radio_5
            $SlideFig_1 = 30
            GUICtrlSetLimit($Slider_1, 300,1)
            GUICtrlSetData($Slider_1,$SlideFig_1)
                $InputFig_1 = 30
                GUICtrlSetData($Input_1, $InputFig_1)
                GUICtrlSetLimit($UpDown_1, 300,1)
                $RepeatType = "Sec"
        ; Radio Button = Repeat Rate : Minutes
        Case $Radio_6
            $SlideFig_1 = 5
            GUICtrlSetLimit($Slider_1, 60,1)
            GUICtrlSetData($Slider_1,$SlideFig_1)
                $InputFig_1 = 5
                GUICtrlSetData($Input_1, $InputFig_1)
                GUICtrlSetLimit($UpDown_1, 60,1)
                $RepeatType = "Min"
        ; Radio Button = Duration : Infinite
        Case $Radio_7
                $SlideFig_2 = 0
                GUICtrlSetData($Slider_2,$SlideFig_2)
                GUICtrlSetState($Slider_2, $GUI_DISABLE)
                    $InputFig_2 = 0
                    GUICtrlSetData($Input_2, $InputFig_2)
                    GUICtrlSetState($Input_2, $GUI_DISABLE)
                    $DurationType = "Infinite"
        ; Radio Button = Duration : Seconds
        Case $Radio_8
            $SlideFig_2 = 30
            GUICtrlSetLimit($Slider_2, 300,1)
            GUICtrlSetData($Slider_2,$SlideFig_2)
            GUICtrlSetState($Slider_2, $GUI_ENABLE)
                $InputFig_2 = 30
                GUICtrlSetData($Input_2, $InputFig_2)
                GUICtrlSetState($Input_2, $GUI_ENABLE)
                GUICtrlSetLimit($UpDown_2, 300,1)
                $DurationType = "Sec"
        ; Radio Button = Duration : Minutes
        Case $Radio_9
            $SlideFig_2 = 5
            GUICtrlSetLimit($Slider_2, 60,1)
            GUICtrlSetData($Slider_2,$SlideFig_2)
            GUICtrlSetState($Slider_2, $GUI_ENABLE)
                $InputFig_2 = 5
                GUICtrlSetData($Input_2, $InputFig_2)
                GUICtrlSetState($Input_2, $GUI_ENABLE)
                GUICtrlSetLimit($UpDown_2, 60,1)
                $DurationType = "Min"
        ; Radio Button = Duration : Fixed Number
        Case $Radio_10
            $SlideFig_2 = 100
            GUICtrlSetLimit($Slider_2, 9999,1)
            GUICtrlSetData($Slider_2,$SlideFig_2)
            GUICtrlSetState($Slider_2, $GUI_ENABLE)
                $InputFig_2 = 100
                GUICtrlSetData($Input_2, $InputFig_2)
                GUICtrlSetState($Input_2, $GUI_ENABLE)
                GUICtrlSetLimit($UpDown_2, 9999,1)
                $DurationType = "Number"
        ; Button : Send
        Case $Button_1
            InitSpammer()
            AdlibEnable("SpamUp", $RepeatRate)
        ; Button : Stop
        Case $Button_2
            AdlibDisable()
            GUICtrlSetState($Button_2, $GUI_DISABLE)
            GUICtrlSetData($Progress_1, 100)
        ; Button : Refresh
        Case $Button_3
            ListMSN()
        ; Button : Exit
        Case $Button_4
            Exit(0)
        ; Loop Functions
        Case Else
            ; Get Focus to Determine Master/Slave
            $Focus = ControlGetFocus("MSN SPAMBOT v2.0", "")
            ; Synchronize Slider 1 to Input Box 1
            If $Focus = "Edit3" Then
                $SlideFig_1 = GUICtrlRead($Input_1)
                GUICtrlSetData($Slider_1, $SlideFig_1)
            EndIf
            ; Synchronize Slider 2 to Input Box 2
            If $Focus = "Edit4" Then
                $SlideFig_2 = GUICtrlRead($Input_2)
                GUICtrlSetData($Slider_2, $SlideFig_2)
            EndIf
            ; Synchronize Input Box 1 to Slider 1
            If $Focus = "msctls_trackbar321" Then
                $InputFig_1 = GUICtrlRead($Slider_1)
                GUICtrlSetData($Input_1, $InputFig_1)
            EndIf
            ; Synchronize Input Box 2 to Slider 2
            If $Focus = "msctls_trackbar322" Then
                $InputFig_2 = GUICtrlRead($Slider_2)
                GUICtrlSetData($Input_2, $InputFig_2)
            EndIf
    EndSwitch
WEnd


; Check for open/visable MSN Conversation Windows
Func ListMSN()
    $MSNList = WinList()
    For $i = 1 to $MSNList[0][0]
        If $MSNList[$i][0] <> "" AND IsVisible($MSNList[$i][1]) And StringInStr($MSNList[$i][0], "- CONVERSATION") And Not StringInStr($MSNList[$i][0], "mbrosius") Then
            GUICtrlSetData($Combo_1, $MSNList[$i][0])
        EndIf
    Next
EndFunc
Func IsVisible($Handle)
    If BitAnd( WinGetState($Handle), 2 ) Then 
        Return 1
    Else
        Return 0
    EndIf
EndFunc

; Interpret & Convert GUI Selections and Create Engine Commands
Func InitSpammer()
    GUICtrlSetState($Button_2, $GUI_ENABLE)
    ; Get Edit Box Text if Necessary
    If $SendType = "Combo" Or $SendType = "Text" Then
        $SendText = GUICtrlRead($Edit_1)
    EndIf
    ; Calculate Repeat Rate
    $RepeatRate = GUICtrlRead($Input_1)
        If $RepeatType = "Sec" Then
            $RepeatRate = Number($RepeatRate * 1000)
        EndIf
        If $RepeatType = "Min" Then
            $RepeatRate = Number($RepeatRate * 60000)
        EndIf
    ; Calculate Duration Time
    $Duration = GUICtrlRead($Input_2)
        If $DurationType = "Sec" Then
            $Duration = Number($Duration * 1000)
        EndIf
        If $DurationType = "Min" Then
            $Duration = Number($Duration * 60000)
        EndIf
        If $DurationType = "Number" Then
            $Duration = Number($Duration * $RepeatRate)
        EndIf
        If $DurationType = "Infinite" Then
            $Duration = $RepeatRate
        EndIf
    ; Calculate Progress Percentiles
    $Factor = $Duration / $RepeatRate
    $Percent = "100" / $Factor
    GUICtrlSetData($Progress_1, 0)
    ;Get Target Window
    $Target = GUICtrlRead($Combo_1)
    ;Reset $RunCount
    $RunCount = 0
EndFunc

; Spammer Engine 
Func SpamUp()
    ;Ensure Infinite Countsown never reaches Zero
    If $DurationType = "Infinite" Then
        $Duration = Number($Duration + $RepeatRate)
    EndIf
    ; Count Each Pass (Approxish)
    If $Duration > 0 Then
        ; Count Each Pass & Update Progress(Approxish)
        $Duration = $Duration - $RepeatRate
        $RunCount = $RunCount + 1
        $Progress = $Percent * $RunCount
            GUICtrlSetData($Progress_1, $Progress)
        ; The Actual Spamming Bit, ROFL
        If $SendType <> "Nudge" Then
            WinActivate($Target)
            Send($SendText & @CRLF)
        EndIf
        If $SendType <> "Text" Then
            WinActivate($Target)
            Send("!A")
            Send("d")
        EndIf
    EndIf
    If Not $Duration > 0 Then
        GUICtrlSetData($Progress_1, 100)
        GUICtrlSetState($Button_2, $GUI_DISABLE)
        AdlibDisable()
    EndIf
EndFunc

In the hope of learning, I'd just like to post it here and let you all rip it to shreads, if you have a spare moment, so I can find out what/where I went wrong, or at least if there are better ways to do any of it (I know some of them were kinda made up as I went along, so there's bound to be lots to complain about.)

Just bear in mind that I've had AutoIt for less than a week, and hadn't done anything like it since Turbo Pascal in the late 80's :"> , so personally I was impressed that it worked at all. So be nice.

Oh yeah, and please forgive my formatting and comments, they make sense to me, which is what's important.

Also, is there a 'Best Practice' viewpoint on whether to do the GUI first, then build, or build then stick in a GUI, or just whatever you happen to feel like at the time?

Anyway, thanks all in advance for you time. I do so love being fed to the wolves. :D

EDIT

Changed to AutoIt Codebox and added attatchment as requested. I think.

MSN_Spam_Bot_Type_Thingy.au3

Edited by Åmbrosius

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Could you put up the script as an attachment? I hate codeboxes....

I personally prefer to do the GUI first then the logic, because the GUI code gives you the basic structure to work on.

Unless I'm in one of my "make-everything-nondependent-from each-other" types of moods. When I'm in that mood, there are almost no depenencies between the different sections of code, so order does not matter.

You'll know yourself through experence after developing your own coding style.

edit: Try using the

AutoIt Tags
. Copying and pasting from there works better that codeboxes.

#)

Edited by nfwu

Share this post


Link to post
Share on other sites

... When I'm in that mood, there are almost no depenencies between the different sections of code, so order does not matter.

So how would that work exactly? Just calling Functions from the GUI? Or am I over simplifying? I was tempted to try that, but didn't want to confuse my poor little brain. In future I would probably prefer to keep them entirely seperate, so either can be rewritten or adapted without dying a slow and painfull death.

My first priority, however, is to figure out how to do things without torturing variables at every step to make anything happen, it just doesn't feel very clean.

Thanks for having a look :D

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

How about this:

(not tested.)

;;;;;OK, let's re-organize everything. (Trying for noob-friendly code)
#include <GuiConstants.au3>
AutoItSetOption("SendKeyDelay", 1)

;;;;;;;;;;;;;;;;;This part of GUI init code is quite good organizing - since you understand it.
;;;;;;;;;;;;;;;;;But I'll personally use more discriptive names like: $EditBox_SendText and $Radio_SendType_Text.
#region Create GUI;;Organize the code in SciTE using Regions (assuming you use SciTE)
; Define & Create the GUI
; Set GUI Label and Window Size
GuiCreate("MSN SPAMBOT v2.0", 400, 454,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
; Create Target Selection Control
$Label_1 = GuiCtrlCreateLabel("TARGET:", 18, 15, 60, 20)
$Combo_1 = GuiCtrlCreateCombo("Please Select Your Target  (Press 'Refresh' to Re-Load)", 70, 10, 320, 220)
; Create Content Controls
$Edit_1 = GuiCtrlCreateEdit("You've been SPAMMED :P", 10, 86, 380, 100)
$Group_1 = GuiCtrlCreateGroup("SEND TYPE :", 10, 36, 380, 40)
    $Radio_1 = GuiCtrlCreateRadio("TEXT", 20, 49, 60, 20)
    $Radio_2 = GuiCtrlCreateRadio("NUDGE", 165, 49, 60, 20)
    $Radio_3 = GuiCtrlCreateRadio("COMBO", 320, 49, 60, 20)
        GUICtrlSetState($Radio_1, $GUI_CHECKED)
; Create Repetition Speed Controls
$Group_2 = GuiCtrlCreateGroup("REPEAT RATE", 10, 191, 380, 40)
    $Radio_4 = GuiCtrlCreateRadio("Milli-SECONDS", 20, 204, 90, 19)
    $Radio_5 = GuiCtrlCreateRadio("SECONDS", 175, 204, 70, 19)
    $Radio_6 = GuiCtrlCreateRadio("MINUTES", 310, 204, 70, 19)
        GUICtrlSetState($Radio_4, $GUI_CHECKED)
$Slider_1 = GuiCtrlCreateSlider(3, 240, 332, 40)
$Input_1 = GUICtrlCreateInput ($InputFig_1, 340, 248, 50, 20, $ES_READONLY)
    $UpDown_1 = GUICtrlCreateUpdown($Input_1, $UDS_NOTHOUSANDS)
        GUICtrlSetLimit($Slider_1, 5000,1)
        GUICtrlSetData($Slider_1, $SlideFig_1)
        GUICtrlSetLimit($UpDown_1, 5000,1)
        GUICtrlSetData($Input_1, $InputFig_1)
; Create Duration Time Controls
$Group_3 = GuiCtrlCreateGroup("DURATION :", 10, 279, 380, 40)
    $Radio_7 = GuiCtrlCreateRadio("INFINITE", 20, 292, 70, 20)
    $Radio_8 = GuiCtrlCreateRadio("SEC", 135, 292, 70, 19)
    $Radio_9 = GuiCtrlCreateRadio("MIN", 225, 292, 70, 19)
    $Radio_10 = GuiCtrlCreateRadio("NUMBER", 315, 292, 70, 20)
        GUICtrlSetState($Radio_7, $GUI_CHECKED)
$Slider_2 = GuiCtrlCreateSlider(3, 328, 332, 40)
$Input_2 = GUICtrlCreateInput ($InputFig_2, 340, 336, 50, 20, $ES_READONLY)
    $UpDown_2 = GUICtrlCreateUpdown($Input_2, $UDS_NOTHOUSANDS)
        GUICtrlSetState($Slider_2, $GUI_DISABLE)
        GUICtrlSetState($Input_2, $GUI_DISABLE)
; Create Action Control Buttons & Progress Bar
$Progress_1 = GuiCtrlCreateProgress(10, 375, 380, 40, $PBS_SMOOTH )
    GUICtrlSetData($Progress_1,100)
$Button_1 = GuiCtrlCreateButton("&Send", 10, 426, 70, 20)
$Button_2 = GuiCtrlCreateButton("S&top", 94, 426, 70, 20)
    GUICtrlSetState($Button_2, $GUI_DISABLE)
$Button_3 = GuiCtrlCreateButton("Re&fresh", 236, 426, 70, 20)
$Button_4 = GuiCtrlCreateButton("E&xit", 320, 426, 70, 20)
#endregion

; Init Populate the Target List
ListMSN()

;;;;;;;;;;;;;;;;P.S. If you add in the GUI after the logic, you'll find the OnEvent Mode useful.
;;;;;;;;;;;;;;;;;;;; Look at the help file under "GUI Reference - OnEvent Mode"

#region GUI Handling Code
GuiSetState()
While 1 
    Switch GuiGetMsg()
        Case $GUI_EVENT_CLOSE;;Windows Exit Event ('X' icon)
            Exit
        Case $Radio_1;;Text Sendtype
            GUICtrlSetState($Edit_1, $GUI_ENABLE)
        Case $Radio_2;;Nudge Sendtype
            GUICtrlSetState($Edit_1, $GUI_DISABLE)
        Case $Radio_3;;Combo Sendtype
            GUICtrlSetState($Edit_1, $GUI_ENABLE)
        Case $Radio_4;;Millisecond Repeat Rate
            GUICtrlSetLimit($Slider_1, 5000,1)
            GUICtrlSetData($Slider_1,500)
            GUICtrlSetData($Input_1, 500)
            GUICtrlSetLimit($UpDown_1, 5000,1)
        Case $Radio_5;;Seconds Repeat Rate
            GUICtrlSetLimit($Slider_1, 300,1)
            GUICtrlSetData($Slider_1,30)
            GUICtrlSetData($Input_1, 30)
            GUICtrlSetLimit($UpDown_1, 300,1)
        Case $Radio_6;;Minutes Repeat Rate
            GUICtrlSetLimit($Slider_1, 60,1)
            GUICtrlSetData($Slider_1,5)
            GUICtrlSetData($Input_1, 5)
            GUICtrlSetLimit($UpDown_1, 60,1)
        Case $Radio_7;;Infinite Duration
            GUICtrlSetData($Slider_2,0)
            GUICtrlSetState($Slider_2, $GUI_DISABLE)
            GUICtrlSetData($Input_2,0)
            GUICtrlSetState($Input_2, $GUI_DISABLE)
        Case $Radio_8;;Seconds Duration
            GUICtrlSetLimit($Slider_2, 300,1)
            GUICtrlSetData($Slider_2, 30)
            GUICtrlSetState($Slider_2, $GUI_ENABLE)
            GUICtrlSetData($Input_2, 30)
            GUICtrlSetState($Input_2, $GUI_ENABLE)
            GUICtrlSetLimit($UpDown_2, 300,1)
        Case $Radio_9;;Minutes Duration
            GUICtrlSetLimit($Slider_2, 60,1)
            GUICtrlSetData($Slider_2,5)
            GUICtrlSetState($Slider_2, $GUI_ENABLE)
            GUICtrlSetData($Input_2, 5)
            GUICtrlSetState($Input_2, $GUI_ENABLE)
            GUICtrlSetLimit($UpDown_2, 60,1)
        Case $Radio_10;;Amount Duration
            GUICtrlSetLimit($Slider_2, 9999,1)
            GUICtrlSetData($Slider_2,100)
            GUICtrlSetState($Slider_2, $GUI_ENABLE)
            GUICtrlSetData($Input_2, 100)
            GUICtrlSetState($Input_2, $GUI_ENABLE)
            GUICtrlSetLimit($UpDown_2, 9999,1)
        Case $Button_1;;Send Button
            InitSpammer()
        Case $Button_2;;Stop Button
            AdlibDisable()
            GUICtrlSetState($Button_2, $GUI_DISABLE)
            GUICtrlSetData($Progress_1, 100)
        Case $Button_3;;Refresh Button
            ListMSN()
        Case $Button_4;;Exit Button
            Exit
        Case Else
; Get Focus to Determine Master/Slave
            $Focus = ControlGetFocus("MSN SPAMBOT v2.0", "")
; Synchronize Slider 1 to Input Box 1
            If $Focus = "Edit3" Then GUICtrlSetData($Slider_1, GUICtrlRead($Input_1))
; Synchronize Slider 2 to Input Box 2
            If $Focus = "Edit4" Then GUICtrlSetData($Slider_2, GUICtrlRead($Input_2))
; Synchronize Input Box 1 to Slider 1
            If $Focus = "msctls_trackbar321" Then GUICtrlSetData($Input_1, GUICtrlRead($Slider_1))
; Synchronize Input Box 2 to Slider 2
            If $Focus = "msctls_trackbar322" Then GUICtrlSetData($Input_2, GUICtrlRead($Slider_2))
    EndSwitch
WEnd
#endregion

Func ListMSN()
    $MSNList = WinList()
    For $i = 1 to $MSNList[0][0]
        If $MSNList[$i][0] <> "" AND IsVisible($MSNList[$i][1]) And StringInStr($MSNList[$i][0], "- CONVERSATION") And Not StringInStr($MSNList[$i][0], "mbrosius") Then
            GUICtrlSetData($Combo_1, $MSNList[$i][0])
        EndIf
    Next
EndFunc
Func IsVisible($Handle)
    If BitAnd( WinGetState($Handle), 2 ) Then 
        Return 1
    Else
        Return 0
    EndIf
EndFunc
Global $SendText, $RepeatRate, $InfiniteDurationMode, $spamfunc
Global $Factor, $Target, $RunCount, $Percent, $Duration
Func InitSpammer()
    $SendText = GUICtrlRead($Edit_1)
;;Set Repeat Rate
    $RepeatRate = GUICtrlRead($Input_1)
    If BitAND(GUICtrlRead($Radio_5), $GUI_CHECKED) = $GUI_CHECKED Then;;If $Radio_5 is checked...;;Seconds
        $RepeatRate = Number($RepeatRate * 1000)
    ElseIf BitAND(GUICtrlRead($Radio_6), $GUI_CHECKED) = $GUI_CHECKED Then;;Minutes
        $RepeatRate = Number($RepeatRate * 60000)
    EndIf
;;Set Duration
    $Duration = GUICtrlRead($Input_2)
    If BitAND(GUICtrlRead($Radio_8), $GUI_CHECKED) = $GUI_CHECKED Then;;Sec
        $Duration = Number($Duration * 1000)
    ElseIf BitAND(GUICtrlRead($Radio_9), $GUI_CHECKED) = $GUI_CHECKED Then;;Min
        $Duration = Number($Duration * 60000)
    ElseIf BitAND(GUICtrlRead($Radio_10), $GUI_CHECKED) = $GUI_CHECKED Then;;Num
        $Duration = Number($Duration * $RepeatRate)
    ElseIf BitAND(GUICtrlRead($Radio_7), $GUI_CHECKED) = $GUI_CHECKED Then;;Infinite
        $Duration = $RepeatRate
        $InfiniteDurationMode = 1
    EndIf
; Calculate Progress Percentiles
    $Factor = $Duration / $RepeatRate
    $Percent = 100 / $Factor
    GUICtrlSetData($Progress_1, 0)
;Get Target Window
    $Target = GUICtrlRead($Combo_1)
;Reset $RunCount
    $RunCount = 0
    
    If BitAND(GUICtrlRead($Radio_1), $GUI_CHECKED) = $GUI_CHECKED Then $spamfunc = "SpamUp_Nudge"
    If BitAND(GUICtrlRead($Radio_1), $GUI_CHECKED) = $GUI_CHECKED Then $spamfunc = "SpamUp_Text"
    If BitAND(GUICtrlRead($Radio_1), $GUI_CHECKED) = $GUI_CHECKED Then $spamfunc = "SpamUp_Combo"
    
    AdlibEnable("SpamUp", $RepeatRate)
EndFunc

Func SpamUp()
;Ensure Infinite Countsown never reaches Zero
    If $InfiniteDurationMode Then $Duration = Number($Duration + $RepeatRate)
; Count Each Pass (Approxish)
    If $Duration > 0 Then
; Count Each Pass & Update Progress(Approxish)
        $Duration = $Duration - $RepeatRate
        $RunCount = $RunCount + 1
        $Progress = $Percent * $RunCount
        GUICtrlSetData($Progress_1, $Progress)
; The Actual Spamming Bit, ROFL
        Call($spamfunc)
    EndIf
    If Not $Duration > 0 Then
        GUICtrlSetData($Progress_1, 100)
        GUICtrlSetState($Button_2, $GUI_DISABLE)
        AdlibDisable()
    EndIf
EndFunc

Func SpamUp_Nudge()
    WinActivate($Target)
    Send("!A")
    Send("d")
EndFunc
Func SpamUp_Text()
    WinActivate($Target)
    Send($SendText & @CRLF)
EndFunc
Func SpamUp_Combo()
    SpamUp_Nudge()
    SpamUp_Text()
EndFunc

#)

edit: removed accidental commenting of a portion of code

btw, interesting editbox:slider sync code!

Edited by nfwu

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

btw, interesting editbox:slider sync code!

Rofl, yeah, couldn't find a better way to get them both to synch to each other, only one way. It works, but the slider can be a little sluggish to respond when using the UpDown on the edit boxes. Fun one to try and figure out though. I'd forgotten how much fun it is to run into brick walls.

Going to have a play with your version now. TY for your time & effort.

Oh yeah, and I do use SciTE, so a big shout-out and thanks to all those who created & adapted it. All the pretty colours make things so much easier to understand, and the parameter prompt is incredibly time saving for a noob like me. Brilliant piece of software, only missing a Vertical Tile option, as far as I can see, otherwise it's perfect. Thanks to the Forum too for poking me in it's direction.

Edited by Åmbrosius

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Just visually noted a couple of things

these three lines have no value... they do the same thing

If BitAND(GUICtrlRead($Radio_1), $GUI_CHECKED) = $GUI_CHECKED Then $spamfunc = "SpamUp_Nudge"
    If BitAND(GUICtrlRead($Radio_1), $GUI_CHECKED) = $GUI_CHECKED Then $spamfunc = "SpamUp_Text"
     If BitAND(GUICtrlRead($Radio_1), $GUI_CHECKED) = $GUI_CHECKED Then $spamfunc = "SpamUp_Combo"

also

when checking for which radio is checked it is good that you use "ElseIf", however on the last one it should be "Else"

example

;;Set Duration
    $Duration = GUICtrlRead($Input_2)
    If BitAND(GUICtrlRead($Radio_8), $GUI_CHECKED) = $GUI_CHECKED Then;;Sec
        $Duration = Number($Duration * 1000)
    ElseIf BitAND(GUICtrlRead($Radio_9), $GUI_CHECKED) = $GUI_CHECKED Then;;Min
        $Duration = Number($Duration * 60000)
    ElseIf BitAND(GUICtrlRead($Radio_10), $GUI_CHECKED) = $GUI_CHECKED Then;;Num
        $Duration = Number($Duration * $RepeatRate)
    Else; infinite
        $Duration = $RepeatRate
        $InfiniteDurationMode = 1
    EndIf
*************** visually only

and here use "If" and "Else" only

;;Set Repeat Rate
    $RepeatRate = GUICtrlRead($Input_1)
    If BitAND(GUICtrlRead($Radio_5), $GUI_CHECKED) = $GUI_CHECKED Then;;If $Radio_5 is checked...;;Seconds
        $RepeatRate = Number($RepeatRate * 1000)
    Else;;Minutes
        $RepeatRate = Number($RepeatRate * 60000)
    EndIf

this makes your script faster and saves CPU usage

8)

Oh yeah, and I do use SciTE, so a big shout-out and thanks to all those who created & adapted it.,,,, from me too...Thanks JDeb!!!!

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Brilliant, thanks.

Made a few changes, added this to the top:

; Preset Default Values
$InputFig_1 = 500
$SlideFig_1 = 500
$InputFig_2 = 0
$SlideFig_2 = 0
$RepeatRate = 500

; Declare Variables
Global $InfiniteDurationMode, $Duration, $RunCount, $Percent, $Target, $SendText, $spamfunc

Needed the presets to create the GUI, not entirely sure why I had to move up those Globals though, as they aren't used till after you declared 'em anyway. But it refused to compile, so go figure. Perhaps because it gets stuck in the GIU loop checking for events?

Also added the following line so the thing could stop :P

Case $Button_1;;Send Button
     GUICtrlSetState($Button_2, $GUI_ENABLE)

Fixed the Spam Type Option with:

; Get Spam Mode
If BitAND(GUICtrlRead($Radio_1), $GUI_CHECKED) = $GUI_CHECKED Then $spamfunc = "SpamUp_Text"
If BitAND(GUICtrlRead($Radio_2), $GUI_CHECKED) = $GUI_CHECKED Then $spamfunc = "SpamUp_Nudge"
If BitAND(GUICtrlRead($Radio_3), $GUI_CHECKED) = $GUI_CHECKED Then $spamfunc = "SpamUp_Combo"

And made the other change you suggested, couldn't change the last one to Else, as it's an option of three, the last being Milliseconds, so doesn't need formatting. In theory.

Your way is definately much cleaner, and doesn't rely so heavily on beating variables into submission, I was having horrible nightmares of trying to keep track of 1000's of pointless vars in a bigger script. It's a hell of a lot more understandable, especially the gui event bit, and looks like it's working a lot less to get the desired result. (It even responds better to the Stop button on faster repeat rates. Which was somewhat annoying before.)

Thanks a mil for the pointers, though I find it terribly sad that you made those changes in a few minutes, when it took me the better part of two days. Must say I expected you to scrap the whole thing though, so I'm not as bad as I thought at least. (He says as Murphy comes along and scraps the whole thing :D )

Definately given me something to think about. Oh yeah, before I go, I take it from reading your version that "If $var Then..." is the same as "If $var <> 0 Then..." or am I wrong? 'cause that would save a lot of ugly lines in my scripts ;)

Errm, one more, if I may be so bold, what's the difference between Call(FunctionX) and FunctionX()?

Thanks again for your advice,

Off to delete all my scripts and start again :D

Hmm, am I warped to be finding this so addictive?

Edited by Åmbrosius

Share this post


Link to post
Share on other sites

(He says as Murphy comes along and scraps the whole thing :D )

LOL...

"If $var Then..." is the same as "If $var <> 0 Then..." or am I wrong?

that is the idea, BUT, that is not always true. So... rather than being mis-leading

$var can represent a number of things... letters ( without a value), numbers and etc

so...

If $var <> 0 Then.

is different than

If $var <> "" Then.

Normally if $var has a value then it is true ( not always )

thus... If $var Then..

what's the difference between Call(FunctionX) and FunctionX()?

wOuter hates the use of Call()

most times you will use Function X()

the advantage of FunctionX() is addeding a $var to the function call...example

Dim $x = 10

FunctionX($x)

Func FunctionX($num)
    MsgBox(0,"Test", $num)
EndFunc

the only advantages i can think of for Call()

#1

for $x = 1 to 10

Call("Function" & $x)

Next

#2

a combobox can have a list of function names

Call(GUICtrlRead($combo))

ok... enough for now

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

TY, oh Great One.

I bow and pay homage to your superior intellect

Share this post


Link to post
Share on other sites

TY, oh Great One.

I bow and pay homage to your superior intellect

LMAO..... :D

Welcome

Valuater

8)


NEWHeader1.png

Share this post


Link to post
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
Sign in to follow this  
Followers 0