ragiroti Posted January 27, 2011 Share Posted January 27, 2011 Hi All, First of all I would like to thank the forum for helping me get familiarized with development and Autoit. My current query: I have a input box in the script which asks the user to enter the developer name $developer = InputBox("Developer Name", "Please type in the Developer Name ""<ABC> <DEF> <XYZ> <PQR>"" and click OK") If @error = 1 Then Exit ; User pressed the Cancel button and then add the entered developer name in the notepad file "Developer: " & $developer & @CRLF & _ Now, could I replace the input box with a drop-down menu, which picks the developers name from a .txt file (easier for adding/removing) and then saves and displays the selected developer name from the drop down menu in the notepad? Also will the drop down menu close when the user selects a developer name from the menu? Thanks team Link to comment Share on other sites More sharing options...
Mat Posted January 27, 2011 Share Posted January 27, 2011 You may be interested in But I imagine thats a bit too much for just that.What you want to do is the following:1. Read the file (FileRead)2. Split the file into lines (StringSplit)3. Loop through the lines adding the menu items (For ... Next, GUICtrlCreateMenuItem)Mat AutoIt Project Listing Link to comment Share on other sites More sharing options...
saywell Posted January 27, 2011 Share Posted January 27, 2011 The easiest way to do this would be to use an .ini file. [Developers] DefaultDev=Fred OtherDevs=John|Billy|Albert Then read these into variables using IniRead. $DefDev = IniRead(@ScriptDir & "\myfile.ini", "Developers", "DefDev", "NotFound") $OtherDevs = IniRead(@ScriptDir & "\myfile.ini", "Developers", "OtherDevs", "NotFound") Where $DefDef is the text that appears when the input box is created and $OhterDevs the contents of the drop-down box. William Link to comment Share on other sites More sharing options...
ragiroti Posted February 1, 2011 Author Share Posted February 1, 2011 (edited) Thanks for the replies guys, but I guess my code is not working . I am not sure if my questions was correct, hence adding the code here. In the code I would like to replace the environment text box to a drop down menu. Is that possible? If yes can I write the different possible environments in a file and could the script pick it from the file and populate the combo box? expandcollapse popup; Location of notepad++ $sNotePadProg = @ProgramFilesDir & "\Notepad++\notepad++.exe" ; Check if notepadd++ is already running $aProcessList = ProcessList("notepad++.exe") If IsArray($aProcessList) And $aProcessList[0][0] > 0 then MsgBox(0, "AAAAAAAAAAAAAaaa", "Notepad++ is still running. Please exit all notepad++ instances before running this script Bye!") Exit EndIf ;Prompt the user to run the script - use a Yes/No prompt (4 - see help file) $answer = MsgBox(4, "ABCDv0.1 (English Only)", "IMP NOTE: This script will launch Notepad++ and setup the template for AAAAAAAAAAA. Please note that the tool is still in developement phase. Run?") If Not FileExists($sNotePadProg) Then MsgBox(0, "AAAAAAAAAAAAAaaa", "Notepad++ is not installed. Bye!") Exit EndIf ; Check the user's answer to the prompt (see the help file for MsgBox return values) ; If "No" was clicked (7) then exit the script If $answer = 7 Then MsgBox(0, "AAAAAAAAAAAAAaaa", "OK. Bye!") Exit EndIf $spnumber = InputBox("YYYYYY", "Please enter the ""<1> <2> <3> <4> <5> <6>"" and click OK") If @error = 1 Then Exit ; User pressed the Cancel button $environment = InputBox("Environment", "Please type in the Environment ""<PC> <Win 7> <Win XP>"" and click OK") If @error = 1 Then Exit ; User pressed the Cancel button $iPID = Run($sNotePadProg) $Result = WinWaitActive("[CLASS:Notepad++]") $Result = ControlClick("[CLASS:Notepad++]", "", "SysTabControl325") $sString = _ "=============================================================================================================================================================" & @CRLF & _ "SSSSSS {#} " & $spnumber & @CRLF & _ "Test Sessions" & @CRLF & _ "=============================================================================================================================================================" & @CRLF & _ "Environment: " & $environment & @CRLF & _ "=============================================================================================================================================================" & @CRLF & _ "------Enter Observations/Questions Here. Please add more points if required------" & @CRLF & _ "1." & @CRLF & _ "2." & @CRLF & _ "3." & @CRLF & _ "4." & @CRLF & _ "=============================================================================================================================================================" & @CRLF & _ "=============================================================================================================================================================" & @CRLF & _ "End of Session" & @CRLF & _ "=============================================================================================================================================================" & @CRLF ClipPut($sString ) $Result = Send("^v") MsgBox(0, "YYYY", "Please ensure to fill in End Time" & @CRLF & "Please ensure to fill in Duration" & @CRLF & "At the end of the session") Thanks for all the help. Edited February 2, 2011 by ragiroti Link to comment Share on other sites More sharing options...
ragiroti Posted February 2, 2011 Author Share Posted February 2, 2011 Help or pointers pls? Thanks Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 2, 2011 Moderators Share Posted February 2, 2011 (edited) ragiroti,You can replace the 2 InputBoxes with something like this:#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIComboBox.au3> $hGUI = GUICreate("Set Parameters", 250, 160, -1, -1, $WS_CAPTION) GUICtrlCreateLabel("YYYYYY" & @CRLF & "Please enter the '<1> <2> <3> <4> <5> <6>'", 10, 10, 250, 40) $spnumber = GUICtrlCreateInput("", 10, 50, 100, 20) GUICtrlSetLimit(-1, 6) GUICtrlCreateLabel("Environment" & @CRLF & "Please choose the Environment", 10, 80, 250, 40) $environment = GUICtrlCreateCombo("", 10, 120, 100, 20) GUICtrlSetData(-1, "PC|Win 7|Win XP") GUISetState() While 1 ; Check if we have 6 chars in the input If StringLen(GUICtrlRead($spnumber)) = 6 Then ; Check if the combo has a selection and is closed If GUICtrlRead($environment) <> "" And _GUICtrlComboBox_GetDroppedState($environment) = False Then ; Get the vales in the 2 controls $spnumber = GUICtrlRead($spnumber) $environment = GUICtrlRead($environment) ; Delete the GUI GUIDelete($hGUI) ; And continue on our way ExitLoop EndIf EndIf WEnd ; Display the results MsgBox(0, "Return", "SP Number = " & $spnumber & @CRLF & "Environment = " & $environment)Points to note:- 1. The Input is limited to 6 characters - use the $ES_NUMBER style if you want to limit it to digits only.- 2. We use a function from the GUIComboBox UDF to check if the Combo is closed as well as checking if we have something in its Edit control - if not we would fire as you ran the mouse over the options. Try it and see! - 3. No need for a button - we exit the loop as soon as the 2 conditions (6 char input and combo selection) have been met.Please ask if you have any questions. M23Edit: Small(but actually quite important) code change - see below. Edited February 2, 2011 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...
Mat Posted February 2, 2011 Share Posted February 2, 2011 Melba... What does this line do Or maybe I should ask what it's meant to do. GUICreate($hGUI) AutoIt Project Listing Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 2, 2011 Moderators Share Posted February 2, 2011 Mat, Ooops! M23 P.S. It seems that today is going to be one of those days!  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...
ragiroti Posted February 3, 2011 Author Share Posted February 3, 2011 (edited) Thanks for the reply and code M23. I added the code in my script and for some reason have the following issues. 1. The UI do not exit after the values are filled in. 2. Iam not able to launch notepad++ after filling the UI. Iam sure I would have made a mistake in my code. Please correct me expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIComboBox.au3> ; Location of notepad++ $sNotePadProg = @ProgramFilesDir & "\Notepad++\notepad++.exe" ; Check if notepadd++ is already running $aProcessList = ProcessList("notepad++.exe") If IsArray($aProcessList) And $aProcessList[0][0] > 0 then MsgBox(0, "ABCD v0.1", "Notepad++ is still running. Please exit all notepad++ instances before running this script Bye!") Exit EndIf ;Prompt the user to run the script - use a Yes/No prompt (4 - see help file) $answer = MsgBox(4, "ABCD v0.1", "IMP NOTE: Please ensure that Notepad++ is installed in the directory C:\Program Files\Notepad++\notepad++.exe. Also ensure to close all files opened in Notepad++ and close Notepad ++ before running the script. Please note that the tool is still in developement phase. Run?") If Not FileExists($sNotePadProg) Then MsgBox(0, "ABCD v0.1", "Notepad++ is not installed. Bye!") Exit EndIf ; Check the user's answer to the prompt (see the help file for MsgBox return values) ; If "No" was clicked (7) then exit the script If $answer = 7 Then MsgBox(0, "ABCD v0.1", "OK. Bye!") Exit EndIf $hGUI = GUICreate("Set Parameters", 250, 160, -1, -1, $WS_CAPTION) GUICtrlCreateLabel("YYYYYY" & @CRLF & "Please enter the '<1> <2> <3> <4> <5> <6>'", 10, 10, 250, 40) $spnumber = GUICtrlCreateInput("", 10, 50, 100, 20) GUICtrlSetLimit(-1, 6) GUICtrlCreateLabel("Environment" & @CRLF & "Please choose the Environment", 10, 80, 250, 40) $environment = GUICtrlCreateCombo("", 10, 120, 100, 20) GUICtrlSetData(-1, "PC|Win 7|Win XP") GUISetState() $iPID = Run($sNotePadProg) $Result = WinWaitActive("[CLASS:Notepad++]") $Result = ControlClick("[CLASS:Notepad++]", "", "SysTabControl325") $sString = _ While 1 ; Check if we have 6 chars in the input If StringLen(GUICtrlRead($spnumber)) = 6 Then ; Check if the combo has a selection and is closed If GUICtrlRead($environment) <> "" And _GUICtrlComboBox_GetDroppedState($environment) = False Then ; Get the vales in the 2 controls $spnumber = GUICtrlRead($spnumber) $environment = GUICtrlRead($environment) ; Delete the GUI GUIDelete($hGUI) ; And continue on our way ExitLoop EndIf EndIf WEnd ; Display the results MsgBox(0, "Return", "SP Number = " & $spnumber & @CRLF & "Environment = " & $environment) "=============================================================================================================================================================" & @CRLF & _ "Sprint Number: " & $spnumber & @CRLF & _ "Exploratory Test Sessions" & @CRLF & _ "=============================================================================================================================================================" & @CRLF & _ "Environment: " & $environment & @CRLF & _ "Project: BGNE OneView" & @CRLF & _ ClipPut($sString ) $Result = Send("^v") Edited February 3, 2011 by ragiroti Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 3, 2011 Moderators Share Posted February 3, 2011 ragiroti, You have to put it in the right place: expandcollapse popup;And add this function to the script #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIComboBox.au3> ; Location of notepad++ $sNotePadProg = @ProgramFilesDir & "\Notepad++\notepad++.exe" ; Check if notepadd++ is already running $aProcessList = ProcessList("notepad++.exe") If IsArray($aProcessList) And $aProcessList[0][0] > 0 then MsgBox(0, "ABCD v0.1", "Notepad++ is still running. Please exit all notepad++ instances before running this script Bye!") Exit EndIf ;Prompt the user to run the script - use a Yes/No prompt (4 - see help file) $answer = MsgBox(4, "ABCD v0.1", "IMP NOTE: Please ensure that Notepad++ is installed in the directory C:\Program Files\Notepad++\notepad++.exe. Also ensure to close all files opened in Notepad++ and close Notepad ++ before running the script. Please note that the tool is still in developement phase. Run?") If Not FileExists($sNotePadProg) Then MsgBox(0, "ABCD v0.1", "Notepad++ is not installed. Bye!") Exit EndIf ; Check the user's answer to the prompt (see the help file for MsgBox return values) ; If "No" was clicked (7) then exit the script If $answer = 7 Then MsgBox(0, "ABCD v0.1", "OK. Bye!") Exit EndIf $hGUI = GUICreate("Set Parameters", 250, 160, -1, -1, $WS_CAPTION) GUICtrlCreateLabel("YYYYYY" & @CRLF & "Please enter the '<1> <2> <3> <4> <5> <6>'", 10, 10, 250, 40) $spnumber = GUICtrlCreateInput("", 10, 50, 100, 20) GUICtrlSetLimit(-1, 6) GUICtrlCreateLabel("Environment" & @CRLF & "Please choose the Environment", 10, 80, 250, 40) $environment = GUICtrlCreateCombo("", 10, 120, 100, 20) GUICtrlSetData(-1, "PC|Win 7|Win XP") GUISetState() While 1 ; Check if we have 6 chars in the input If StringLen(GUICtrlRead($spnumber)) = 6 Then ; Check if the combo has a selection and is closed If GUICtrlRead($environment) <> "" And _GUICtrlComboBox_GetDroppedState($environment) = False Then ; Get the vales in the 2 controls $spnumber = GUICtrlRead($spnumber) $environment = GUICtrlRead($environment) ; Delete the GUI GUIDelete($hGUI) ; And continue on our way ExitLoop EndIf EndIf WEnd $iPID = Run($sNotePadProg) $Result = WinWaitActive("[CLASS:Notepad++]") $Result = ControlClick("[CLASS:Notepad++]", "", "SysTabControl325") $sString = _ "=============================================================================================================================================================" & @CRLF & _ "Sprint Number: " & $spnumber & @CRLF & _ "Exploratory Test Sessions" & @CRLF & _ "=============================================================================================================================================================" & @CRLF & _ "Environment: " & $environment & @CRLF & _ "Project: BGNE OneView" & @CRLF ClipPut($sString ) $Result = Send("^v") All good now? M23  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...
ragiroti Posted February 3, 2011 Author Share Posted February 3, 2011 Wow, thnx so much M23. I guess this will be my last question. Appreciate all ur help If I need to add in more fields in the GUI example some more text boxes and combo box. Do I need to have an if for each of those fields? In the code below I have added the developer combo box, but I still need to add more text boxes and drop downs. So is there a trick or do I have to follow the below procedure? expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIComboBox.au3> $hGUI = GUICreate("Set Parameters", 500, 400, -1, -1, $WS_CAPTION) GUICtrlCreateLabel("YYYYYY" & @CRLF & "Please enter the '<1> <2> <3> <4> <5> <6>'", 10, 10, 250, 40) $spnumber = GUICtrlCreateInput("", 10, 50, 100, 20) GUICtrlSetLimit(-1, 6) GUICtrlCreateLabel("Environment" & @CRLF & "Please choose the Environment", 10, 80, 250, 40) $environment = GUICtrlCreateCombo("", 10, 120, 100, 20) GUICtrlSetData(-1, "PC|Win 7|Win XP") GUICtrlCreateLabel("Developer" & @CRLF & "Please choose the Developer Name", 10, 150, 250, 40) $developer = GUICtrlCreateCombo("", 10, 200, 100, 20) GUICtrlSetData(-2, "ABC|DEF|GHI|JKL|MNO|PQR") GUISetState() While 1 ; Check if we have 6 chars in the input If StringLen(GUICtrlRead($spnumber)) = 1 Then ; Check if the combo has a selection and is closed If GUICtrlRead($environment) <> "" And _GUICtrlComboBox_GetDroppedState($environment) = False Then If GUICtrlRead($developer) <> "" And _GUICtrlComboBox_GetDroppedState($developer) = False Then ; Get the vales in the 3 controls $spnumber = GUICtrlRead($spnumber) $environment = GUICtrlRead($environment) $developer = GUICtrlRead($developer) ; Delete the GUI GUIDelete($hGUI) ; And continue on our way ExitLoop EndIf EndIf EndIf WEnd ; Display the results MsgBox(0, "Return", "SP Number = " & $spnumber & @CRLF & "Environment = " & $environment & @CRLF & "Developer = " & $developer) Thank you so much Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 3, 2011 Moderators Share Posted February 3, 2011 ragiroti, This is not really a trick, but it does make the code more readable: While 1 ; Set the check to 0 $iCheck = 0 ; Check to see if all conditions met If StringLen(GUICtrlRead($spnumber)) = 6 Then $iCheck += 1 If GUICtrlRead($environment) <> "" And _GUICtrlComboBox_GetDroppedState($environment) = False Then $iCheck += 1 If GUICtrlRead($developer) <> "" And _GUICtrlComboBox_GetDroppedState($developer) = False Then $iCheck += 1 ; If we have all 3 checks we are good to go If $iCheck = 3 Then $spnumber = GUICtrlRead($spnumber) $environment = GUICtrlRead($environment) $developer = GUICtrlRead($developer) ; Delete the GUI GUIDelete($hGUI) ; And continue on our way ExitLoop EndIf WEnd All clear? M23  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...
ragiroti Posted February 7, 2011 Author Share Posted February 7, 2011 Thanks for all the help M23. I made few minor changes to the code, but then I get the error message on running the code: Invalid expression. I tried solving it on my own by going thru the forums and re-looking into each line. But I am unable to figure out the issue. Any pointers pls?expandcollapse popup;And add this function to the script #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIComboBox.au3> ; Location of notepad++ $sNotePadProg = @ProgramFilesDir & "\Notepad++\notepad++.exe" ; Check if notepadd++ is already running $aProcessList = ProcessList("notepad++.exe") If IsArray($aProcessList) And $aProcessList[0][0] > 0 then MsgBox(0, "ABCD v0.1", "Notepad++ is still running. Please exit all notepad++ instances before running this script Bye!") Exit EndIf ;Prompt the user to run the script - use a Yes/No prompt (4 - see help file) $answer = MsgBox(4, "ABCD v0.1", "IMP NOTE: Please ensure that Notepad++ is installed in the directory C:\Program Files\Notepad++\notepad++.exe. Also ensure to close all files opened in Notepad++ and close Notepad ++ before running the script. Please note that the tool is still in developement phase. Run?") If Not FileExists($sNotePadProg) Then MsgBox(0, "ABCD v0.1", "Notepad++ is not installed. Bye!") Exit EndIf ; Check the user's answer to the prompt (see the help file for MsgBox return values) ; If "No" was clicked (7) then exit the script If $answer = 7 Then MsgBox(0, "ABCD v0.1", "OK. Bye!") Exit EndIf $hGUI = GUICreate("Set Parameters", 600, 500, -1, -1, $WS_CAPTION) GUICtrlCreateLabel("YYYYYY" & @CRLF & "Please enter the '<1> <2> <3> <4> <5> <6>'", 10, 10, 250, 40) $spnumber = GUICtrlCreateInput("", 10, 50, 100, 20) GUICtrlSetLimit(-1, 6) GUICtrlCreateLabel("Environment" & @CRLF & "Please choose the Environment", 10, 80, 250, 40) $environment = GUICtrlCreateCombo("", 10, 120, 100, 20) GUICtrlSetData(-1, "PC|Win 7|Win XP") GUICtrlCreateLabel("Developer" & @CRLF & "Please choose the Developer Name", 10, 150, 250, 40) $developer = GUICtrlCreateCombo("", 20, 250, 100, 20) GUICtrlSetData(-2, "aaa|BBB|CCC|DDD|EEE|FFF") GUICtrlCreateLabel("Tester" & @CRLF & "Please choose the Tester Name", 20, 300, 250, 40) $tester = GUICtrlCreateCombo("", 20, 360, 100, 20) GUICtrlSetData(-3, "GGG|HHH|III|JJJ") GUICtrlCreateLabel("Date" & @CRLF & "Please enter the date in the following format 'dd-mm-yyyy'", 10, 360, 250, 40) $date = GUICtrlCreateInput("", 10, 420, 100, 20) GUICtrlSetLimit(-4, 10) GUISetState() While 1 ; Set the check to 0 $iCheck = 0 ; Check to see if all conditions met If StringLen(GUICtrlRead($spnumber)) = 1 And StringLen(GUICtrlRead($date)) = 10 Then $iCheck += 1 If GUICtrlRead($environment) <> "" And _GUICtrlComboBox_GetDroppedState($environment) = False Then $iCheck += 1 If GUICtrlRead($developer) <> "" And _GUICtrlComboBox_GetDroppedState($developer) = False Then $iCheck += 1 If GUICtrlRead($tester) <> "" And _GUICtrlComboBox_GetDroppedState($tester) = False Then $iCheck += 1 ; If we have all 3 checks we are good to go If $iCheck = 4 Then $spnumber = GUICtrlRead($spnumber) $environment = GUICtrlRead($environment) $developer = GUICtrlRead($developer) $tester = GUICtrlRead($tester) $date = GUICtrlRead($date) ; Delete the GUI GUIDelete($hGUI) ; And continue on our way ExitLoop EndIf WEnd $iPID = Run($sNotePadProg) $Result = WinWaitActive("[CLASS:Notepad++]") $Result = ControlClick("[CLASS:Notepad++]", "", "SysTabControl325") $sString = _ "=============================================================================================================================================================" & @CRLF & _ "Sprint Number: " & $spnumber & @CRLF & _ "Exploratory Test Sessions" & @CRLF & _ "=============================================================================================================================================================" & @CRLF & _ "Environment: " & $environment & @CRLF & _ "Developer: " & $developer & @CRLF & _ "Project: aaaaaaaaaaaa" & @CRLF & _ "Tester: " & $tester & @CRLF & _ "Date: " & $date & @CRLF & _ ClipPut($sString ) $Result = Send("^v") Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 7, 2011 Moderators Share Posted February 7, 2011 ragiroti,The only error I get is from the final line of your string - which should read:"Date: " & $date & @CRLFI have amended your condition code so that you need to enter the correct format for the date rather than just 10 characters: While 1 ; Set the check to 0 $iCheck = 0 ; Check to see if all conditions met If StringLen(GUICtrlRead($spnumber)) = 6 Then $iCheck += 1 ; You need 6 here - you only had 1 <<<<<<<<<<<<<<<<<<<<<<<<<<<< If GUICtrlRead($environment) <> "" And _GUICtrlComboBox_GetDroppedState($environment) = False Then $iCheck += 1 If GUICtrlRead($developer) <> "" And _GUICtrlComboBox_GetDroppedState($developer) = False Then $iCheck += 1 If GUICtrlRead($tester) <> "" And _GUICtrlComboBox_GetDroppedState($tester) = False Then $iCheck += 1 If StringRegExp(GUICtrlRead($date), "\d{2}-\d{2}-\d{4}") Then $iCheck += 1 ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ; If we have all 5 checks we are good to go If $iCheck = 5 Then $spnumber = GUICtrlRead($spnumber) $environment = GUICtrlRead($environment) $developer = GUICtrlRead($developer) $tester = GUICtrlRead($tester) $date = GUICtrlRead($date) ; Delete the GUI GUIDelete($hGUI) ; And continue on our way ExitLoop EndIf WEndFinally, when you create the controls, -1 is shorthand for the last control created. So you do not need to enumerate -2, -3, -4 etc. As you can see, AutoIt will understand any negative number to mean the "the last control created", but you will confuse anyone trying to read the code. This is how it should read:GUICtrlCreateLabel("YYYYYY" & @CRLF & "Please enter the '<1> <2> <3> <4> <5> <6>'", 10, 10, 250, 40) $spnumber = GUICtrlCreateInput("", 10, 50, 100, 20) GUICtrlSetLimit(-1, 6) GUICtrlCreateLabel("Environment" & @CRLF & "Please choose the Environment", 10, 80, 250, 40) $environment = GUICtrlCreateCombo("", 10, 120, 100, 20) GUICtrlSetData(-1, "PC|Win 7|Win XP") GUICtrlCreateLabel("Developer" & @CRLF & "Please choose the Developer Name", 10, 150, 250, 40) $developer = GUICtrlCreateCombo("", 10, 190, 100, 20) GUICtrlSetData(-1, "aaa|BBB|CCC|DDD|EEE|FFF") GUICtrlCreateLabel("Tester" & @CRLF & "Please choose the Tester Name", 10, 220, 250, 40) $tester = GUICtrlCreateCombo("", 10, 260, 100, 20) GUICtrlSetData(-1, "GGG|HHH|III|JJJ") GUICtrlCreateLabel("Date" & @CRLF & "Please enter the date in the following format 'dd-mm-yyyy'", 10, 290, 250, 40) $date = GUICtrlCreateInput("", 10, 340, 100, 20) GUICtrlSetLimit(-1, 10)You may notice that I tidied up the layout a bit. All good now? M23  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...
ragiroti Posted February 7, 2011 Author Share Posted February 7, 2011 (edited) Thanks for all the help M23. Now I have the code in place thanks to your guidance. But, when I run it I get the same error. I have attached a screen shot of the error. Is there a new version I should be using? Below is the code I am running with your changes added expandcollapse popup;And add this function to the script #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIComboBox.au3> ; Location of notepad++ $sNotePadProg = @ProgramFilesDir & "\Notepad++\notepad++.exe" ; Check if notepadd++ is already running $aProcessList = ProcessList("notepad++.exe") If IsArray($aProcessList) And $aProcessList[0][0] > 0 then MsgBox(0, "ABCD v0.1", "Notepad++ is still running. Please exit all notepad++ instances before running this script Bye!") Exit EndIf ;Prompt the user to run the script - use a Yes/No prompt (4 - see help file) $answer = MsgBox(4, "ABCD v0.1", "IMP NOTE: Please ensure that Notepad++ is installed in the directory C:\Program Files\Notepad++\notepad++.exe. Also ensure to close all files opened in Notepad++ and close Notepad ++ before running the script. Please note that the tool is still in developement phase. Run?") If Not FileExists($sNotePadProg) Then MsgBox(0, "ABCD v0.1", "Notepad++ is not installed. Bye!") Exit EndIf ; Check the user's answer to the prompt (see the help file for MsgBox return values) ; If "No" was clicked (7) then exit the script If $answer = 7 Then MsgBox(0, "ABCD v0.1", "OK. Bye!") Exit EndIf $hGUI = GUICreate("Set Parameters", 600, 500, -1, -1, $WS_CAPTION) GUICtrlCreateLabel("YYYYYY" & @CRLF & "Please enter the '<1> <2> <3> <4> <5> <6>'", 10, 10, 250, 40) $spnumber = GUICtrlCreateInput("", 10, 50, 100, 20) GUICtrlSetLimit(-1, 6) GUICtrlCreateLabel("Environment" & @CRLF & "Please choose the Environment", 10, 80, 250, 40) $environment = GUICtrlCreateCombo("", 10, 120, 100, 20) GUICtrlSetData(-1, "PC|Win 7|Win XP") GUICtrlCreateLabel("Developer" & @CRLF & "Please choose the Developer Name", 10, 150, 250, 40) $developer = GUICtrlCreateCombo("", 10, 190, 100, 20) GUICtrlSetData(-1, "aaa|BBB|CCC|DDD|EEE|FFF") GUICtrlCreateLabel("Tester" & @CRLF & "Please choose the Tester Name", 10, 220, 250, 40) $tester = GUICtrlCreateCombo("", 10, 260, 100, 20) GUICtrlSetData(-1, "GGG|HHH|III|JJJ") GUICtrlCreateLabel("Date" & @CRLF & "Please enter the date in the following format 'dd-mm-yyyy'", 10, 290, 250, 40) $date = GUICtrlCreateInput("", 10, 340, 100, 20) GUICtrlSetLimit(-1, 10) GUISetState() While 1 ; Set the check to 0 $iCheck = 0 ; Check to see if all conditions met If StringLen(GUICtrlRead($spnumber)) = 6 Then $iCheck += 1 ; You need 6 here - you only had 1 <<<<<<<<<<<<<<<<<<<<<<<<<<<< If GUICtrlRead($environment) <> "" And _GUICtrlComboBox_GetDroppedState($environment) = False Then $iCheck += 1 If GUICtrlRead($developer) <> "" And _GUICtrlComboBox_GetDroppedState($developer) = False Then $iCheck += 1 If GUICtrlRead($tester) <> "" And _GUICtrlComboBox_GetDroppedState($tester) = False Then $iCheck += 1 If StringRegExp(GUICtrlRead($date), "\d{2}-\d{2}-\d{4}") Then $iCheck += 1 ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ; If we have all 5 checks we are good to go If $iCheck = 5 Then $spnumber = GUICtrlRead($spnumber) $environment = GUICtrlRead($environment) $developer = GUICtrlRead($developer) $tester = GUICtrlRead($tester) $date = GUICtrlRead($date) ; Delete the GUI GUIDelete($hGUI) ; And continue on our way ExitLoop EndIf WEnd $iPID = Run($sNotePadProg) $Result = WinWaitActive("[CLASS:Notepad++]") $Result = ControlClick("[CLASS:Notepad++]", "", "SysTabControl325") $sString = _ "=============================================================================================================================================================" & @CRLF & _ "Sprint Number: " & $spnumber & @CRLF & _ "Exploratory Test Sessions" & @CRLF & _ "=============================================================================================================================================================" & @CRLF & _ "Environment: " & $environment & @CRLF & _ "Developer: " & $developer & @CRLF & _ "Project: aaaaaaaaaaaa" & @CRLF & _ "Tester: " & $tester & @CRLF & _ "Date: " & $date & @CRLF & _ ClipPut($sString ) $Result = Send("^v") Edited February 7, 2011 by ragiroti Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 7, 2011 Moderators Share Posted February 7, 2011 ragiroti,You still have not adjusted the final line of your string as I suggested above. It should read:"Date: " & $date & @CRLFAt the moment you haver a superfluous "& _" which gives me an error when I try to run the code you just posted - although I do not get the same error message as you. Amend that and try again. M23  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...
ragiroti Posted February 8, 2011 Author Share Posted February 8, 2011 (edited) Pardon me for missing that out. The script works fantastic thanks to you. I have added more fields in the GUI and also using your scroll bar. The scroll bar code is great. One small query - could a text box be validated to exit when the value in the text box is less than or equal to 60? I tried the below condition, but it does not seem to work. Is there an other way to do it? If StringLen(GUICtrlRead($mission)) <= 60 Appreciate all your help M23 Edited February 8, 2011 by ragiroti Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 8, 2011 Moderators Share Posted February 8, 2011 ragiroti, What you have should work - but it seems like an interesting condition to meet, normally you exit when you have more than a certain number, not less! If you could explain a little more what exactly is going on while waiting for the conditon to be met, I might be able to offer more concrete help. M23  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...
ragiroti Posted February 8, 2011 Author Share Posted February 8, 2011 what I have in mind is to ask user to add in a line in the text box for example "what are you testing in this build?". The user is free to enter any characters, integers or symbols in the text box example "The purpose of the test is to verify the if x saves the values in the DB -> also very load" I am still unsure if 60 is good number to limit the number of characters or to increase it to say 240. I would like the script to exit the same way as the other input boxes in the script. Hope I have provided enough information. Please let me know if you need more info. Link to comment Share on other sites More sharing options...
ragiroti Posted February 8, 2011 Author Share Posted February 8, 2011 This is what flashed to me, this might be trivial but is there a way to capture the enter key stroke?. The user could punch in the line he/she wishes to enter and then on hitting the enter key on the Keyboard the script could exit? If this is possible I could have a minimum length and a maximum length defined for the input box. Just thinking.... 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