Jump to content

[Auto Answers] Could use some help with script


 Share

Go to solution Solved by SOLVE-SMART,

Recommended Posts

Problem with a central file is that if someone is writing to it, no one can do the same.  Unless there is a rigorous error handling, some updates may be lost. 

I suppose that is not an important issue ATM and I trust someone (like you) can manage the short term situation.  But I have worked in heavy load of data (hospitals) and my first reflex is to give a robust solution.

So I still wouldn't suggest to go with a DB. Since update may reduce to none over time, I believe having a shared file is your best solution in short-middle term.  It will be way easier to deploy.  Using the robust WinAPI, you can address the problem of multiple access and let the users wait for update of the central file.

Link to comment
Share on other sites

15 hours ago, Nine said:

Problem with a central file is that if someone is writing to it, no one can do the same.  Unless there is a rigorous error handling, some updates may be lost. 

I suppose that is not an important issue ATM and I trust someone (like you) can manage the short term situation.  But I have worked in heavy load of data (hospitals) and my first reflex is to give a robust solution.

So I still wouldn't suggest to go with a DB. Since update may reduce to none over time, I believe having a shared file is your best solution in short-middle term.  It will be way easier to deploy.  Using the robust WinAPI, you can address the problem of multiple access and let the users wait for update of the central file.

Well, since i can use a lot of help with achieving this solution. I’m not one to make a demand in a certain way, since we can’t handle workload everything would be acceptable, even everyone running their own program with ‘answers’ file, and sharing copy/paste answers to add to it through teams, or me making a new file every friday or weekend. We need some ‘time saver’ for the near future to keep our workload managable. 
 

i would say if the system could scan for a directory of files at the start; and document the name before the .txt or .ini as an entry to use, and show that as a searchable string, i could work with that for now already. But keeping the layout (as my example answer) without having to code things like <enter> or <bold> in it would already help a lot as well 

Link to comment
Share on other sites

Here a simple script that hopefully will can get you started :

#include <GUIConstantsEx.au3>
#include <GuiRichEdit.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
  Local $hGui = GUICreate("Example of reading a RTF file", 1020, 650, -1, -1)
  Local $hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 10, 10, 1000, 520, _
      BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
  GUISetState()

  $sText = StringRegExp(FileRead("Document.txt"), "(?s)\[VPN\]\v*(.*)\[\/VPN\]", 1)[0]

  _GUICtrlRichEdit_SetText($hRichEdit, $sText)
  While True
    Switch GUIGetMsg()
      Case $GUI_EVENT_CLOSE
        ExitLoop
    EndSwitch
  WEnd
  _GUICtrlRichEdit_SetSel($hRichEdit, 0, -1)
  _GUICtrlRichEdit_Copy($hRichEdit)
  _GUICtrlRichEdit_Destroy($hRichEdit)
EndFunc   ;==>Example

I took your example previously posted and used your idea of special tags [VPN]...[/VPN]

Once you have reviewed the text, it automatically copy the text and you can paste it in an Outlook message successfully.

Tested in Win7.

I used Notepad++ to update the file.  You just need to write your answers with my script, open the file Document.txt, add tags, paste text in between.

Of course, you will need to add a more intelligent UI, but this proof of concept is working...

ps.  If you do not like my approach of having everything into a single txt document, you could also create a rtf file for each answers (you could use WordPad for it).  And then read the corresponding document instead of extracting it.

Document.txt

Edited by Nine
Link to comment
Share on other sites

Hi @barkeeper,

I followed the thread (the conversation) here and found it would be helpful to contribute.
I will also provide a little example like @Nine did 👍 .

My approach will contain a database usage because I have a similar requirement for another project (probably with more data).
This means it could be useful for me too. I try to provide basic functionality to fit your mentioned requirements (as I understood them 😅).
Afterwards I will restructure the project to to meet my requirements.

My implementation will take a while. So if you can not wait (few days) go ahead and try to use and expand the nice example of @Nine.

On 2/25/2022 at 12:46 AM, Nine said:

So I still wouldn't suggest to go with a DB. Since update may reduce to none over time, I believe having a shared file is your best solution in short-middle term.  It will be way easier to deploy.  Using the robust WinAPI, you can address the problem of multiple access and let the users wait for update of the central file.

Yes the file approach should be easier. Regarding the possible multiple access handling, a database would do it on his own. That's why I would prefer that way 😀 .
I hope I can bring a suggestion pretty soon, but don't count on it.

Best regards
Sven

________________
Stay innovative!

Edited by SOLVE-SMART

Stay innovative!

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to comment
Share on other sites

23 hours ago, Nine said:

Here a simple script that hopefully will can get you started :

