Jump to content
DickG

Setting cursor pos inside input box

Recommended Posts

DickG

When I open a GUI that has an Input box, and the text for that box is long, the text has scrolled all the way to the right. I would like it to show the beginning of the text rather than the end. So I have to click inside the box and press Home to read the beginning.

Is there a way to do make it scroll left in the Input box?

Share this post


Link to post
Share on other sites
water

Maybe this thread helps


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Melba23

DickG,

Or perhaps like this:

#include <GUIConstantsEx.au3>

$sText = "A nice long string to get the input scrolled to the right"

$hGUI = GUICreate("Test", 500, 500)

$cInput = GUICtrlCreateInput($sText, 10, 10, 200, 20)

GUISetState()

ControlSend($hGUI, "", $cInput, "{HOME}")

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

M23

  • Like 2

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
water

This Google search will return similar results.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
DickG

Maybe this thread helps

Awesome! That works great! I could not find anything on this forum when I typed "cursor position input box". I was not aware of the _GUICtrlEdit_SetSel() command. I guess searching the AutoIt forums gives me better results from Google! :-)

Thanks much, water.

Share this post


Link to post
Share on other sites
water

Correct. At the moment Google gives the best search results as the forums search feature is awful since the last upgrade :(
Did you try the solution Melba provided? I think this is even more elegnat as it doesn't need to include a whole UDF.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
UEZ

My idea:

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

AutoItSetOption("GUIOnEventMode", 1)

Global Const $hGUI = GUICreate("Test", 232, 90)
Global Const $iInput = GUICtrlCreateInput("", 42, 30, 140), $hInput = GUICtrlGetHandle($iInput)
Global Const $iButton = GUICtrlCreateButton("OK", 190, 50, 32, 32)
GUISetState()

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

While Sleep(100)
WEnd

Func _Exit()
    GUIDelete()
    Exit
EndFunc

Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg
    Local $iIDFrom = _WinAPI_LoWord($iwParam)
    Local $iCode = _WinAPI_HiWord($iwParam)
    Local $sInput, $aPosCtrl, $aPosWin
    Switch $ilParam
        Case $hInput
            Switch $iCode
                Case $EN_SETFOCUS
                    ControlClick($hGUI, "", $iInput, "", 1, 1)
                Case $EN_CHANGE
                    $sInput = GUICtrlRead($iInput)
                    If StringLen($sInput) > 22 Then
                        $aPosWin = WinGetPos($hGUI)
                        $aPosCtrl = ControlGetPos($hGUI, "", $iInput)
                        ToolTip($sInput, -100 + $aPosWin[0] + $aPosCtrl[0], $aPosWin[1] + $aPosCtrl[1])
                    EndIf
                Case $EN_KILLFOCUS
                    ToolTip("")
            EndSwitch
    EndSwitch
    Return "GUI_RUNDEFMSG"
EndFunc   ;==>WM_COMMAND

 

Edit: forget it, I got you wrong -> new year hangover :drinks:

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
DickG

DickG,

Or perhaps like this:

#include <GUIConstantsEx.au3>

$sText = "A nice long string to get the input scrolled to the right"

$hGUI = GUICreate("Test", 500, 500)

$cInput = GUICtrlCreateInput($sText, 10, 10, 200, 20)

GUISetState()

ControlSend($hGUI, "", $cInput, "{HOME}")

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

M23

Thanks, Melba. I tried it, but couldn't get it to work. I must be doing something wrong because your sample does indeed work. But the _GUICtrlEdit_SetSel() command works for me, so I'll be using that.

Share this post


Link to post
Share on other sites
mikell

:)

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>

$sText = "A nice long string to get the input scrolled to the right"

$hGUI = GUICreate("Test", 300, 100)
$cInput = GUICtrlCreateInput($sText, 10, 10, 200, 20)
GUISetState()
GuiCtrlSendMsg($cInput, $EM_SETSEL, 0, 0)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

 

  • Like 1

Share this post


Link to post
Share on other sites
DickG

:)

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>

$sText = "A nice long string to get the input scrolled to the right"

$hGUI = GUICreate("Test", 300, 100)
$cInput = GUICtrlCreateInput($sText, 10, 10, 200, 20)
GUISetState()
GuiCtrlSendMsg($cInput, $EM_SETSEL, 0, 0)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Awesome!

GuiCtrlSendMsg($cInput, $EM_SETSEL, 0, 0) also works great! Now I have two great ways to do this!

Thanks much, mikell!

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

×