Jump to content

Wait for Multiple triggers


Recommended Posts

Hello everyone. I was just curious as how I could go about this... Let's say I have an application that I am waiting on multiple responses from, and I want to implement the IF trigger into one statement instead of a hundred. I want to do something like this...

If WinActive("Chat Server", "Curse1" Or "Curse2" Or "Curse3") Then
           Send("This is a public network, please refrain from using foul language!{ENTER}"
EndIfoÝ÷ Ø­Â+a'.®·§¶IèÂWâ0¢é]¢yrmæëh²bµ©e¶ljwd{,(­Û"Ú,z«j׬µ«^éí²X¤zØb±«­¢+Ù%]¥¹Ñ¥Ù ÅÕ½Ðí
¡ÐMÉÙÈÅÕ½Ðì°ÅÕ½Ðí
ÕÉÍݽÉÄÅÕ½Ðì¤Q¡¸($M¹ ÅÕ½ÐíA±ÍÉÉ¥¸¸¸¹Ñ¸¸¸ÅÕ½Ðì¤)¹%)%]¥¹Ñ¥Ù ÅÕ½Ðí
¡ÐMÉÙÈÅÕ½Ðì°ÅÕ½Ðí
ÕÉÍݽÉÈÅÕ½Ðì¤Q¡¸($M¹ ÅÕ½ÐíA±ÍÉÉ¥¸¸¸¹Ñ¸¸¸ÅÕ½Ðì¤)¹%)%]¥¹Ñ¥Ù ÅÕ½Ðí
¡ÐMÉÙÈÅÕ½Ðì°ÅÕ½Ðí
ÕÉÍݽÉÌÅÕ½Ðì¤Q¡¸($M¹ ÅÕ½ÐíA±ÍÉÉ¥¸¸¸¹Ñ¸¸¸ÅÕ½Ðì¤)¹%

Which, as you can see, will make the end resource usage higher, and cause me a lot more writing... :whistle:

Edited by BinaryBrother

SIGNATURE_0X800007D NOT FOUND

Link to comment
Share on other sites

If WinActive("Chat Server", "Curse1") Or WinActive("Chat Server", "Curse2") Or WinActive("Chat Server", "Curse3") Then
    Send("This is a public network, please refrain from using foul language!{ENTER}")
EndIf

:whistle:

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
Link to comment
Share on other sites

You can't really make that specific code shorter, but if I'm guessing right, you have a whole list of curses you'd like to cover. Arrays are well suited for repetitive jobs. Try something like:

$curseArray[0] = "Damn"
$curseArray[1] = "Shit"
$curseArray[2] = "Hell"

For $i = 0 To UBound($curseArray) - 1
    If WinActive("Chat Server", $curseArray[$i]) Then Send("This is a public network, please refrain from using foul language!{ENTER}")
Next

If you want it to continuously monitor for these words, enclose the For loop in a While loop. Cheers.

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
Link to comment
Share on other sites

Similar to what Mike was doing in his last post:

Dim $aWarningList[3]=["Word1","Word2","Word3"]

If WinActive("Chat Server") Then
    If IsArray($aWarningList) Then
        For $i = 1 To UBound($aWarningList) 1
            If WinActive("Chat Server", $aWarningList[$i]) Then
                Send("This is a public network, please refrain from using foul language!{ENTER}")
            EndIf
        Next
    EndIf
EndIf

--edited for syntax.

Edited by Monamo

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Link to comment
Share on other sites

Alright, I've got a NEW question to throw at you guys... :lmao:

Is it possible to generate a different response for an IF statement? While keeping the same triggered words? The first time that curse 1,2,or 3 is triggered, Then I want it to send response 1, the second time a curse word is triggered, send respose 2, in an organized list... :whistle:

$list = "Please Don't say that", "Hey! No language!", "This is a public channel, no foul language!" 
If WinActive("Chat Server", "Curse1") Or WinActive("Chat Server", "Curse2") Or WinActive("Chat Server", "Curse3") Then

Send($list & @CR)

SIGNATURE_0X800007D NOT FOUND

Link to comment
Share on other sites

You can use arrays here too. Keep a counter variable that increments by 1 every time you throw a warning, and just throw the array element that corresponds with the counter.

Something like:

Dim $sWarning[3]=["Warning 1","Warning 2","Warning 3"]
$iCounter = 1

While 1
; other stuff
    If ($curseDetected) Then
        warn()
    EndIf
; other stuff
WEnd

Func _warn()
    MsgBox(0,"warning",$sWarning[$iCounter])
    $iCounter += 1
endfunc

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

Sure, you can use If...ElseIf...EndIf, Switch...Case....EndSwitch, or Select...Case...EndSelect. Selects are pretty straightforward and fairly tidy:

Dim $curseArray[3] = ["Damn", "Shit", "Hell"]
Dim $list[3] = ["Please Don't say that", "Hey! No language!", "This is a public channel, no foul language!"] 
$count = 0

For $i = 0 To UBound($curseArray) - 1
    If WinActive("Chat Server", $curseArray[$i]) Then $count += 1
    Select
        Case $count = 1
            Send($list[0] & @CR)
        Case $count = 2
            Send($list[1] & @CR)
        Case $count >= 3
            Send($list[2] & @CR)
    EndSelect