#include <GUIConstantsEx.au3>
#include <GuiRichEdit.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
  Local $hGui = GUICreate("Example of reading a RTF file", 1020, 650, -1, -1)
  Local $hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 10, 10, 1000, 520, _
      BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
  GUISetState()

  $sText = StringRegExp(FileRead("Document.txt"), "(?s)\[VPN\]\v*(.*)\[\/VPN\]", 1)[0]

  _GUICtrlRichEdit_SetText($hRichEdit, $sText)
  While True
    Switch GUIGetMsg()
      Case $GUI_EVENT_CLOSE
        ExitLoop
    EndSwitch
  WEnd
  _GUICtrlRichEdit_SetSel($hRichEdit, 0, -1)
  _GUICtrlRichEdit_Copy($hRichEdit)
  _GUICtrlRichEdit_Destroy($hRichEdit)
EndFunc   ;==>Example

I took your example previously posted and used your idea of special tags [VPN]...[/VPN]

Once you have reviewed the text, it automatically copy the text and you can paste it in an Outlook message successfully.

Tested in Win7.

I used Notepad++ to update the file.  You just need to write your answers with my script, open the file Document.txt, add tags, paste text in between.

Of course, you will need to add a more intelligent UI, but this proof of concept is working...

ps.  If you do not like my approach of having everything into a single txt document, you could also create a rtf file for each answers (you could use WordPad for it).  And then read the corresponding document instead of extracting it.

Document.txt 1.88 kB · 3 downloads

I will take a look at this after the weekend, but let me start by saying i’m incredible thankful that you’ve looked into this and gave me something to start/continue on! Will keep you posted ❤️

Link to comment
Share on other sites

Well after some more thoughts, I believe the simpler and most efficient short-term solution would be to create a share folder where everybody could add their answers in RTF format.

Here a revised version using this approach :

#include <GUIConstants.au3>
#include <GuiRichEdit.au3>
#include <WindowsConstants.au3>
#include <File.au3>

Global Const $DOCUMENT_PATH = ".\document\"

Example()

Func Example()
  Local $aList = _FileListToArray($DOCUMENT_PATH, "*.rtf", $FLTA_FILES)
  If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Error", "No File Found")

  Local $hGui = GUICreate("Example of reading a RTF file", 1020, 650, -1, -1)
  Local $idList = GUICtrlCreateCombo("Select Answer", 10, 10, 150, 25)
  GUICtrlSetData(-1, ListAnswer($aList))
  Local $hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 10, 50, 1000, 520, _
      BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
  Local $idCopy = GUICtrlCreateButton("Copy", 10, 600, 100, 20)
  GUISetState()

  Local $sText

  While True
    Switch GUIGetMsg()
      Case $GUI_EVENT_CLOSE
        ExitLoop
      Case $idList
        $sText = BinaryToString(FileRead($DOCUMENT_PATH & GUICtrlRead($idList) & ".rtf"))
        _GUICtrlRichEdit_StreamFromVar($hRichEdit, $sText)
      Case $idCopy
        _GUICtrlRichEdit_SetSel($hRichEdit, 0, -1, True)
        _GUICtrlRichEdit_Copy($hRichEdit)
        _GUICtrlRichEdit_SetSel($hRichEdit, -1, -1)
    EndSwitch
  WEnd
  _GUICtrlRichEdit_Destroy($hRichEdit)
EndFunc   ;==>Example

Func ListAnswer($aArray)
  Local $sList
  For $i = 1 To $aArray[0]
    $sList &= StringRegExpReplace($aArray[$i], "\..*", "") & "|"
  Next
  Return StringTrimRight($sList, 1)
EndFunc

There is a small bug when using WordPad, so I suggest to create/modify the RTF file with Word.

VPN.rtf

Edited by Nine
Link to comment
Share on other sites

Hi @barkeeper,

can I assume that you and your colleagues will be connected to the internet during using the program?
Because I want to use a embedded editor instead of preparing the *.rtf files in WordPad or somewhere else 😀 .

Best regards
Sven

________________
Stay innovative!

Edited by SOLVE-SMART

Stay innovative!

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to comment
Share on other sites

43 minutes ago, SOLVE-SMART said:

I want to use a embedded editor instead preparing the *.rtf files in WordPad or somewhere else

I am interested in that ActiveX, can you provide a bit more information about it ?  I will not cut the grass under your feet....

Link to comment
Share on other sites

Hi @Nine,

22 minutes ago, Nine said:

I will not cut the grass under your feet....

👍 , glad to read that 😂 .

Actually it's quite simple, if it's feasable 😉 .

  • I will create a GUI, embedd an IE object, load a javascript RTF editor and interact with that editor by innerHTML object evaluation.
  • I hope to store the format information of the editor in SQLite.
  • I scroll through the tags and show the answer in the js RTF editor (hope so).

