Jump to content
Sign in to follow this  
barkeeper

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

Share this post


Link to post
Share on other sites

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.
  :)

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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

 

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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/

 

Share this post


Link to post
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!

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Jamestay97
      Hello! Thanks you for looking at my post
      **No source code I'm sorry work related can't copy information**
      I've been using autoit for about 1 year. 
      I'm having trouble automating a click on an internet explorer web page and I've tried a lot of examples from help pages and forums already. The object I'm trying to click on isnt always in the same spot so I can't use mouse click or control click, I have tried to use the different get collection options and clickbyname, or index or get object. I'm just struggling. 
      Description of object I'm trying to click -- 
      HTML Code looks like <a ng-click.. "Click Here" it appears it's just a click able object named "click here" that opens a hidden window by running a script inside the web page. I'm not able to grab the information from the window unless it's open so I have to automate this click somehow. 
       
      I understand it's difficult to assist without having something to look at, I apologize for that sincerely and appreciate and assistance and suggestions. 
    • By kingjacob90
      Hi
      So I am trying to click the green button, this button is not always in the same place. So fare I am trying to click it by finding the color but there is also something else with the same color on the screen (circled in yellow) that is causing issues. Is there a way to use the Title and Class of the window (can't be just the window as there are more than one with the same name).
      How does AutoIt Info get this information?

    • By adjist
      Hello all! 
       
      Getting this error :
      (22) : ==> Variable used without being declared.: if $vNumber = 0 Then if ^ ERROR  
      But I'm sure I have defined the variable, as in the top of my script has 
      Global $vNumber = 0  
      How would I go about fixing this?
       
    • By MarkIT
      Hi AutoIT masters,
      Good day! Sorry to have bothered this forum but we really need help. We are working on an automation project that is running on VDI server. The BOTS are in .exe are running fine until AV detected them and deleted the files. The files were re-compiled and AV kept on deleting them. The copy of the .exe BOT deleted were sent to Symantec for whitelisting. After whitelisting, it is no longer deleted but no longer working as designed (showing Line script error). We checked the scripts and there were no issues since we run it using SciTE editor and it performed the desired task. Good thing we found on this thread the solution using .a3x and the BOTS worked fine and no longer deleted. Now, the problem is they are asking why the BOTS won't run in .EXE and what is the reason behind Symantec AV deleting them. We raised a case with Symantec but they cannot provide further information as they are always seeing the file as "False Positive". We even tested with Symantec turned off and those .EXE files are working fine, however, after re-enabling, it got deleted.
      Just seeking help on how to better convince them that it is really Symantec causing the issue and the .a3x file.
    • By v120
      Original posted by CoePSX
       
       
       
       
      Drawing_Script.au3
×
×
  • Create New...