joedamoe Posted March 1, 2010 Share Posted March 1, 2010 (edited) expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 414, 88, 192, 124) $TextInput = GUICtrlCreateInput("TextInput", 8, 8, 393, 30) GUICtrlSetFont($TextInput, 12, 800, 0, "Palatino Linotype") $Start = GUICtrlCreateButton("Start", 240, 40, 163, 41, $WS_GROUP) $Label1 = GUICtrlCreateLabel("Deley (miniseconds):", 8, 56, 101, 17) $Delay = GUICtrlCreateInput("Delay", 112, 56, 121, 21) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Global $Paused HotKeySet("{ESC}", "stop") Func stop() $i = 0 EndFunc ;==>stop GUISetState() $msg = GUIGetMsg() Select case $msg = $Start $i = 1 EndSelect While $i = 0 Sleep(1000) WEnd While $i = 1 Send($TextInput, 0) Sleep($Delay) WEnd im sure the solution is simple but i have no idea what it is :S Edited March 1, 2010 by joedamoe Link to comment Share on other sites More sharing options...
99ojo Posted March 1, 2010 Share Posted March 1, 2010 (edited) Hi,1) You are messing around with your while loops.2) Your Send will send the ControlID of your Inputfield to the active window (see helpfile GUICtrlCreateInput () AND Send ()). Doesn't make sense at all. You might want to send the Data of The Input Field.Send(GUICtrlRead ($TextInput), 0) -> This will send the data of the input to active window.3) You might use WinActivate () to activate a specific window before send -> see helpfile for further information.Heres some code you could go on:#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $Paused, $run = FALSE HotKeySet("{ESC}", "stop") #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 414, 88, 192, 124) $TextInput = GUICtrlCreateInput("TextInput", 8, 8, 393, 30) GUICtrlSetFont($TextInput, 12, 800, 0, "Palatino Linotype") $Start = GUICtrlCreateButton("Start", 240, 40, 163, 41, $WS_GROUP) $Label1 = GUICtrlCreateLabel("Deley (miniseconds):", 8, 56, 101, 17) $Delay = GUICtrlCreateInput("Delay", 112, 56, 121, 21) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Start $run = True EndSwitch If $run Then Send($TextInput, 0); more sense see the remarks above or Melba23's post Sleep(GUICtrlRead ($Delay)) EndIf WEnd Func stop() $run = False EndFunc ;==>stop;-))Stefan@Edit: @Melba23: I missed the GUICtrlRead for $delay. Thanks for further explanation. Edited March 1, 2010 by 99ojo Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 1, 2010 Moderators Share Posted March 1, 2010 (edited) joedamow,Welcome to the AutoIt forum. I have played around with your script and it now works as I think you want it (except that I have it writing in the SciTE console rather than Sending to another window):expandcollapse popup#include <GUIConstantsEx.au3> HotKeySet("{ESC}", "_Stop") Global $Paused = 1 $Form1 = GUICreate("Form1", 414, 88, 192, 124) $TextInput = GUICtrlCreateInput("TextInput", 8, 8, 393, 30) GUICtrlSetFont($TextInput, 12, 800, 0, "Palatino Linotype") $Start = GUICtrlCreateButton("Start", 240, 40, 163, 41) $Label1 = GUICtrlCreateLabel("Delay (milliseconds):", 8, 56, 101, 17) $Delay = GUICtrlCreateInput("Delay", 112, 56, 121, 21) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Start $Paused = 0 _Run() EndSwitch WEnd Func _Stop() $Paused = 1 EndFunc ;==>stop Func _Run() While $Paused = 0 ConsoleWrite(GUICtrlRead($TextInput) & @CRLF) Sleep(Number(GUICtrlRead($Delay))) WEnd EndFuncThe major changes:1. You need to have a Case for the button in your While...WEnd loop so AutoIt can see when it is actioned.2. You need some code to run when the button is pressed - here I have used the function _Run.3. This function runs while $Paused = 0. The HotKey sets $Paused to 1 and so stops the function.4. You need to use GUICtrlRead to get the contents of the 2 inputs.5. You had far too many loops!I hope that is all clear - please ask if not. Given your evident lack of coding experience (not a problem - we all started there ) you will find that reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) helps you enormously. You should also look at the excellent tutorials that you will find here and here. There are even video tutorials on YouTube if you prefer watching to reading.I know you want to start coding NOW, but a little study will save you a lot of trouble later on, believe me. M23Edit: Typnig! Edited March 1, 2010 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
joedamoe Posted March 1, 2010 Author Share Posted March 1, 2010 some really useful tips from you both, thanks guys. 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