Jump to content

Too many enters in script


Recommended Posts

Hi there, not sure if this is the right place, but I'm building a script for using premade answers in chat. It works and outputs the answers (stored in an ini file based on:  answer name = answer it also works with a new line if there is a tag <enter> in the answer text in the ini file. Now the problem is, that after the answer is pasted in the chat (you bring up the interface with ctrl+1) it gives an enter, thus sending the output straight away. I would like to be able to review the answer before sending it. can anyone help me by telling what's wrong in the script, I tried replacing the @crlf in the script with other options, no luck. Thanks in advance! 

antwoorden.au3

antwoorden.ini

Link to comment
Share on other sites

  • Developers

Guess we need to understand what character needs to be send in stead of @CRLF (<enter>) for a newline in your chat client.
Any idea or tried Shift+Enter or just @lf or @cr?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

On ‎25‎-‎1‎-‎2017 at 5:55 PM, Jos said:

Guess we need to understand what character needs to be send in stead of @CRLF (<enter>) for a newline in your chat client.
Any idea or tried Shift+Enter or just @lf or @cr?

Jos

I tried @LF and @CR, no luck. how would I achieve a Shift+Enter instead of the regular enter, can't figure it out I'm afraid.

Link to comment
Share on other sites

13 minutes ago, Subz said:

You could just use StringReplace for example:

If StringInStr($sAnswer,"<enter>") Then $sAnswer =StringReplace($sAnswer,"<enter>", @CRLF)

 

Hi Subz, Thanks for looking at the script. The StringReplace function does make it a little better, but what happens with it is that the first line in the answer .ini file is posted (with enter) and the second one is not (like I want it to be). Any ideas ? The script is meant for providing quick answers to chats we do with Skype for Business, and we would like to review the pasted "default" text, before sending

Link to comment
Share on other sites

14 minutes ago, Subz said:

Also you could use Op('ExpandVarStrings', 1) then in your Ini file you can write your <Enter> as @CRLF@ these will be automatically expanded upon reading the ini file.  For example:

[answers]
answer1=default answer line 1@CRLF@line 2 
answer2=default answer line 1@CRLF@line 2

 

Can you show me a line of code using the ExpandVarStrings in my current script so I get an idea. I'm really new to this. Cheers

Link to comment
Share on other sites

This is a little quick and dirty but maybe you want to try something like this:

#include <Array.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Opt('ExpandVarStrings', 1)

Global $hGUI
Global $bGuiHide = True
Global $sIni = @ScriptDir & "\antwoorden.ini"
Global $aIni = IniReadSection($sIni, 'answers')
    If @error Then Exit MsgBox(16, 'Error', 'Unable to read ini file')

HotKeySet("^1", "_GuiToggle")

Example()

While 1
    Sleep(50)
WEnd

Func Example()
    $hGUI = GUICreate("Example", 300, 200)

    Local $idComboBox = GUICtrlCreateCombo("", 10, 10, 280, 20, $CBS_DROPDOWNLIST)
    Local $idEditBox = GUICtrlCreateEdit('', 10, 40, 280, 120)
    Local $idClose = GUICtrlCreateButton("Close", 210, 170, 85, 25)

    GUICtrlSetData($idComboBox, _ArrayToString($aIni, '|', 1, -1, '|', 0, 0))

    If $bGuiHide = True Then
        GUISetState(@SW_HIDE, $hGUI)
    Else
        GUISetState(@SW_SHOW, $hGUI)
    EndIf

    Local $sComboRead = ""

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idClose
                GUISetState(@SW_HIDE)
                $bGuiHide = True
            Case $idComboBox
                $sComboRead = GUICtrlRead($idComboBox)
                $sIniRead = IniRead($sIni, 'answers', $sComboRead, "Sorry No answer available")
                GUICtrlSetData($idEditBox, $sIniRead)
        EndSwitch
    WEnd
EndFunc

Func _GuiToggle()
    If $bGuiHide = True Then
        $bGuiHide = False
        GUISetState(@SW_SHOW, $hGUI)
    Else
        $bGuiHide = True
        GUISetState(@SW_HIDE, $hGUI)
    EndIf
EndFunc

antwoorden.ini

[answers]
answer1=default answer line 1@CRLF@line 2 
answer2=default answer line 1@CRLF@line 2
test=test@CRLF@not recommended@CRLF@http://www.mywebsite.com/

 

Link to comment
Share on other sites

12 minutes ago, Subz said:

This is a little quick and dirty but maybe you want to try something like this:

expandcollapsepopup
#include <Array.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Opt('ExpandVarStrings', 1)

Global $hGUI
Global $bGuiHide = True
Global $sIni = @ScriptDir & "\antwoorden.ini"
Global $aIni = IniReadSection($sIni, 'answers')
    If @error Then Exit MsgBox(16, 'Error', 'Unable to read ini file')

HotKeySet("^1", "_GuiToggle")

Example()

While 1
    Sleep(50)
WEnd

Func Example()
    $hGUI = GUICreate("Example", 300, 200)

    Local $idComboBox = GUICtrlCreateCombo("", 10, 10, 280, 20, $CBS_DROPDOWNLIST)
    Local $idEditBox = GUICtrlCreateEdit('', 10, 40, 280, 120)
    Local $idClose = GUICtrlCreateButton("Close", 210, 170, 85, 25)

    GUICtrlSetData($idComboBox, _ArrayToString($aIni, '|', 1, -1, '|', 0, 0))

    If $bGuiHide = True Then
        GUISetState(@SW_HIDE, $hGUI)
    Else
        GUISetState(@SW_SHOW, $hGUI)
    EndIf

    Local $sComboRead = ""

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idClose
                GUISetState(@SW_HIDE)
                $bGuiHide = True
            Case $idComboBox
                $sComboRead = GUICtrlRead($idComboBox)
                $sIniRead = IniRead($sIni, 'answers', $sComboRead, "Sorry No answer available")
                GUICtrlSetData($idEditBox, $sIniRead)
        EndSwitch
    WEnd
EndFunc

Func _GuiToggle()
    If $bGuiHide = True Then
        $bGuiHide = False
        GUISetState(@SW_SHOW, $hGUI)
    Else
        $bGuiHide = True
        GUISetState(@SW_HIDE, $hGUI)
    EndIf
EndFunc

antwoorden.ini

[answers]
answer1=default answer line 1@CRLF@line 2 
answer2=default answer line 1@CRLF@line 2
test=test@CRLF@not recommended@CRLF@http://www.mywebsite.com/

 

I'll take a look at it, appreciate it, thanks!

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

×
×
  • Create New...