Jump to content

mortog

Active Members
  • Posts

    26
  • Joined

  • Last visited

Everything posted by mortog

  1. I was working on something similar and tackled it as follows: Trained sentences: - scrap the input from capital letters, dots, etc. Call the remainder as a function with the remainder as its name, the function will have a bunch of variables attached to it (reply, grammar analysis (see below), etc.) New sentences: Split input into 3 parts: the original, grammatical analysis, word roots For the grammatical parts, I used treetagger and had it create a file containing the input, grammatical analysis, and root of the words: ShellExecuteWait("C:\TreeTagger\bin\tag-english.bat", $InputFile & " > " & $OutputFile, @SW_HIDE) build a 2d array of the info in $OutputFile (_DelimFile_To_Array2D) build a loop that uses _ArrayFindAll to check if a specific value of the input matches the trained sentences and build up an array of the results (ideally you should do this for the original input, grammar and root, so you can compare the data). get the highest matching results. For this I used a function I found on these forums, which I edited to suit my needs: ;=============================================================================== ; ; FunctionName: _ArrayMode() ; Description: Returns the most frequently occuring elements in the array ; Syntax: _ArrayMode( $aArray [, $iStart] ) ; Parameter(s): $aArray - The ByRef array to find the mode of ; $iStart - (optional) The first index to check for data, default is 0 ; Return Value(s): On success returns a 1D array: ; [0] = Mode (number of instances of most common data element) ; [1] = First mode element ; [2] = Second mode element (with same mode count as first) ; [n] = Last mode element (with same mode count as first) ; On failure returns 0 and sets @error ; Author(s): jon8763; modified by PsaltyDS; further modified by Mortog ;=============================================================================== Func _ArrayMode(ByRef $aArray, $iStart = 0) ; Get list of unique elements Local $aData = _ArrayElements($aArray, $iStart) If @error Then Return SetError(@error, 0, 0) If $aData[0] = 0 Then Return $aData ; Setup to use SOH as delimiter Local $SOH = Chr(01), $sData = $SOH ; Setup for number of dimensions Local $iBound1 = UBound($aArray) - 1, $Dim2 = False, $iBound2 = 0 If UBound($aArray, 0) = 2 Then $Dim2 = True $iBound2 = UBound($aArray, 2) - 1 EndIf ; Assemble data string for searching For $m = $iStart To $iBound1 If $Dim2 Then ; 2D For $n = 0 To $iBound2 $sData &= $aArray[$m][$n] & $SOH Next Else ; 1D $sData &= $aArray[$m] & $SOH EndIf Next ; Check count of each unique element listed in $aData, highest count kept in $aCounts[0] Local $aCounts[$aData[0] + 1] = [0], $aRegExp[1] For $n = 1 To $aData[0] $aRegExp = StringRegExp($sData, $SOH & $aData[$n] & $SOH, 3) $aCounts[$n] = UBound($aRegExp) If $aCounts[$n] > $aCounts[0] Then $aCounts[0] = $aCounts[$n] Next ;create 2d array with unique numbers and their occurances _ArrayDelete($aCounts, 0) $o = _ArrayMaxIndex($aCounts) _ArrayDelete($aCounts, $o) _ArrayInsert($aCounts, 0) _ArrayInsert($aCounts, $o +1) $k = UBound($aCounts) Local $aCounts_2d[$k][2] For $i = 1 to $k step +1 _ArrayInsert($aCounts_2d, $i-1, $aCounts[$i -1] & "|" & $aData[$i -1]) Next _ArrayDelete($aCounts_2d, 0) Local $aRET = _ArrayMaxIndex($aCounts_2d,0,0,UBound($aData), 0) Return $aRET EndFunc ;==>_ArrayMode Attach scores to all the values based on their grammatical analysis and start comparing the input to your trained material. Some additional thoughts you should consider: Let's assume you have the following trained: how are you doing? and you have the input: how are you doing today? You may consider the input having a total score of 6, being 6 strings. The trained material would have a score of 5, and can figure out whether you'd like your script to remove adjectives, conjunctions and adverbs one by one to see if it gets a match to your trained data. Even better would be to have different values for different types of words, for examples verbs could have a score of 1, adverbials of time a score of 0.7. This would probably make finding matches more accurate, and easier. The challenging part though, will be that the word today does imply something: you could be expacted to have had a bad experience yesterday for example. The system described here is also easy for single sentences, but you'll need to build on it considerably if you want it to be able to process multiple sentences (and for example recognize a sentence with multiple questions).
  2. That also gives me a result of 0. Could anyone perhaps give me a working example of imagesearch so I can use that to work my way back to what's causing this problem? I'm getting the feeling either my dll file or imagesearch file is wrong.
  3. Thanks for the suggestion, it still returns a 0 value though.
  4. Hey everyone, I'm trying to create a script that will eventually search through a bunch of images, but I can't even get the basics to work. Could anyone tell me what I'm doing wrong? Below is the code and the steps I've taken trying to solve the problem: #Include <ImageSearch.au3> HotKeySet("{ESC}", "Terminate") Func Terminate() Exit 0 EndFunc global $y = 0, $x = 0 While 1 Sleep (2000) $search = _ImageSearch("test.jpeg", 1, $x, $y, 20) Sleep (2000) If $search = 1 Then MsgBox (0, "" , "succes!") Else msgbox (0, "", $search) EndIf WEnd - the file test.jpeg is just a screenshot of the section that says: "global $y = 0, $x = 0". - I've tried the 32 and 64 bit versions of imagesearch - the DLL file is in the windowssystem32 folder and the imagesearch file in the autoitinclude folder - I've also tried the example from >this site but obviously with referencing my test image. Thanks in advance for your help! I've attached the test image.
  5. The commas were just as an example, in the actual string and array that I'll be using there will be whole sentenses so I should not run into the 11 issue. I went for your latest changes though as I'd otherwise run into other problems. Thanks again!
  6. Ah, you're right about that.. but in the string and array that I'll be using in reality there's never going to be a 2 digit number, so that shouldn't pose an issue.
  7. That's what I was thinking of at first as well Jos, but that seemed to be a bit too extensive for the relatively easy thing I was trying to do. Also I wasn't to concerned about possible problems since I really didn't want anything else then to search a specific string (in this case the contents of a text file) for various array values. Mike, your suggestion did exactly what I was looking for and works like a charm, thanks a lot Edit: just tried yours also Czardas, works like a charm as well.
  8. Hey folks, I'm a bit stuck on the following: I've got a string of text and an array that I want to compare (I want to check if any of the values in the array exist in the string), but I can't get it to work. I also want this to work in a While loop. I've been thinking of a way to give an example of what I'm trying to do, but I don't know how I'd approach this using AutoIt. Let's say for arguments sake that I have a $string = "1,2,3,4,5,6,7,8,9" and Global $array[3] = ["1", "3", "6", "9"] My question is then : how do I search if any of the values in the array (so 1,3,6,or 9) exist in the string? I don't necessarily need a return of which of these values exists in the string, so long as any of them does. In a sense you could say I'm trying to do the exact opposit of what an arraysearch does. Thanks a lot in advance for the help.
  9. Thanks again, I'm going to have a look at that as well. The problem with drivemapping is that a restriction on our network is that if anyone is logged in on a computer no other person can map any folders from that pc unless you enter admin credentials. Problem is though that I'm trying to have this tool function ofline as well with just a network cable connected between the original and new computer and by logging locally on both pc's
  10. Unfortunately that didn't work.. I keep getting a code 1 error return ( 1 = Undefined / Other error. @extended set with Windows API return ) Any other ideas?
  11. I wasn't using DirCopy because of the rediculous security measures on the network here, which so far prevented me from using it. Your suggestion sounds very interesting Sleepydvdr, I'm going to check it out right away.
  12. Thanks for your reply MPH, do you mean the SyntaxCheck? otherwise I'm not sure which window you mean. The SyntaxCheck comes out without any errors. >C:\AutoIt3\SciTE\..\au3check.exe "C:\AutoIt3\########.au3" AutoIt3 Syntax Checker v1.54.8 Copyright © Tylo 2007 C:\AutoIt3\Ashland.au3 - 0 error(s), 0 warning(s) >Exit code: 0 Time: 0.331 It just occured to me that I'm using the WinActive function rather then the WinWaitActive function. I'm going to give that one a try and see what comes out.
  13. Hey folks, I'm trying to create a file copy tool which will manually copy files (because dircopy and such doesn't work due to network restrictions). However I'm trying to make sure that steps won't continue until windows are active, but for some reason it doesn't seem to work. Could anyone shed some light on what I'm doing wrong? Thanks in advance! Here's an extract of what I'm working on. While 1 $msg = GUIGetMsg() If $msg = $XIcon[1] Then Exit If $msg = $XIcon[2] Then GUISetState(@SW_MINIMIZE) If $msg = $Exit Then Exit If $msg = $Ok Then Ping(GUICtrlRead ($Input1), 2500) If @error = 0 Then $Lang_dll = DllOpen("kernel32.dll") $UserIntLang=DllCall ( $Lang_dll, "int", "GetUserDefaultUILanguage" ) If @error=0 Then $UserIntLang=Hex($UserIntLang[0],4) Else $UserIntLang="UNKNOWN" EndIf DllClose($Lang_dll) ; the language piece is kind of obsolete now, just left it there as a just in case precaution Sleep(1000) Run("c:\Migration\Error.exe") ; see below for the code of this .exe Sleep(1000) Send("#m") Sleep(2000) Send("#r") Sleep(1000) WinActive(StringInStr(WinGetTitle("[active]"), "Run" or "Exécuter")) Sleep(1000) Send("\\" & GUICtrlRead($Input1) & "\c$") Sleep(1500) Send("{Enter}") Sleep(1000) WinActive ("Connect to " & GUICtrlRead($Input1)) Sleep(1000) Send(GUICtrlRead($Input1) & "\i400550") Sleep(1000) Send("{tab}") Sleep(1000) Send("asdf1234") Sleep(1000) Send("{enter}") Sleep(1000) WinActive(StringInStr(WinGetTitle("[active]"), "c$")) Sleep(1000) Send("!+{F4}") Sleep(5000) Send("#m") Sleep(2000) Send("#r") Sleep(1000) WinActive(StringInStr(WinGetTitle("[active]"), "Run" or "Exécuter")) Sleep(1000) Send(@MyDocumentsDir) Sleep(1000) Send("{Enter}") Sleep(1000) WinActive(StringInStr(WinGetTitle("[active]"), "My Documents" or "Mes Documents")) Sleep(1000) Send("{Right}") Sleep(1000) Send("^a") Sleep(2000) Send("^c") Sleep(2000) Send("!+{F4}") Sleep(5000) Send("#r") Sleep(1000) WinActive(StringInStr(WinGetTitle("[active]"), "Run" or "Exécuter")) Sleep(1000) Send("\\" & GUICtrlRead($Input1) & "\c$\Documents and Settings\" & GUICtrlRead($Input2) & "\My Documents\") Sleep(1000) Send("{Enter}") Sleep(1000) WinActive(StringInStr(WinGetTitle("[active]"), GUICtrlRead($Input2) & "'s Documents" or "Documents de " & GUICtrlRead($Input2))) Sleep(1000) Send("{Right}") Sleep(1000) Send("^v") Sleep(1000) WinActive(StringInStr(WinGetTitle("[active]"), "Copying..." or "Copie...")) Sleep(1000) WinActive(StringInStr(WinGetTitle("[active]"), GUICtrlRead($Input2) & "'s Documents" or "Documents de " & GUICtrlRead($Input2))) Sleep(1000) Send("!+{F4}") Sleep(5000) The Error.exe tool: HotKeySet("{ESC}", "Terminate") Opt("TrayIconHide", 1) Func Terminate() Exit 0 EndFunc While 1 If StringInStr(WinGetTitle("[Active]"), "Confirm" ) Then Sleep(500) Send("{Right}") Sleep(500) Send("{Enter}") Sleep(500) Else EndIf WEnd
  14. I did indeed! Thanks a lot mate
  15. hey folks, I'm trying to write a little program that keeps looping and checks if the active window contains the string 'Confirm' and if so will give a right arrow and enter key input, however what I've got so far isn't working. I'm probably completely overlooking something small here, but I have a bit of a blackout and was wondering if someone could tell me where I'm going wrong. Thanks in advance! HotKeySet("{ESC}", "Terminate") Func Terminate() Exit 0 EndFunc Sleep(2500) While 1 If WinActive (StringInStr(WinGetTitle("[Active]"), "Confirm" )) Then Send ("{Right}") Sleep(200) Send ("{Enter}") Else EndIf Sleep(2500) WEnd
  16. Solved the problem by using StrimTrim, it makes the code looks quite brutish, but well.. if it works I guess..
  17. no worries Czardas However unfortunately I run into a new problem. It seems the string length seems to be messing up bigtime. When I try to add functions later such as creating an array and then try to do an array search (or w/e really) it always seems to think the string is 2 longer then it really is. To clarify why the code below is the way it is: I'm trying to split all words in a typed sentense and compare it to various arrays such as the $Subject one. However I can't find any method to get a positive confirmation that the input matches the $subject so if I only type "I" (thus I becomming $1) and then use for example _ArrayFindAll to compare the $subject vs $1 to see if I get a match, it will always fail. Any thoughts? I've scrapped the comparing bit of code and replaced it with a StringLen result to show what I mean. #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <Array.au3> $hGUI = GUICreate("Test", 500, 500) $Edit = GUICtrlCreateEdit("", 10, 10, 480, 300, BitOR($WS_VSCROLL, $ES_MULTILINE, $WS_EX_TRANSPARENT)) $Input = GUICtrlCreateInput("", 60, 330, 375, 20) GUISetState() Local $Subject[7] = ["I", "you", "he", "she", "it", "we", "they"] While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $Input GUICtrlSetData($Edit, GUICtrlRead($Input) & @CRLF, 1) GuiCtrlSetData($Input, "") Case $Edit $text = GUICtrlRead($Edit) $array = StringSplit($text, " ") $1 = _ArrayToString($array, "", 1, 1) $2 = _ArrayToString($array, "", 2, 2) $3 = _ArrayToString($array, "", 3, 3) $4 = _ArrayToString($array, "", 4, 4) $5 = _ArrayToString($array, "", 5, 5) $6 = _ArrayToString($array, "", 6, 6) $7 = _ArrayToString($array, "", 7, 7) $8 = _ArrayToString($array, "", 8, 8) $9 = _ArrayToString($array, "", 9, 9) $StringLen = StringLen($1) MsgBox(0, "test", $StringLen) EndSwitch WEnd
  18. Aye, the array display was just to make sure I was getting the output I was looking for since a msgbox would just display blank info, I've now completely ditched that part though As for the messagebox, I believe I ran into it in a helpfile, but you're right -1 is kinda pointless, which is also why in my last reply I changed it to 0. I'm still quite a noob when it comes to autoit, but I'm learning thanks to this great community
  19. Actually I found another solution to work around it that works perfectly. After the StringSplit I've used _ArrayToString which should allow me to get all individual inputs and assign values to them. (kinda working from A to B to A ) So in a quick test I modified it to: Case $Edit $text = GUICtrlRead($Edit) $array = StringSplit($text, " ") MsgBox(0,"test", _ArrayToString($array, @CR, 1, 40)) Obviously that's just to test if it works, but I believe from here I should be able to assign values to each individual string with a little bit of tinkering Thanks again for all your help, I owe you one.
  20. What would I do without you? I was looking at _StringExplode and _StringBetween but didn't manage to get the results I wanted. StringSplit seems to be spot on and I will definately look into using Assign to add values. However when I tried to test the Stringsplit there was 1 tiny problem, the last word in the line has 2 boxes behind it. Is there a way to get them to disappear? #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <Array.au3> $hGUI = GUICreate("Test", 500, 500) $Edit = GUICtrlCreateEdit("", 10, 10, 480, 300, BitOR($WS_VSCROLL, $ES_MULTILINE, $WS_EX_TRANSPARENT)) $Input = GUICtrlCreateInput("", 60, 330, 375, 20) GUISetState() While 1 $msg = GUIGetMsg() If GuiCtrlRead($Edit) = "test" Then MsgBox (-1, "test", "it works!") EndIf Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $Input GUICtrlSetData($Edit, GUICtrlRead($Input) & @CRLF, 1) GuiCtrlSetData($Input, "") Case $Edit $text = GUICtrlRead($Edit) $array = StringSplit($text, " ") _ArrayDisplay($array) EndSwitch WEnd
  21. Hey Emiel, thanks for the tip, I'll keep that in mind. However at the moment I wasn't planning to paste .txt contents into the edit box. There was another thing I was curious about and perhaps you could point me in the right direction. I intend to use only input from the user appearing in the edit box, however this input can be up to 4-5 words. I was wondering if it would be possible to assign a value to each individual string entered. For example if you have the line: "this is an example" Is there a function that allows me to assign a numeric value to each of the individual words? So let's say this=1 is=2 an=3 example=4 Is there perhaps something along the line of: a value is assigned to each bunch of strings between spaces? I've been going over the autoit documentation for quite a while now without finding a solution. The request may seem a bit odd, but it's for a linguistic project I wanted to pursue. edit: I'm currently checking up _StringBetween to determain if it can spot a space and then assign a numeric value to each word before each space in the string.
  22. Cheers mate, you've put me exactly in the right direction I've now used a case function and then an if stringinstr then and it works great, thanks again!
  23. hey folks, as the topic says, I can't get the Read function to respond to the stuff appearing in Edit. Could anyone point me at what I'm overlooking here? Here's a short example of how I'm going about it (I've stripped most of the unnecessary code away and such for this example) #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> $hGUI = GUICreate("Test", 500, 500) $Edit = GUICtrlCreateEdit("", 10, 10, 480, 300, BitOR($WS_VSCROLL, $ES_MULTILINE, $WS_EX_TRANSPARENT)) $Input = GUICtrlCreateInput("", 60, 330, 375, 20) GUISetState() While 1 $msg = GUIGetMsg() If GuiCtrlRead($Edit) = "test" Then MsgBox (-1, "test", "it works!") EndIf Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $Input GUICtrlSetData($Edit, GUICtrlRead($Input) & @CRLF, 1) GuiCtrlSetData($Input, "") EndSwitch WEnd The eventual goal of all this is that I want the Read function to pick up on every individual word typed by the user in the input box, and I was trying to use GUICtrlRead for this. If there's a more efficient function for this I'm all ears edit: oddly enough when I change If GuiCtrlRead($Edit) to If GuiCtrlRead($Input) I actually do get the messagebox to appear, but then it does so as soon as you finish typing, which is kinda what I don't want.
  24. It looks like such a small change, but it helped me bigtime. Thanks a lot Arterie, that worked like a charm
  25. Thanks for the reaction Arterie, but although the problem is now clear to me I'm not sure how I can fix the problem as a whole. If I want the user's input from the GuiCtrlCreateInput to be read by the MsgBox, how should I go about it if I want to stick to OnEventMode?
×
×
  • Create New...