Jump to content

Selection of text full/incomplete


Recommended Posts

 

Hi and a great year for all.

Can someone help me with this code? I got diffents results. I call the function one time, i got the word full, but sometimes i got without the last letter. Regards.

#include <DotNet.au3>
#include <GuiEdit.au3>

Func OpText()
$Alfa = NET_ControlGetHandleByName($Fox, "", "txtA")
$Beta = NET_ControlGetHandleByName($Fox, "", "txtB")
If ControlCommand($Fox, "",$Beta, "GetSelected", "") = "" Then Send("+{HOME}")
$range = _GUICtrlEdit_GetSel($Beta)
If IsArray($range) Then
    If $range[0] <> $range[1] Then
        $SelectedText = StringMid(_GUICtrlEdit_GetText($Beta), $range[0] + 1, $range[1] - $range[0])
        $SelectedText = StringRegExpReplace($SelectedText,"[,:;.]" , "")
        $SelectedText = StringStripWS($SelectedText,7)
        ControlClick($Fox,"",$Alfa)
        If _IsFocused($Fox, $Alfa) Then
            _GUICtrlEdit_SetText($Alfa,StringUpper(StringLeft($SelectedText,1)) & StringTrimLeft($SelectedText,1))
            Send("^{END}")
        EndIf
    EndIf
EndIf
$SelectedText = 0
$Alfa = 0
$Beta = 0
$range = 0
$Fox = 0
EndFunc()

 

Edited by fxg4758
Link to comment
Share on other sites

Hi.

It's not possible to test your code. First error I see is the last line. It should be "EndFunc" in one word and w/o brackets.

But if I try to run your script I get a lot of errors:

"test2.au3"(1,26) : warning: $VK_ESCAPE: possibly used before declaration.
_HotKey_Assign($VK_ESCAPE,
~~~~~~~~~~~~~~~~~~~~~~~~~^
"test2.au3"(4,22) : warning: $Fox: possibly used before declaration.
_WinWaitActivate($Fox,
~~~~~~~~~~~~~~~~~~~~~^
"test2.au3"(1,26) : error: $VK_ESCAPE: undeclared global variable.
_HotKey_Assign($VK_ESCAPE,
~~~~~~~~~~~~~~~~~~~~~~~~~^
"test2.au3"(1,36) : error: _HotKey_Assign(): undefined function.
_HotKey_Assign($VK_ESCAPE, "OpText")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"test2.au3"(4,25) : error: _WinWaitActivate(): undefined function.
_WinWaitActivate($Fox,"")
~~~~~~~~~~~~~~~~~~~~~~~~^
"test2.au3"(5,58) : error: NET_ControlGetHandleByName(): undefined function.
Local $Alfa = NET_ControlGetHandleByName($Fox, "", "txtA")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"test2.au3"(8,41) : error: _GUICtrlEdit_GetSel(): undefined function.
Local $range = _GUICtrlEdit_GetSel($Beta)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"test2.au3"(12,61) : error: _GUICtrlEdit_GetText(): undefined function.
        $SelectedText = StringMid(_GUICtrlEdit_GetText($Beta)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"test2.au3"(16,34) : error: _IsFocused(): undefined function.
        If _IsFocused($Fox, $Alfa)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"test2.au3"(17,114) : error: _GUICtrlEdit_SetText(): undefined function.
            _GUICtrlEdit_SetText($Alfa,StringUpper(StringLeft($SelectedText,1)) & StringTrimLeft($SelectedText,1))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"test2.au3"(27,17) : error: _HotKey_Release(): undefined function.
_HotKey_Release()
~~~~~~~~~~~~~~~~^
test2.au3 - 9 error(s), 2 warning(s)

Try to serve a snippet everybody can run w/o errors except the one you are asking for. So someone is willing to help you.

Regards, Conrad

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Link to comment
Share on other sites

2 hours ago, Simpel said:

Hi.

It's not possible to test your code. First error I see is the last line. It should be "EndFunc" in one word and w/o brackets.

But if I try to run your script I get a lot of errors:

"test2.au3"(1,26) : warning: $VK_ESCAPE: possibly used before declaration.
_HotKey_Assign($VK_ESCAPE,
~~~~~~~~~~~~~~~~~~~~~~~~~^
"test2.au3"(4,22) : warning: $Fox: possibly used before declaration.
_WinWaitActivate($Fox,
~~~~~~~~~~~~~~~~~~~~~^
"test2.au3"(1,26) : error: $VK_ESCAPE: undeclared global variable.
_HotKey_Assign($VK_ESCAPE,
~~~~~~~~~~~~~~~~~~~~~~~~~^
"test2.au3"(1,36) : error: _HotKey_Assign(): undefined function.
_HotKey_Assign($VK_ESCAPE, "OpText")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"test2.au3"(4,25) : error: _WinWaitActivate(): undefined function.
_WinWaitActivate($Fox,"")
~~~~~~~~~~~~~~~~~~~~~~~~^
"test2.au3"(5,58) : error: NET_ControlGetHandleByName(): undefined function.
Local $Alfa = NET_ControlGetHandleByName($Fox, "", "txtA")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"test2.au3"(8,41) : error: _GUICtrlEdit_GetSel(): undefined function.
Local $range = _GUICtrlEdit_GetSel($Beta)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"test2.au3"(12,61) : error: _GUICtrlEdit_GetText(): undefined function.
        $SelectedText = StringMid(_GUICtrlEdit_GetText($Beta)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"test2.au3"(16,34) : error: _IsFocused(): undefined function.
        If _IsFocused($Fox, $Alfa)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"test2.au3"(17,114) : error: _GUICtrlEdit_SetText(): undefined function.
            _GUICtrlEdit_SetText($Alfa,StringUpper(StringLeft($SelectedText,1)) & StringTrimLeft($SelectedText,1))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"test2.au3"(27,17) : error: _HotKey_Release(): undefined function.
_HotKey_Release()
~~~~~~~~~~~~~~~~^
test2.au3 - 9 error(s), 2 warning(s)

Try to serve a snippet everybody can run w/o errors except the one you are asking for. So someone is willing to help you.

Regards, Conrad

Hi Simpel.

Thanks for your help. I made a update in the code. My problem is when i send the keys to select the text and made the replaces, sometimes it cuts the last letter. I don´t understand if is because i delete the spaces or is a error in the numer of characters to return. Regards.

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