Ginga Posted November 17, 2015 Share Posted November 17, 2015 Hi!I'm new to scripting, so bare with me.I want to be able to find a word by typing series of letters in different inputboxes which correspond to different placements in a speciffic word and then print it to an editbox or msgbox. for instance: in Inputbox1 I will type in "a,g,e,b,c,s,t" In Inputbox2 I will type in "p,y,f,a,t,k" And in Inputbox3 I will type in "y,f,u,r,s,g"It should then be able to check each inputbox and see which character fits in each placement of the set word"car" is a word that could be spelled out using the "c" in Inputbox1, the "a" in Inputbox2 and the "r" in Inputbox3.But if another word i have set is "cat", then the search will not find it because there is no "t" in inputbox3.If it finds multiple solutions from my list of words it should give me those as well. I have been searching for a solution in the Help archive for AutoIt, the forums and many other places, but I can't find any.Any thoughts of how I can make it work? Link to comment Share on other sites More sharing options...
ViciousXUSMC Posted November 17, 2015 Share Posted November 17, 2015 So you want a user to choose from given letters, if the letters are proper then give the word.If they use a letter that is not an option then it gives an error? To do this "right" use a GUI instead of input boxes and use input validation.Else you can use If Statements to check if users selected valid letters and just concatenate them together for your final word.I am not aware of any dictionary function to check if a word is valid or not. Link to comment Share on other sites More sharing options...
guestscripter Posted November 17, 2015 Share Posted November 17, 2015 You're trying to solve anagrams, right? ImageSearch15.au3 featuring _ImageSearchStartup() and _ImageSearchShutdown() Link to comment Share on other sites More sharing options...
ViciousXUSMC Posted November 17, 2015 Share Posted November 17, 2015 (edited) This is just my idea of what I think you want to do, there are a million ways to do it.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("Test Words", 511, 214, 192, 124) $Label1 = GUICtrlCreateLabel("First Letter: Choose a, g, e, b, c, s, t", 8, 8, 293, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Label2 = GUICtrlCreateLabel("Second Letter: Choose p, y , f, a, t, k", 8, 72, 298, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Label3 = GUICtrlCreateLabel("Third Letter: Choose y, f, u r, s, g", 8, 144, 267, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input1 = GUICtrlCreateInput("", 8, 32, 297, 21) $Input2 = GUICtrlCreateInput("", 8, 104, 297, 21) $Input3 = GUICtrlCreateInput("", 8, 176, 297, 21) $Button1 = GUICtrlCreateButton("GO!", 344, 48, 123, 113) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 Sleep(10) $sI1 = GUICtrlRead($Input1) $sI2 = GUICtrlRead($Input2) $sI3 = GUICtrlRead($Input3) $Validate1 = StringRegExpReplace($sI1, "([^agebcst]+)", "") $Validate2 = StringRegExpReplace($sI2, "([^pyfatk]+)", "") $Validate3 = StringRegExpReplace($sI3, "([^yfursg]+)", "") GUICtrlSetData($Input1, $Validate1) GUICtrlSetData($Input2, $Validate2) GUICtrlSetData($Input3, $Validate3) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 ExitLoop EndSwitch WEnd MsgBox(0, "", $sI1 & $sI2 & $sI3)Edit: Oh he wants to look up dictionary stuff eh? Tons of free sites for that stuff. I was under the impression this would be for kids to learn or something or just for the sake of code experience how to limit characters and form words from separate input boxes.Oh well I see the RegExReplace() works really well as input validation, never tried it before was an idea I had. Edited November 17, 2015 by ViciousXUSMC Link to comment Share on other sites More sharing options...
Ginga Posted November 17, 2015 Author Share Posted November 17, 2015 (edited) Here's a test of my GUI Test.au3The issue I'm having is that i can't find a way to check if only one letter in the inputboxes matches. If i type in "random" in four inputboxes, and one of my words are "dorm" it should check all inputboxes, one by one, if it has the corresponding letters to spell out the word.also if there are more combinations that fit any other word in my list, it should show them in the inputbox as well.*English isn't my first language, so if I'm not formulating my self right as of what I want from my script i will try to explain it better Edited November 17, 2015 by Ginga Link to comment Share on other sites More sharing options...
Ginga Posted November 17, 2015 Author Share Posted November 17, 2015 Btw, how do you put your script in the post/reply like you did?; noob alert Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 17, 2015 Moderators Share Posted November 17, 2015 Ginga,When you want to post code you should use Code tags - see here how to do it. Then you get a scrolling box and syntax colouring as you can see in the above posts.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...
guestscripter Posted November 18, 2015 Share Posted November 18, 2015 Here's a test of my GUI Test.au3The issue I'm having is that i can't find a way to check if only one letter in the inputboxes matches. If i type in "random" in four inputboxes, and one of my words are "dorm" it should check all inputboxes, one by one, if it has the corresponding letters to spell out the word.also if there are more combinations that fit any other word in my list, it should show them in the inputbox as well.*English isn't my first language, so if I'm not formulating my self right as of what I want from my script i will try to explain it better The way you describe what you are trying to do it's difficult to understand what the purpose should be.It would help if you give some examples with what the inputs would be and what the output should be.I played around with your script to make it work, just it's kind of pointless the way it is, since your conditions ("1st input contains c and not b" etc.) only allow for one result "car".expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Word1 = "car" $Word2 = "cat" $Word3 = "cee" $Word4 = "bar" $Word5 = "bat" Local $11 = "c", $12 = "b" Local $21 = "a", $22 = "b" Local $31 = "r", $32 = "t" #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 364, 259, 192, 114) $Input1 = GUICtrlCreateInput("cxx", 16, 24, 121, 21) $Input2 = GUICtrlCreateInput("axx", 16, 72, 121, 21) $Input3 = GUICtrlCreateInput("rxx", 16, 112, 121, 21) $Button1 = GUICtrlCreateButton("GO!", 24, 168, 97, 65) $Edit1 = GUICtrlCreateEdit("", 192, 24, 129, 217, BitOR($GUI_SS_DEFAULT_EDIT, $ES_CENTER)) GUICtrlSetData(-1, "Edit1") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ControlClick($Form1,"",$Button1);Autoclick button on startup While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 ; Check if $Input1 has a "c" or a "b" in it ; If $Input1 has a "c" and not a "b" it will check $Input2 and see if it has an "a" or an "e" in it. If (StringInStr(GUICtrlRead($Input1), $11) > 0) And (Not (StringInStr(GUICtrlRead($Input1), $12) > 0)) Then ; If $Input2 has an "a" and not an "e" in it, it will continue to $Inputbox3 and check if it has an "r" or a "t". If (StringInStr(GUICtrlRead($Input2), $21) > 0) And (Not (StringInStr(GUICtrlRead($Input2), $22) > 0)) Then ; If Input3 has an "r" and not a "t" it should find out which word listed above matches with the word spelled out in the inputboxes. If (StringInStr(GUICtrlRead($Input3), $31) > 0) And (Not (StringInStr(GUICtrlRead($Input3), $32) > 0)) Then $sCombination = $11 & $21 & $31 $sWordsMatch = "" If $sCombination = $Word1 Then $sWordsMatch &= $Word1 & @CRLF If $sCombination = $Word2 Then $sWordsMatch &= $Word2 & @CRLF If $sCombination = $Word3 Then $sWordsMatch &= $Word3 & @CRLF If $sCombination = $Word4 Then $sWordsMatch &= $Word4 & @CRLF If $sCombination = $Word5 Then $sWordsMatch &= $Word5 & @CRLF GUICtrlSetData($Edit1, $sWordsMatch);Data is the words listed above that match the input from the inputboxes. EndIf EndIf EndIf EndSwitch WEnd I'm confused and slightly curious as to the point, so let us know! ImageSearch15.au3 featuring _ImageSearchStartup() and _ImageSearchShutdown() Link to comment Share on other sites More sharing options...
Ginga Posted November 19, 2015 Author Share Posted November 19, 2015 Found a way to make it do what I want it to do, after a long night of reading, coffee and thinking.expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $vVar[27] Global $pSvar[4] #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 364, 259, 192, 114) $Input1 = GUICtrlCreateInput("", 16, 25, 121, 21) $Input2 = GUICtrlCreateInput("", 16, 50, 121, 21) $Button1 = GUICtrlCreateButton("GO!", 24, 168, 97, 65) $Edit1 = GUICtrlCreateEdit("", 192, 24, 129, 217, BitOR($GUI_SS_DEFAULT_EDIT, $ES_CENTER)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Check() EndSwitch WEnd Func Check() $vVar[1] = 'a' $vVar[2] = 'b' $vVar[3] = 'c' $vVar[4] = 'd' $vVar[5] = 'e' $vVar[6] = 'f' $vVar[7] = 'g' $vVar[8] = 'h' $vVar[9] = 'i' $vVar[10] = 'j' $vVar[11] = 'k' $vVar[12] = 'l' $vVar[13] = 'm' $vVar[14] = 'n' $vVar[15] = 'o' $vVar[16] = 'p' $vVar[17] = 'q' $vVar[18] = 'r' $vVar[19] = 's' $vVar[20] = 't' $vVar[21] = 'u' $vVar[22] = 'v' $vVar[23] = 'w' $vVar[24] = 'x' $vVar[25] = 'y' $vVar[26] = 'z' $CountP = 0 If StringInStr(GUICtrlRead($Input1), $vVar[2]) > 0 Then ; <---------Bat If StringInStr(GUICtrlRead($Input2), $vVar[1]) > 0 Then If StringInStr(GUICtrlRead($Input3), $vVar[20]) > 0 Then $pSvar[$CountP] = 'Bat' $CountP = $CountP + 1 EndIf EndIf EndIf If StringInStr(GUICtrlRead($Input1), $vVar[3]) > 0 Then ; <---------Cat If StringInStr(GUICtrlRead($Input2), $vVar[1]) > 0 Then If StringInStr(GUICtrlRead($Input3), $vVar[20]) > 0 Then $pSvar[$CountP] = 'Cat' $CountP = $CountP + 1 EndIf EndIf EndIf If StringInStr(GUICtrlRead($Input1), $vVar[4]) > 0 Then ; <---------Dog If StringInStr(GUICtrlRead($Input2), $vVar[15]) > 0 Then If StringInStr(GUICtrlRead($Input3), $vVar[7]) > 0 Then $pSvar[$CountP] = 'Dog' $CountP = $CountP + 1 EndIf EndIf EndIf If StringInStr(GUICtrlRead($Input1), $vVar[8]) > 0 Then ; <---------Hat If StringInStr(GUICtrlRead($Input2), $vVar[1]) > 0 Then If StringInStr(GUICtrlRead($Input3), $vVar[20]) > 0 Then $pSvar[$CountP] = 'Hat' $CountP = $CountP + 1 EndIf EndIf EndIf GUICtrlSetData($Edit1, $pSvar[0] & @CRLF & $pSvar[1] & @CRLF & $pSvar[2]) EndFunc ;==>Check Link to comment Share on other sites More sharing options...
mikell Posted November 19, 2015 Share Posted November 19, 2015 (edited) Such a method will force you to make a huge scriptThis seems to be a shorter way :expandcollapse popup#include <GUIConstantsEx.au3> Global $Words = ["car", "cartoon", "hat", "bar", "bart"] $Form1 = GUICreate("Form1", 364, 259, 192, 114) $Input1 = GUICtrlCreateInput("", 16, 25, 121, 21) $Input2 = GUICtrlCreateInput("", 16, 50, 121, 21) $Input3 = GUICtrlCreateInput("", 16, 75, 121, 21) $Button1 = GUICtrlCreateButton("GO!", 24, 168, 97, 65) $Edit1 = GUICtrlCreateEdit("", 192, 24, 129, 217) GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Check() EndSwitch WEnd Func Check() Local $sResult = "" ; concatenate the 3 letters $sTest = GuiCtrlRead($Input1) & GuiCtrlRead($Input2) & GuiCtrlRead($Input3) ; loop through the array of words For $i = 0 to UBound($Words)-1 ; test if the word begins with the 3 letters If StringLeft($Words[$i], 3) = $sTest Then $sResult &= $Words[$i] & @crlf Next ; display the result If $sResult = "" Then GUICtrlSetData($Edit1, "nothing found") Else GUICtrlSetData($Edit1, $sResult) EndIf EndFunc ;==>Check Edited November 19, 2015 by mikell Link to comment Share on other sites More sharing options...
Ginga Posted November 19, 2015 Author Share Posted November 19, 2015 Such a method will force you to make a huge scriptThis seems to be a shorter way :expandcollapse popup#include <GUIConstantsEx.au3> Global $Words = ["car", "cartoon", "hat", "bar", "bart"] $Form1 = GUICreate("Form1", 364, 259, 192, 114) $Input1 = GUICtrlCreateInput("", 16, 25, 121, 21) $Input2 = GUICtrlCreateInput("", 16, 50, 121, 21) $Input3 = GUICtrlCreateInput("", 16, 75, 121, 21) $Button1 = GUICtrlCreateButton("GO!", 24, 168, 97, 65) $Edit1 = GUICtrlCreateEdit("", 192, 24, 129, 217) GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Check() EndSwitch WEnd Func Check() Local $sResult = "" ; concatenate the 3 letters $sTest = GuiCtrlRead($Input1) & GuiCtrlRead($Input2) & GuiCtrlRead($Input3) ; loop through the array of words For $i = 0 to UBound($Words)-1 ; test if the word begins with the 3 letters If StringLeft($Words[$i], 3) = $sTest Then $sResult &= $Words[$i] & @crlf Next ; display the result If $sResult = "" Then GUICtrlSetData($Edit1, "nothing found") Else GUICtrlSetData($Edit1, $sResult) EndIf EndFunc ;==>Check I can see that, but with your version I can only use one letter in each input. I want it to find the word(s) that match my list regardless of how many letter there are in each individual inputbox. Link to comment Share on other sites More sharing options...
ViciousXUSMC Posted November 19, 2015 Share Posted November 19, 2015 Your asking for a totally different concept now than you originally posted.Looks like Post#3 is on target. Your pretty much after an anagram solver. Link to comment Share on other sites More sharing options...
mikell Posted November 19, 2015 Share Posted November 19, 2015 (edited) I want it to find the word(s) that match my list regardless of how many letter there are in each individual inputbox.Ah OKPlease try thisexpandcollapse popup#include <GUIConstantsEx.au3> Global $Words = ["car", "cartoon", "hat", "bar", "bart"] Global $Inputs[3] $Form1 = GUICreate("Form1", 364, 259, 192, 114) $Inputs[0] = GUICtrlCreateInput("", 16, 25, 121, 21) $Inputs[1] = GUICtrlCreateInput("", 16, 50, 121, 21) $Inputs[2] = GUICtrlCreateInput("", 16, 75, 121, 21) $Button1 = GUICtrlCreateButton("GO!", 24, 168, 97, 65) $Edit1 = GUICtrlCreateEdit("", 192, 24, 129, 217) GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Check() EndSwitch WEnd Func Check() Local $sResult = "", $match For $i = 0 to UBound($Words)-1 ; for each word $match = 1 $tmp = StringSplit($Words[$i], "") ; create array of letters ; for each letter in this word (according to the number of inputs) For $k = 1 to UBound($Inputs) ; if the letter is NOT present in the Input If StringInStr(GuiCtrlRead($Inputs[$k-1]), $tmp[$k]) = 0 Then $match = 0 Exitloop ; get out and test next word EndIf Next ; all letters were found then store the word If $match = 1 Then $sResult &= $Words[$i] & @crlf Next ; display the result If $sResult = "" Then GUICtrlSetData($Edit1, "nothing found") Else GUICtrlSetData($Edit1, $sResult) EndIf EndFunc ;==>Check Edited November 19, 2015 by mikell Link to comment Share on other sites More sharing options...
Ginga Posted November 19, 2015 Author Share Posted November 19, 2015 That's perfect mikell! Thanks! Your asking for a totally different concept now than you originally posted.Looks like Post#3 is on target. Your pretty much after an anagram solver.Oh, didn't see that post. Kind of like an anagram, yes, but instead of rearranging letters it uses multiple Inputs and sees which letters fits the possition it has in a word. The possition is set by the different inputs.like:the first letter of a word would be looked for in Input1, the secound letter of a word in Input2 and so on. if it finds a word that has all the letters it needs, it will print to the Editbox. No, It's still the same question, but it might have been some miscommunication there. Might have been poorly explained by me. 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