That's it basically. Don't do this earlier 😅 , I want to do the POC.
Just kidding, do what ever you want. And to be honest, I am interested in your opinion about these thoughts.

Best regards
Sven

________________
Stay innovative!

Edited by SOLVE-SMART

Stay innovative!

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to comment
Share on other sites

That is a great idea.  But I do not feel up to create such a thing.  Especially if I would have to maintain it.  Moreover in the long run...

But I would be very interested to see and test your POC !

Link to comment
Share on other sites

@SOLVE-SMART  On second thought, why do you need to create this artificial ActiveX when you could use Word ActiveX to perform exactly what you intend to do ?  That seems to be a nicer way to go, no ?

Link to comment
Share on other sites

Hi @Nine,
 

15 hours ago, Nine said:

[...] why do you need to create this artificial ActiveX when you could use Word ActiveX to perform exactly what you intend to do ? [...]

I think you're right about this could be a nicer way, but I don't want to use Word ActiveX because I will need "Code" block editor format which isn't available in Word (WordPad) out of the box. In the js variant it is 😀 .

Like I wrote, I will prepare something for @barkeeper, but I also focus my own requirements.
Maybe I can start the implementation of the POC at todays evening - let's see (local time for me in germany now: 15:54).

Best regards
Sven

________________
Stay innovative!

Edited by SOLVE-SMART

Stay innovative!

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to comment
Share on other sites

On 2/26/2022 at 2:02 PM, SOLVE-SMART said:

Hi @barkeeper,

I followed the thread (the conversation) here and found it would be helpful to contribute.
I will also provide a little example like @Nine did 👍 .

My approach will contain a database usage because I have a similar requirement for another project (probably with more data).
This means it could be useful for me too. I try to provide basic functionality to fit your mentioned requirements (as I understood them 😅).
Afterwards I will restructure the project to to meet my requirements.

My implementation will take a while. So if you can not wait (few days) go ahead and try to use and expand the nice example of @Nine.

Yes the file approach should be easier. Regarding the possible multiple access handling, a database would do it on his own. That's why I would prefer that way 😀 .
I hope I can bring a suggestion pretty soon, but don't count on it.

Best regards
Sven

________________
Stay innovative!

Wow, that's awesome! Let's keep in touch, sure I can wait a few days/weeks, keep me posted :)

Link to comment
Share on other sites

On 2/26/2022 at 10:54 PM, SOLVE-SMART said:

Hi @barkeeper,

can I assume that you and your colleagues will be connected to the internet during using the program?
Because I want to use a embedded editor instead of preparing the *.rtf files in WordPad or somewhere else 😀 .

Best regards
Sven

________________
Stay innovative!

Yes we are, some restrictions on "not default" ports, but since we're IT, no issues there if it should be needed as well

Link to comment
Share on other sites

Hi folks,

I finished the first design mockup for the answer tool, called Au3AnswerByTag.
The backend code is still in progress, but I achieved the functional breakthrough 🤞 .

I am already in contact with @barkeeper by private message, but I will you inform about the progress.
In case your offer still exist, I will let you know when you can test the application @Nine 😀 .

grafik.png
Image: Program opened

grafik.png
Image: Answer displayed by chosen tag

Best regards
Sven

________________
Stay innovative!

Stay innovative!

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to comment
Share on other sites

  • Solution

Hi folks,

I completed a first version v0.1.0 of "Au3AnswerByTag".

  • It can be visit and checked on GitHub.
  • If you don't want to get the complete release package, just use the zip archive that is attached to this post 😉 .
    • Only the program files are in the zip, no documents or other GitHub related stuff.

Now it's time to do proper testing or at least just a review @Nine 😅 .
But please keep in mind that I have to talk again with @barkeeper about the current features and possible upcoming changes.

grafik.png.2bfef0e71c629c698814d110f10f6997.png

Best regards
Sven

________________
Stay innovative!

Au3AnswerByTag.zip

Stay innovative!

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to comment
Share on other sites

16 hours ago, SOLVE-SMART said:

Hi folks,

I completed a first version v0.1.0 of "Au3AnswerByTag".

  • It can be visit and checked on GitHub.
  • If you don't want to get the complete release package, just use the zip archive that is attached to this post 😉 .
    • Only the program files are in the zip, no documents or other GitHub related stuff.

Now it's time to do proper testing or at least just a review @Nine 😅 .
But please keep in mind that I have to talk again with @barkeeper about the current features and possible upcoming changes.

grafik.png.2bfef0e71c629c698814d110f10f6997.png

Best regards
Sven

________________
Stay innovative!

Au3AnswerByTag.zip 1.22 MB · 3 downloads

AMAZING! This solves my requirements, you're the best!! thank you

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...