Jump to content
barkeeper

Too many enters in script

Recommended Posts

barkeeper

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
Jos

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


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
barkeeper
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
Subz

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
barkeeper
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
barkeeper
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
Subz

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
barkeeper
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

  • Similar Content

    • Pagi
      By Pagi
       
      <a href="index.php=4143b27b41db0a40c499202865c3e24d" class="menuitem " target="\_self"> "Menu Item 1" </a>
      Can you tell me if it´s possible to click this menu button? If yes, how? Cause I have no idea, I think i should use _IETagNameGetCollection
    • milkmoron
      By milkmoron
      https://www.autoitscript.com/forum/topic/153520-iuiautomation-ms-framework-automate-chrome-ff-ie/?do=findComment&comment=1156373 At least we have an element title: [Entered By:] class: [WindowsForms10.EDIT.app.0.30495d1_r9_ad1] Having the following values for all properties: Title is: <Entered By:> Class := <WindowsForms10.EDIT.app.0.30495d1_r9_ad1> controltype:= <UIA_EditControlTypeId> ,<50004> , (0000C354) 322;370;736;184 *** Parent Information top down *** 3: Title is: <View Activity> Class := <WindowsForms10.Window.8.app.0.30495d1_r9_ad1> controltype:= <UIA_WindowControlTypeId> ,<50032> , (0000C370) 306;72;784;605 "Title:=View Activity;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.30495d1_r9_ad1"" 2: Title is: <> Class := <WindowsForms10.Window.8.app.0.30495d1_r9_ad1> controltype:= <UIA_PaneControlTypeId> ,<50033> , (0000C371) 314;103;768;542 "Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.30495d1_r9_ad1"" 1: Title is: <> Class := <WindowsForms10.Window.8.app.0.30495d1_r9_ad1> controltype:= <UIA_PaneControlTypeId> ,<50033> , (0000C371) 314;103;749;451 "Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.30495d1_r9_ad1"" 0: Title is: <Delete> Class := <WindowsForms10.Window.8.app.0.30495d1_r9_ad1> controltype:= <UIA_PaneControlTypeId> ,<50033> , (0000C371) 314;122;749;432 "Title:=Delete;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.30495d1_r9_ad1"" ;~ *** Standard code maintainable *** #include "UIAWrappers.au3" AutoItSetOption("MustDeclareVars", 1) _UIA_setVar("oP1","Title:=View Activity;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.30495d1_r9_ad1") ;View Activity _UIA_setVar("oP2","Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.30495d1_r9_ad1") ; _UIA_setVar("oP3","Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.30495d1_r9_ad1") ; _UIA_setVar("oP4","Title:=Delete;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.30495d1_r9_ad1") ;Delete _UIA_setVar("EnteredBy:.mainwindow","title:=Entered By:;classname:=WindowsForms10.EDIT.app.0.30495d1_r9_ad1") ;~ Actions split away from logical/technical definition above can come from configfiles ;~_UIA_Action("oP1","highlight") _UIA_Action("oP1","setfocus") ;~_UIA_Action("oP2","highlight") _UIA_Action("oP2","setfocus") ;~_UIA_Action("oP3","highlight") _UIA_Action("oP3","setfocus") ;~_UIA_Action("oP4","highlight") _UIA_Action("oP4","setfocus") _UIA_action("EnteredBy:.mainwindow","setfocus") ;~ *** Standard code Flexible*** #include "UIAWrappers.au3" AutoItSetOption("MustDeclareVars", 1) Local $oP3=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=View Activity;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.30495d1_r9_ad1", $treescope_children) _UIA_Action($oP3,"setfocus") Local $oP2=_UIA_getObjectByFindAll($oP3, "Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.30495d1_r9_ad1", $treescope_children) _UIA_Action($oP2,"setfocus") Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.30495d1_r9_ad1", $treescope_children) _UIA_Action($oP1,"setfocus") Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=Delete;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.30495d1_r9_ad1", $treescope_children) _UIA_Action($oP0,"setfocus") _UIA_setVar("EnteredBy:.mainwindow","title:=Entered By:;classname:=WindowsForms10.EDIT.app.0.30495d1_r9_ad1") _UIA_action("EnteredBy:.mainwindow","setfocus") Need some help selecting this defining it as a variable to save and then insert the text within, to the same application but different account.
    • BogdanNicolescu
      By BogdanNicolescu
      While 1 / / / A whole bunch of codes found in help and here: https://www.autoitscript.com/autoit3/docs/ / / / WEnd OR:

       
      HotKeySet("{ESC}", "Terminate") While 1 MouseClick("Right",674,422) MouseClick("Left",673,447) Sleep(2000) / / / A whole bunch of codes found in help and here: https://www.autoitscript.com/autoit3/docs/ / / / MouseClick("Left",675,339) SLeep(3000) WEnd Func Terminate()     Exit 0 EndFunc  
      Sorry if i should't let this here to be found by newbies like me -.-'
    • PleaseHelpMEIWillLoveyou
      By PleaseHelpMEIWillLoveyou
      Is there a way to use a custom terminal or something from my pc and run a script on another pc.
      please let me know if its possible
      (not for anything bad just for a project im working on)
    • kelso
      By kelso
      Hello Guru's,
       
      I'm trying to write an autoit script to select from the dropdown list as you see in the attached picture. 
      I read the help page for _IEFormElementOptionSelect, but I cannot grasp how to correlate that with the source code that I'm seeing. any suggestions?

×