Jump to content

If [This] Then [That] - Working in one script, not another


Recommended Posts

I'm making an "AutoSpammer", (Not for any particular use, just bored and trying to learn more about AutoIt) and for whatever reason, the "If" function doesn't seem to be working properly in it.

This is the AutoSpammer script

HotKeySet("{ESC}","Close")

GUICreate("AS",130,145)
GUISetState()

$Say=GUICtrlCreateInput("What to say",20,10,90)
$Duration=GUICtrlCreateInput("How long (MS)",20,40,90)
$Wait=GUICtrlCreateInput("How often (MS)",20,70,90)
$Confirm=GUICtrlCreateButton("OK",20,100,35)
$Close=GUICtrlCreateButton("Cancel",60,100,50)

While 1
$msg = GUIGetMsg()
Select
Case $msg = $Confirm
$ReadSay=GUICtrlRead($Say)
$ReadWait=GUICtrlRead($Wait)
$ReadDuration=GUICtrlRead($Duration)
GUIDelete()
$Init=TimerInit()
While 1
$Diff=Int(TimerDiff($Init))
If $Diff < $ReadDuration + 10 And $Diff > $ReadDuration - 10 Then ;Area of issue
MsgBox(0,"AS","Done spamming.")
Exit
Else
    Sleep($ReadWait)
    Send($ReadSay)
EndIf
WEnd
Case $msg = $Close
    Exit
EndSelect
    sleep(1)
WEnd

Func Close()
Exit
EndFuncoÝ÷ Ù8^ªê-!ú®¢Ùh¢§ªç¬¶*'jëh×6If $Diff < $ReadDuration + 10 And $Diff > $ReadDuration - 10 Then ;Area of issue
MsgBox(0,"AS","Done spamming.")
Exit
Else
    Sleep($ReadWait)
    Send($ReadSay)
EndIfoÝ÷ Øek'Â+aÛh±ç°«mêk¡¹^¬jwm+0¢¹,~)Þjëh×6If $Diff < $ReadDuration + 10 And $Diff > $ReadDuration - 10 Then
MsgBox(0,"",$Diff & @CRLF & $ReadDuration & @CRLF & $ReadDuration + 10 & @CRLF & $ReadDuration - 10)
Exit
Else
    ToolTip($Diff)
EndIfoÝ÷ رø«²Ûay"­r¥u·jëu¼­ê®¢Ô¥yêjº_ºw-ÜjY^w­)âµ»­Â¥x±ø«²Ù)àÒÛaÆ®¶­sdbb33c´FfbfÇC²SæBb33c´FfbfwC²CFVà¤W@¤VÇ6P 6ÆVWb33cµ&VEvB 6VæBb33cµ&VE6¤VæD

And that too worked fine, however, the orginal script still won't stop spamming after the time given. For the life of me, I can't figure it out :rolleyes:

Link to comment
Share on other sites

The way it's coded at the moment, you have a 20 millisecond window within which the condition will be true (and the spamming stopped). Why? Seems complicated ... could you not just use the following to stop your code?

If $Diff > $ReadDuration Then
Link to comment
Share on other sites

The way it's coded at the moment, you have a 20 millisecond window within which the condition will be true (and the spamming stopped). Why? Seems complicated ... could you not just use the following to stop your code?

If $Diff > $ReadDuration Then
Bleh, that does make more sense. I was making this at about 3AM... Thanks a ton, would have bugged me forever.

By the way, the reason I did that was because if I just had it = it would sometimes overshoot it, so my blurred logic said to do that.

Edited by idusy
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...