barkeeper Posted January 13, 2011 Share Posted January 13, 2011 (edited) Hey Guys, I'm trying to create a script that can function as sort of a "paste-able knowledge base", Since I'm new to AutoIT, i'm running into some trouble. First of all : Is there an easy option to create a knowledgebase file with "searchterm","Answer" (best would be to have multiple searchterms with 1 answer) or something close to that. Second of all : Whatever I search for (in this example 'test1' it still doesn't work (doesn't find anything). Third of all : I want the script to let me know when it didn't find anything and shows the searchbar again. What I want with the script is : we have a mailbox where customers ask questions, lot's of those questions we already pre-answered, instead of typing the reply allover again, I'd like to create some set paste-ables with friendly names for us to use, for example, I click reply on en e-mail, press ctrl+1 (hotkey), a search bar pops up, I type in : password reset (for example) and a set reply is pasted into the e-mail I was answering. We use Outlook 2010 (shouldn't be important, right?). Here is what I have this far : #include < Misc.au3 > HotKeySet("^1","search") $zoek = 12345 Func Search() $zoek = InputBox("Search", "Search for:") endfunc Func _SendEx($ss) Local $iT = TimerInit() While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12") If TimerDiff($iT) > 2000 Then MsgBox(262144, "Warning", "Shift, Ctrl and Alt keys need to be released to proceed!") EndIf WEnd Send($ss) EndFunc ;==>_SendEx if $zoek = ("test1") or $zoek = ("Test1") then _Sendex("This is a test message that should paste in the box I selected.") Else MsgBox(0, "Didnt find anything, try again:","Nothing found, try again") search() Endif while 1 Sleep(1) WEnd Any help is greatly appreciated! Edited January 13, 2011 by barkeeper Link to comment Share on other sites More sharing options...
JohnOne Posted January 13, 2011 Share Posted January 13, 2011 (edited) Just a quick look, is this what you need? expandcollapse popup#include <Misc.au3> HotKeySet("^1", "search") $zoek = "" ; if its going to be a string, its good practice to declare it as a string While 1 Sleep(1) WEnd Func _test() If $zoek = "test1" Then ; You dont need to test case unless using the "==" operator WinActivate("Untitled - Notepad") WinWaitActive("Untitled - Notepad") _Sendex("This is a test message that should paste in the box I selected.") Else MsgBox(0, "Didnt find anything, try again:", "Nothing found, try again") ;search() EndIf $zoek = "" ;Reset string EndFunc ;==>_test Func search() $zoek &= InputBox("Search", "Search for:") _test() EndFunc ;==>search Func _SendEx($ss) Local $iT = TimerInit() While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12") If TimerDiff($iT) > 2000 Then MsgBox(262144, "Warning", "Shift, Ctrl and Alt keys need to be released to proceed!") $iT = TimerInit() ; reset the timer EndIf WEnd Send($ss) $zoek = "" ;Reset string EndFunc ;==>_SendEx EDIT: You will need a new notepad open, I used that just to test it worked. Edited January 13, 2011 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
barkeeper Posted January 13, 2011 Author Share Posted January 13, 2011 (edited) Thanks for the look m8, appreciate it. What would be ideal is the following - a file (.ini?) that stores all the "searchtermS" and "Answers" - If a searchterm is found, paste the appropriate answer in my "reply to mail" in outlook (to avoid having to copy/paste from notepad to outlook). - If I look for a term that doesn't exist, it would be great to have an "nothing found" message, followed by another search option. Any chance you could help me with that ? Edited January 13, 2011 by barkeeper Link to comment Share on other sites More sharing options...
JohnOne Posted January 13, 2011 Share Posted January 13, 2011 I cant help you at all unless that script works for you. If I press the hotkeys ctrl + 1 the input box appears, if I type 'test1' it activates notepad, and sends the message, if I type anything else, I get the msgbox nothing found. If this simple script does not work for you, something is very wrong. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
barkeeper Posted January 13, 2011 Author Share Posted January 13, 2011 It works for notepad, also if I add "elseif" 's for more than 1 searchterm and answer it works. I'd like to have the paste happen either in the field I click after having searched for something, or in my outlook reply (with a different window name everytime, depending on the subject). Ideal a file to store questions and answers would also be nice Thank you so much in advance. Link to comment Share on other sites More sharing options...
JohnOne Posted January 13, 2011 Share Posted January 13, 2011 To have it paste the text into a particular field, you could use controlsend() function, or optionally activate the window needed and set focus to the input field. You should read up on that and give it a go. Also look at the iniread() and its related functions, and have a play about with them until you are confident to put it in your script proper. Or if you dont want to learn that way there are tons of examples on the forum, just use the search, but I advise option 1 for your learing. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
barkeeper Posted January 13, 2011 Author Share Posted January 13, 2011 (edited) I will have a go at playing around with it, can I be blunt and ask you to keep an eye out for the thread in case I need some assistance ? You're a star! Edited January 13, 2011 by barkeeper Link to comment Share on other sites More sharing options...
JohnOne Posted January 13, 2011 Share Posted January 13, 2011 Sure, while Im here. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
barkeeper Posted January 13, 2011 Author Share Posted January 13, 2011 Turns out I can just use : WinActivate("RE:") cause that's what all replies to mail screens will start with. Having a play with the "ini" file, but I never really got the whole array story, so trying to figure it out. If anyone has tips how to include an ini file or config file with question/answers to search for, that would be amazing. Link to comment Share on other sites More sharing options...
JohnOne Posted January 13, 2011 Share Posted January 13, 2011 (edited) You dont really need arrays at this point, here is a swift example, see if you can build on it. You need to create the red.ini first in same dir #include <Misc.au3> HotKeySet("^1", "search") $zoek = "" ; if its going to be a string, its good practice to declare it as a string While 1 Sleep(1) WEnd Func _test() Local $sIni = @ScriptDir & "\red.ini" Local $sAnswer = "" $sAnswer = IniRead($sIni, "answers", $zoek, "Sorry No answer available") MsgBox(0, "Answer", $sAnswer) $zoek = "" ;Reset string EndFunc ;==>_test Func search() $zoek &= InputBox("Search", "Search for:") _test() EndFunc ;==>search Func _SendEx($ss) Local $iT = TimerInit() While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12") If TimerDiff($iT) > 2000 Then MsgBox(262144, "Warning", "Shift, Ctrl and Alt keys need to be released to proceed!") $iT = TimerInit() ; reset the timer EndIf WEnd Send($ss) $zoek = "" ;Reset string EndFunc ;==>_SendEx red.ini [answers] frog=A Frog leaps on lilys toad=Liking toads is not recommended platipus=Wut? Edited January 13, 2011 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
barkeeper Posted January 14, 2011 Author Share Posted January 14, 2011 You're the best! I can work with this! Have an amazing weekend! Link to comment Share on other sites More sharing options...
JohnOne Posted January 14, 2011 Share Posted January 14, 2011 Glad you're making progress. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
barkeeper Posted January 14, 2011 Author Share Posted January 14, 2011 Raising the bar on myself again now this is working, trying to get <enters> to be made into the text that is declared in the ini file, not having much luck yet Link to comment Share on other sites More sharing options...
JohnOne Posted January 14, 2011 Share Posted January 14, 2011 I'm not sure what you mean. [answers] answer1=<enters> ? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
barkeeper Posted January 17, 2011 Author Share Posted January 17, 2011 if I use : question=answer and I use multiple lines, it doesn't work, so need a function where an <enter> is made into the text question=line1<enter>line2<hyperlink><enter> That idea.. Any thoughts ? Link to comment Share on other sites More sharing options...
saywell Posted January 17, 2011 Share Posted January 17, 2011 Would you be better off using a database for this? SQLite and the _SQLite Management UDF work well. It would be much more expandable than an ini file, too. William Link to comment Share on other sites More sharing options...
JohnOne Posted January 17, 2011 Share Posted January 17, 2011 (edited) Heads up first, that this is probably not the best way to do this, so bear that in mind if you decide to. You should probably use a database of some sort. Heres just a mod to the existing code to show how it could be done with ini (and I wouldnt be surprised if there were a better way with ini files too) Look at the change in the ini file. expandcollapse popup#include <Misc.au3> HotKeySet("^1", "search") $zoek = "" ; if its going to be a string, its good practice to declare it as a string While 1 Sleep(1) WEnd Func _test() Local $sIni = @ScriptDir & "\red.ini" Local $sAnswer = "" $sAnswer = IniRead($sIni, "answers", $zoek, "Sorry No answer available") If StringInStr($sAnswer,"</br>") Then $aAnswer = StringSplit($sAnswer,"</br>",1) ; 1 = entire delimiter string is needed to mark the split $sAnswer = "" For $i = 1 To $aAnswer[0] $sAnswer &= $aAnswer[$i] & @CRLF Next EndIf MsgBox(0, "Answer", $sAnswer) $zoek = "" ;Reset string EndFunc ;==>_test Func search() $zoek &= InputBox("Search", "Search for:") _test() EndFunc ;==>search Func _SendEx($ss) Local $iT = TimerInit() While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12") If TimerDiff($iT) > 2000 Then MsgBox(262144, "Warning", "Shift, Ctrl and Alt keys need to be released to proceed!") $iT = TimerInit() ; reset the timer EndIf WEnd Send($ss) $zoek = "" ;Reset string EndFunc ;==>_SendEx ini [answers] frog=A Frog leaps on lilys toad=Liking toads is</br>not recommended</br>http://www.mywebsite.com/ platipus=Wut? Edited January 17, 2011 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
barkeeper Posted January 17, 2011 Author Share Posted January 17, 2011 You're a hero! Almost perfect, but it seems that at the end of the <br> text it gives windows commands for enter and other things, any ideas ? Link to comment Share on other sites More sharing options...
JohnOne Posted January 17, 2011 Share Posted January 17, 2011 You can just change the deliminator to anything you want, for example "<enter>" AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
barkeeper Posted January 17, 2011 Author Share Posted January 17, 2011 (edited) Changed it to <enter> but since I paste the information from the ini file into outlook (I search for a window called : RE: and paste it in there). it seems that & @CRLF is giving the error. Outlook is going crazy if <enter> is in the answer, it seems like it's pressing escape, don't save, send (it sends the mail in the end). Any ideas ? expandcollapse popup#include <Misc.au3> HotKeySet("^1", "search") $zoek = "" ; if its going to be a string, its good practice to declare it as a string While 1 Sleep(1) WEnd Func _test() Local $sIni = @ScriptDir & "\antwoorden.ini" Local $sAnswer = "" $sAnswer = IniRead($sIni, "answers", $zoek, "Sorry nothing found with the terms specified") If StringInStr($sAnswer,"<enter>") Then $aAnswer = StringSplit($sAnswer,"<enter>",1) ; 1 = entire delimiter string is needed to mark the split $sAnswer = "" For $i = 1 To $aAnswer[0] $sAnswer &= $aAnswer[$i] & @CRLF Next EndIf WinActivate("RE:") WinWaitActive("RE:") If $sAnswer = "Sorry nothing found with the terms specified" then MsgBox(0, "Answer", "Nothing found") Else _Sendex ($sAnswer) $zoek = "" ;Reset string EndIf EndFunc ;==>_test Func search() $zoek &= InputBox("Search", "Search for:") _test() EndFunc ;==>search Func _SendEx($ss) Local $iT = TimerInit() While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12") If TimerDiff($iT) > 2000 Then MsgBox(262144, "Warning", "Shift, Ctrl and Alt keys need to be released to proceed!") $iT = TimerInit() ; reset the timer EndIf WEnd Send($ss) $zoek = "" ;Reset string EndFunc ;==>_SendEx Ini file : test=test<enter>not recommended<enter>http://www.mywebsite.com/ Edited January 17, 2011 by barkeeper 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