nf67 Posted March 10, 2008 Share Posted March 10, 2008 (edited) Hello there, I am trying to make a WaveMaker for MSN, it sends the text you type in the inputfield to the other person with increasing ( and later decreasing ) numbers of spaces. This creates a funny "waving" effect. Now I can't really get the Stop button to work, please help: expandcollapse popup#include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 312, 61, 193, 125) $Text = GUICtrlCreateInput("texttotype", 8, 8, 297, 21) $Spam = GUICtrlCreateButton("Spam", 208, 32, 99, 25, 0) $Stop = GUICtrlCreateButton("Stop", 8, 32, 49, 17) $StopValue = 0; Stopvalue starts below 1 for the Spam Loop AutoItSetOption ( "SendKeyDelay", 1 ) GUISetState(@SW_SHOW) #EndRegion ### START Koda GUI section ### Form= While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Spam Sleep ( 5000 ) ; Time to put cursor somewhere While $StopValue <= 1; Loop from here to WEnd if StopValue is below 1 Send(GUICtrlRead($Text)) ;Start of the wave effect ( not important for problem ) Send("{ENTER}") Send("{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}{SPACE}{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}{SPACE}{SPACE}{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}{SPACE}{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") ;End of the wave effect ( not important for problem ), should start at begin again. WEnd ;End of the loop from While Case $Stop ; If $Stop is pressed $StopValue = 2 ; Make $StopValue more than 1 to break the Spam Loop EndSwitch WEnd Thanks a lot! Chris Edited March 10, 2008 by nf67 Link to comment Share on other sites More sharing options...
nf67 Posted March 10, 2008 Author Share Posted March 10, 2008 Oh yeah, the description behind the ; describes my actual problem in detail Link to comment Share on other sites More sharing options...
spudw2k Posted March 10, 2008 Share Posted March 10, 2008 (edited) The problem is you're starting a new Loop within the While statement for gathering GuiGetMSG, so it never gets back to GuiGetMSG. Make the wave part of the first While Loop rather than start a new one. Here's how I would do it. expandcollapse popup#include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 312, 61, 193, 125) $Text = GUICtrlCreateInput("texttotype", 8, 8, 297, 21) $Spam = GUICtrlCreateButton("Spam", 208, 32, 99, 25, 0) $Stop = GUICtrlCreateButton("Stop", 8, 32, 49, 17) $StopValue = 1; AutoItSetOption ( "SendKeyDelay", 1 ) GUISetState(@SW_SHOW) #EndRegion ### START Koda GUI section ### Form= While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Spam $StopValue = 0 Case $Stop $StopValue = 1 EndSwitch If $StopValue = 0 Then Sleep ( 5000 ) Send(GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}{SPACE}{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}{SPACE}{SPACE}{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}{SPACE}{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") EndIf WEnd Edited March 10, 2008 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
nf67 Posted March 11, 2008 Author Share Posted March 11, 2008 That doesn't work actually... it also includes the sleep 5000 in the loop, it should only wait once. Thanks anyway Link to comment Share on other sites More sharing options...
LinuZ Posted March 11, 2008 Share Posted March 11, 2008 Test a FOR TO STEP NEXT loop like this: expandcollapse popup#include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 312, 61, 193, 125) $Text = GUICtrlCreateInput("texttotype", 8, 8, 297, 21) $Spam = GUICtrlCreateButton("Spam", 208, 32, 99, 25, 0) $Stop = GUICtrlCreateButton("Stop", 8, 32, 49, 17) $StopValue = 0; Stopvalue starts below 1 for the Spam Loop AutoItSetOption ( "SendKeyDelay", 1 ) GUISetState(@SW_SHOW) #EndRegion ### START Koda GUI section ### Form= While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Spam Sleep ( 5000 ) ; Time to put cursor somewhere FOR $loop = $StopValue TO 1 STEP 1 ;;This starts the loop from $StopValue, and sets +1 every "round" until it reaches 1 Send(GUICtrlRead($Text)) ;Start of the wave effect ( not important for problem ) Send("{ENTER}") Send("{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}{SPACE}{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}{SPACE}{SPACE}{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}{SPACE}{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") ;End of the wave effect ( not important for problem ), should start at begin again. NEXT ;;NEXT Case $Stop ; If $Stop is pressed $StopValue = 2 ; Make $StopValue more than 1 to break the Spam Loop EndSwitch WEnd Link to comment Share on other sites More sharing options...
nf67 Posted March 11, 2008 Author Share Posted March 11, 2008 Yeah I did something like that with Do... Until, but I want to be able to do the +1 ( or whatever numnber ) manually, with the stop button for example. Link to comment Share on other sites More sharing options...
nf67 Posted March 11, 2008 Author Share Posted March 11, 2008 So the actual target is: If I press Spam ; WorksType the message from $Text and keep doing this endlessly ;WorksStop the endless message typing loop when Stop is pressed ;Does not work Link to comment Share on other sites More sharing options...
spudw2k Posted March 11, 2008 Share Posted March 11, 2008 How about a hotkey instead? Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
LinuZ Posted March 11, 2008 Share Posted March 11, 2008 Yes a hotkey would do it, but it doesnt just look professional. You could try with putting the spam in one process (another exe), and kill it when you need to stop (it isnt that profession either). Or add another GUI that can handle it, and then control it with the mainGUI. Link to comment Share on other sites More sharing options...
nf67 Posted March 11, 2008 Author Share Posted March 11, 2008 (edited) Would that be: HotKeySet ( {ESC}, Terminate ) or HotKeySet ( {ESC}, TogglePause ) ? Please correct me if both things are wrong, there is no AutoIt on this PC, nor a help file. Thanks P.S: What about HotKey -> Scriptpause ----&---- Button -> Hotkey ( which pauses the script ) Edited March 11, 2008 by nf67 Link to comment Share on other sites More sharing options...
newbiescripter Posted March 11, 2008 Share Posted March 11, 2008 You can setup the hotkeys like this. HotKeySet ("{ESC}", "Terminate") Func Terminate() If MsgBox(4,"Exit","Are you sure you want to exit?") = 6 Then Exit 0 EndIf EndFunc HotKeySet("p", "Pausenow") Func Pausenow() MsgBox(0,"Paused","The program is now paused. Press OK to start again") Do Sleep(500) Until 1 EndFunc I havent tested this, sorry, just created it in notepad.. but hope it works for you Regards Link to comment Share on other sites More sharing options...
LinuZ Posted March 12, 2008 Share Posted March 12, 2008 (edited) Hey I got it! It was bugging me that I couldn't do the script working as you wanted it to do so this is how you stop the loop with the button: expandcollapse popup#include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 312, 61, 193, 125) $Text = GUICtrlCreateInput("texttotype", 8, 8, 297, 21) $Spam = GUICtrlCreateButton("Spam", 208, 32, 99, 25, 0) $Stop = GUICtrlCreateButton("Stop", 8, 32, 49, 17) $StopValue = 0; Stopvalue starts below 1 for the Spam Loop AutoItSetOption ( "SendKeyDelay", 1 ) GUISetState(@SW_SHOW) #EndRegion ### START Koda GUI section ### Form= While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Spam Sleep ( 5000 ) ; Time to put cursor somewhere While $StopValue <= 1; Loop from here to WEnd if StopValue is below 1 $nMsg = GUIGetMsg() If $nMsg = $Stop Then ExitLoop ;HEUREKA :P Send(GUICtrlRead($Text)) ;Start of the wave effect ( not important for problem ) Send("{ENTER}") Send("{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}{SPACE}{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}{SPACE}{SPACE}{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}{SPACE}{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") Send("{SPACE}" & GUICtrlRead($Text)) Send("{ENTER}") ;End of the wave effect ( not important for problem ), should start at begin again. WEnd ;End of the loop from While Case $Stop ; If $Stop is pressed $StopValue = 2 ; Make $StopValue more than 1 to break the Spam Loop EndSwitch WEnd $nMsg = GUIGetMsg() If $nMsg = $Stop Then ExitLoop = was added in the spam loop, I hope it works! (I cant test it on this computer) Edited March 12, 2008 by LinuZ Link to comment Share on other sites More sharing options...
newbiescripter Posted March 12, 2008 Share Posted March 12, 2008 (edited) Yes LinuZ that's better than the hotkeys.. well nf67 I would might have send the text from the input raw or else it would crash when you insert something like ! What I would do is: expandcollapse popup#include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 312, 61, 193, 125) $Text = GUICtrlCreateInput("texttotype", 8, 8, 297, 21) $Spam = GUICtrlCreateButton("Spam", 208, 32, 99, 25, 0) $Stop = GUICtrlCreateButton("Stop", 8, 32, 49, 17) $StopValue = 0; Stopvalue starts below 1 for the Spam Loop AutoItSetOption ( "SendKeyDelay", 1 ) GUISetState(@SW_SHOW) #EndRegion ### START Koda GUI section ### Form= While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Spam Sleep ( 5000 ) ; Time to put cursor somewhere While $StopValue <= 1; Loop from here to WEnd if StopValue is below 1 $nMsg = GUIGetMsg() If $nMsg = $Stop Then ExitLoop ;HEUREKA Send(GUICtrlRead($Text),1) ;Start of the wave effect ( not important for problem ) Send("{ENTER}") Send(" " & GUICtrlRead($Text),1) ; 2spaces Send("{ENTER}") Send(" " & GUICtrlRead($Text),1) ;4 spaces Send("{ENTER}") Send(" " & GUICtrlRead($Text),1) ;6 spaces Send("{ENTER}") Send(" " & GUICtrlRead($Text),1) ;8 spaces Send("{ENTER}") Send(" " & GUICtrlRead($Text),1) ;10 spaces Send("{ENTER}") Send(" " & GUICtrlRead($Text),1) ;12 spaces Send("{ENTER}") Send(" " & GUICtrlRead($Text),1) ;10 spaces Send("{ENTER}") Send(" " & GUICtrlRead($Text),1) ;8 spaces Send("{ENTER}") Send(" " & GUICtrlRead($Text),1) ;6 spaces Send("{ENTER}") Send(" " & GUICtrlRead($Text),1) ;4 spaces Send("{ENTER}") Send(" " & GUICtrlRead($Text),1) ; 2 spaces Send("{ENTER}") ;End of the wave effect ( not important for problem ), should start at begin again. WEnd ;End of the loop from While Case $Stop ; If $Stop is pressed $StopValue = 2 ; Make $StopValue more than 1 to break the Spam Loop EndSwitch WEndoÝ÷ Ù.q©í¯+^²Ü¨ºº0©÷Þ)ì×Ûaz{{Z¶©¥éìjwméí¯+aƧvÇ°«b²©¥éâ^ªÝ°@ÈLò¢çhm)¶ÛazÊZqë+k¨¹Æ§j[(vbëaÆ®¶se6VæBgV÷C·´TåDU'ÒgV÷C²¥6VæBgV÷C·µ54W×µ54WÒgV÷C²¥6VæBuT7G&Å&VBb33cµFWBà Edited March 12, 2008 by newbiescripter Link to comment Share on other sites More sharing options...
FreeFry Posted March 12, 2008 Share Posted March 12, 2008 (edited) The problem here is that you're doing alot of other stuff while also trying to handle the gui, that's why the stop button doesn't "work".To get around this, you could do like LinuZ did in his code, but it would still not be really responsive(as it only checks if stop was pressed before executing all the sends, etc.),the other solution is using GUIOnEventMode(look at Opt in the helpfile), or perhaps(if you would like to take it that far) create a separate script that does the Sending. Good LuckEdit:Also$nMsg = GUIGetMsg() If $nMsg = $Stop Then ExitLoop;HEUREKA tongue.gifCould be shortened toIf GUIGetMsg() = $Stop Then ExitLoop Edited March 12, 2008 by FreeFry Link to comment Share on other sites More sharing options...
LinuZ Posted March 12, 2008 Share Posted March 12, 2008 Yes, now when I tested the code I see my example must complete the While loop to stop, and it is not so handy :/ Hey FreeFry (föresten e jag finlandsvensk ) if I add the Opt (GUIOnEventMode, 1), I cant control the GUI at all it doesnt respond to me, not even when closing it. Why? Thanks/Tack Link to comment Share on other sites More sharing options...
FreeFry Posted March 12, 2008 Share Posted March 12, 2008 Hehe, jag föredrar o ha diskussionen på engelska, eftersom då kan andra lära sej utav det man surrar om. // Swedish Anyways, when you're using GUIOnEventMode, you also have to use GUICtrlSetOnEvent, and GUISetOnEvent to 'handle' the gui instead(no need to use GUIGetMsg) As stated in the helpfile: If the GUIOnEventMode option is set to 1 then the return from GUIGetMsg is always 0 and the @error is set to 1. I suggest you have a look in the helpfile regarding GUICtrlSetOnEvent and GUISetOnEvent, it's explained there how to use it. Link to comment Share on other sites More sharing options...
nf67 Posted March 12, 2008 Author Share Posted March 12, 2008 Linuz script works after his edit :-) that was indeed the "magic missing piece" I was looking for. It still finishes the loop after pressing stop but I really don't care about that. I'll edit the stopvalue crap so it can Spam again after pressing stop ( right now stop also raises the StopValue and it won't loop when it's > 1 ). FreeFry, have you also watched DeathNote? Link to comment Share on other sites More sharing options...
FreeFry Posted March 12, 2008 Share Posted March 12, 2008 (edited) okidaay..No I haven't watched DeathNote, what is it about? Edited March 12, 2008 by FreeFry Link to comment Share on other sites More sharing options...
LinuZ Posted March 12, 2008 Share Posted March 12, 2008 (edited) Hehe, jag föredrar o ha diskussionen på engelska, eftersom då kan andra lära sej utav det man surrar om. // Swedish[swedish]Samma här, dessutom passar termerna bättre [/swedish] Thanks! I havent used it before, but I will try it now. Nice explanation. No I haven't watched DeathNote, what is it about? Surely something alike Bleach from your sig. Edited March 12, 2008 by LinuZ Link to comment Share on other sites More sharing options...
DW1 Posted March 12, 2008 Share Posted March 12, 2008 (edited) EDIT: Code worked fine for me, but others had issues, see last post for working code. removed Edited March 12, 2008 by danwilli AutoIt3 Online Help Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now