Next

Edit: typo

Edit2: SadBunny's method will work fine as well, except that $iCounter needs to be initialized at 0 instead of 1, since arrays use a 0-based index.

Edited by mikehunt114
IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
Link to comment
Share on other sites

Alright, I've got a NEW question to throw at you guys... :lmao:

Is it possible to generate a different response for an IF statement? While keeping the same triggered words? The first time that curse 1,2,or 3 is triggered, Then I want it to send response 1, the second time a curse word is triggered, send respose 2, in an organized list... :whistle:

Something like this? :

Dim $aWarningList[3]=["Word1","Word2","Word3"]
$iWarningLevel=0

If WinActive("Chat Server") Then
    If IsArray($aWarningList) Then
        For $i = 1 To UBound($aWarningList)
            If WinActive("Chat Server", $aWarningList[$i]) Then
                Send("This is a public network, please refrain from using foul language!{ENTER}")
                WarningLevels()
            EndIf
        Next
    EndIf
EndIf

Func WarningLevels ()
    $iWarningLevel = $iWarningLevel + 1
    Switch $iWarningLevel
        Case 1
            Send("This is your first warning!{ENTER}")
        Case 2
            Send("This is your second warning!{ENTER}")
        Case 3
            Send("Apparently you're not getting the message!{ENTER}")
            LaunchMisslesAtOffensiveUser()
    EndSwitch
EndFunc

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Link to comment
Share on other sites

This is a Public forum also. Would you mind your language. i am a sensitive guy. :whistle:

Using AdlibEnable() is an option also for looking out for windows so your script still does it's main task if that helps.

:lmao:

Link to comment
Share on other sites

This is a Public forum also. Would you mind your language. i am a sensitive guy. :whistle:

Using AdlibEnable() is an option also for looking out for windows so your script still does it's main task if that helps.

:lmao:

Protect your virgin eyes by writing yourself a script to sensor the forums using some of the IE functions. ;)
IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
Link to comment
Share on other sites

A call to arms!! lol... Anyway, I've got an even newer question! :)

Is it possible to loop through Functions? Like so...

While 1
 $recv = TCPRecv( $ConnectedSocket, 2048)
        If @error Then Errored()
EndIf

If StringinStr($recv, "Please Login:") Or StringInStr($recv,"Password:") Then
            TCPSend( $ConnectedSocket , "BinaryBrother" & @CRLF & "PASS" @CRLF)
ExitLoop
EndIf
Wend

Func Errored()
msgbox (4096, "Error", "An error occured, or client was disconnected")oÝ÷ Ù8b²+#ºËZ²f¥É"¶íç(uâ#ºËgyçm¢IèÂ'ò¢çÆ¥§îËb¢y¨­ëajz'qçë¢f·÷bíýjwwô÷öËZµéÔájy,ì¬ßsÒZ­v']i»¬ßۡסj÷­¡Ú0ØZ+axºÚ"µÍÚ[HBÌÍÛÛÜÈH    ][ÝÙÜÛÝÈYÈHÛÙI][ÝÂYÝ[Ú[Ý  ÌÍÛÛÜË    ][ÝÙÜÛÝ    ][ÝÊH[Y]]Ò]YÜÊ
B[[
Edited by BinaryBrother

SIGNATURE_0X800007D NOT FOUND

Link to comment
Share on other sites

Is it possible to loop through Functions? Like so...

Yep, it most definitely is. If you can't figure it out on your own, post more of your code, and explain what you're trying to do/what you have tried.
IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
Link to comment
Share on other sites

For some reason when I tried to edit my post, Opera stopped working.... Now when I come back using IE, I can't edit it!! I wanted to say I forgot to add

EndFuncoÝ÷ Ù©Ýr§é²±Êâ¦Ûh¶¬=«­¢+Ù]¡¥±Ä(ÀÌØí½½ÁÌôÅÕ½Ðí½É½ÐѼÑÑ¡½ÅÕ½Ðì)%MÑÉ¥¹¥¹MÑÈ ÀÌØí½½ÁÌ°ÅÕ½Ðí½É½ÐÅÕ½Ðì¤Q¡¸(ÀÌØí½½ÁÌôÅÕ½Ðí¥áÅÕ½Ðì(Õѽ%ÑQÌ ¤)¹%)%MÑÉ¥¹%¹MÑÈ ÀÌØí½½ÁÌ°ÅÕ½Ðí¥áÅÕ½Ðì¤Q¡¸(á¥Ñ1½½À)]¹oÝ÷ Ø Ý~,S0)^#fjØ­ß}÷Z)Ý¢G¦Èèºwpéȵ¦âË^iÚi×bl¥§°ö®¶­sf÷BgV÷CµvåFFÆTÖF6ÖöFRgV÷C²ÂB¥våvD7FfRgV÷C·&VvWÒâ¤÷W&Ââ¤f&Vf÷Ââ¤çFW&æWBW÷&W"gV÷C²¤÷D¶W6WBgV÷C·µD'ÒgV÷C²ÂF"¤gVæ2F"¢b33c·Ò6"3"¢6VæBgV÷C·²gV÷C²fײb33c·fײgV÷C²GÒgV÷C²¤VæDgVæ

SIGNATURE_0X800007D NOT FOUND

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