Jump to content
Sign in to follow this  
Gustavo Lago

Highlighted text in GUI Input

Recommended Posts

Gustavo Lago

How to select the all text of the GUI Input when to catch the focus?

thanks,

Gustavo

Share this post


Link to post
Share on other sites
jvanegmond

This is the best I can come up with. Press Close to select:

#include <GUIConstants.au3>
$Form1 = GUICreate("AForm1", 297, 236)
$Edit1 = GUICtrlCreateEdit("Text to select??", 0,0,297,236)
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        GUICtrlSetState($Edit1,$GUI_FOCUS)
        Send("+{HOME}")
    EndSelect
WEnd
Exit

If I were to rate this, I wouldn't even give it a 4 out of 10. It's a bad solution to a simple problem I can't get my head around..

Share this post


Link to post
Share on other sites
Gustavo Lago

Tanks!!

My code:

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form", 203, 160, 193, 115)
$Input1 = GUICtrlCreateInput("00", 16, 32, 41, 26, BitOR($ES_CENTER, $ES_AUTOHSCROLL, $ES_NUMBER))
GUICtrlSetLimit(-1,2)
$Input2 = GUICtrlCreateInput("12345678", 72, 32, 113, 26, BitOR($ES_CENTER, $ES_AUTOHSCROLL, $ES_NUMBER))
GUICtrlSetLimit(-1,8)
$Button1 = GUICtrlCreateButton("&Consultar", 16, 128, 75, 25, 0)
$Button2 = GUICtrlCreateButton("&Fechar", 112, 128, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$Foco = ""
While 1
   $nMsg = GUIGetMsg()
  ;If $nMsg <> 0 Then;GUICtrlSetData($Label1, ControlGetFocus(""))
   Switch $nMsg
      Case $GUI_EVENT_CLOSE
         Exit
      Case $Button1
        ;;;;;;;
      Case Else
         If $Foco <> ControlGetFocus("") Then
            $Foco = ControlGetFocus("")
             If $Foco = "Edit1" Or $Foco = "Edit2"Then
               Sleep(100)
               Send("{HOME}+{END}")
            EndIf
         EndIf
   EndSwitch
WEnd

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.