Jump to content

Loosing Focus!


Recommended Posts

how can i set the Ibeam to not become inactive in an input box...

i want to use buttons on screen to send keys into an input box but every time i click the created button,

the Ibeam would be out of the inputbox so nothing would be inputted

Link to comment
Share on other sites

Wait... you mean you want something like this?

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 296, 231, 200, 135)
$Button1 = GUICtrlCreateButton("Hello", 32, 184, 225, 25, 0)
$Input1 = GUICtrlCreateInput("", 40, 64, 201, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            GUICtrlSetData($Input1,GUICtrlRead($Input1)&"Hello")
    EndSwitch
WEnd

Or you want to send text to an external window? Would you mind re-phrasing your question for non-english speaking people? :)

Link to comment
Share on other sites

I came up with this...

#include <GUIConstants.au3>
#Include <GuiEdit.au3>
$GUI = GUICreate ("Not Loose Focus in Edit", 400, 400)
$edit = GUICtrlCreateEdit ("", 0, 0, 250, 400, $ES_NOHIDESEL + $ES_WANTRETURN)
$btn1 = GUICtrlCreateButton ("INSERT: AN", 250, 0, 150, 30)
$btn2 = GUICtrlCreateButton ("INSERT: EXAMPLE", 250, 30, 150, 30)
$btn3 = GUICtrlCreateButton ("INSERT: PHRASE", 250, 60, 150, 30)
$btn4 = GUICtrlCreateButton ("INSERT: CAN", 250, 90, 150, 30)
$btn5 = GUICtrlCreateButton ("INSERT: BE", 250, 120, 150, 30)
$btn6 = GUICtrlCreateButton ("INSERT: INSERTED", 250, 150, 150, 30)
GUISetState ()

ControlFocus ($GUI, "", $edit)

While 1
    Switch GUIGetMsg ()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $btn1
            $text = "AN"
            _GUICtrlEditReplaceSel ($edit, TRUE, $text)
            ControlFocus ($GUI, "", $edit)
        Case $btn2
            $text = "EXAMPLE"
            _GUICtrlEditReplaceSel ($edit, TRUE, $text)
            ControlFocus ($GUI, "", $edit)
        Case $btn3
            $text = "PHRASE"
            _GUICtrlEditReplaceSel ($edit, TRUE, $text)
            ControlFocus ($GUI, "", $edit)
        Case $btn4
            $text = "CAN"
            _GUICtrlEditReplaceSel ($edit, TRUE, $text)
            ControlFocus ($GUI, "", $edit)
        Case $btn5
            $text = "BE"
            _GUICtrlEditReplaceSel ($edit, TRUE, $text)
            ControlFocus ($GUI, "", $edit)
        Case $btn6
            $text = "INSERTED"
            _GUICtrlEditReplaceSel ($edit, TRUE, $text)
            ControlFocus ($GUI, "", $edit)
    EndSwitch
WEnd
Edited by Bert
Link to comment
Share on other sites

Wait... you mean you want something like this?

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 296, 231, 200, 135)
$Button1 = GUICtrlCreateButton("Hello", 32, 184, 225, 25, 0)
$Input1 = GUICtrlCreateInput("", 40, 64, 201, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            GUICtrlSetData($Input1,GUICtrlRead($Input1)&"Hello")
    EndSwitch
WEnd

Or you want to send text to an external window? Would you mind re-phrasing your question for non-english speaking people? :)

yes this is what i wanted.... but can the $Input1 change depending on what inputbox my Ibeam is current in??

so if my Ibeam is in $Input2 GUICtrlSetData($Input2,GUICtrlRead($Input2)&"Hello")

Link to comment
Share on other sites

I came up with this...

#include <GUIConstants.au3>
#Include <GuiEdit.au3>
$GUI = GUICreate ("Not Loose Focus in Edit", 400, 400)
$edit = GUICtrlCreateEdit ("", 0, 0, 250, 400, $ES_NOHIDESEL + $ES_WANTRETURN)
$btn1 = GUICtrlCreateButton ("INSERT: AN", 250, 0, 150, 30)
$btn2 = GUICtrlCreateButton ("INSERT: EXAMPLE", 250, 30, 150, 30)
$btn3 = GUICtrlCreateButton ("INSERT: PHRASE", 250, 60, 150, 30)
$btn4 = GUICtrlCreateButton ("INSERT: CAN", 250, 90, 150, 30)
$btn5 = GUICtrlCreateButton ("INSERT: BE", 250, 120, 150, 30)
$btn6 = GUICtrlCreateButton ("INSERT: INSERTED", 250, 150, 150, 30)
GUISetState ()

ControlFocus ($GUI, "", $edit)

While 1
    Switch GUIGetMsg ()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $btn1
            $text = "AN"
            _GUICtrlEditReplaceSel ($edit, TRUE, $text)
            ControlFocus ($GUI, "", $edit)
        Case $btn2
            $text = "EXAMPLE"
            _GUICtrlEditReplaceSel ($edit, TRUE, $text)
            ControlFocus ($GUI, "", $edit)
        Case $btn3
            $text = "PHRASE"
            _GUICtrlEditReplaceSel ($edit, TRUE, $text)
            ControlFocus ($GUI, "", $edit)
        Case $btn4
            $text = "CAN"
            _GUICtrlEditReplaceSel ($edit, TRUE, $text)
            ControlFocus ($GUI, "", $edit)
        Case $btn5
            $text = "BE"
            _GUICtrlEditReplaceSel ($edit, TRUE, $text)
            ControlFocus ($GUI, "", $edit)
        Case $btn6
            $text = "INSERTED"
            _GUICtrlEditReplaceSel ($edit, TRUE, $text)
            ControlFocus ($GUI, "", $edit)
    EndSwitch
WEnd
is it possible for this to work if i have more than 1 inputbox?
Link to comment
Share on other sites

This is what I did. It doesn't work the way you want yet.

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 296, 231, 200, 135)
$Button1 = GUICtrlCreateButton("Hello", 32, 184, 225, 25, 0)
$Input1 = GUICtrlCreateInput("", 40, 64, 201, 21)
$Input2 = GUICtrlCreateInput("", 40, 94, 201, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$input=$Input1
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $input1
            $input=$input1
        Case $input2
            $input=$input2
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            GUICtrlSetData($Input,GUICtrlRead($Input)&"Hello")
    EndSwitch
WEnd

It will send 'hello' to the last input you typed something in. For example, type something in the first one and press the button. It will send hello to that inputbox. Now type something in the second one and press the button, will send hello to that inputbox.

There's a way of doing it the way you want, let me see if I can find that UDF...

Link to comment
Share on other sites

This will send 'hello' to the inputbox your mouse is over... not what you want, but might give you ideas. I'm off to bed now.

#include <GUIConstants.au3>
#include <_ControlHover.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 296, 231, 200, 135)
$Button1 = GUICtrlCreateButton("Hello", 32, 184, 225, 25, 0)
$Input1 = GUICtrlCreateInput("", 40, 64, 201, 21)
$Input2 = GUICtrlCreateInput("", 40, 94, 201, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$input=$Input1
_ControlHover(2, "", $Input1); add controls here
_ControlHover(2, "", $Input2); add controls here
While 1
    Sleep(25)
    $Over = _ControlHover(0, $Form1); or _ControlHover() - or _ControlHover(0)
    If $Over = 1 Then
        $tempID = @extended
        If $tempID = $input1 Then 
            GUICtrlSetData($Input1,GUictrlread($Input1)&"Hello")
        EndIf
        If $tempID = $input2 Then 
            GUICtrlSetData($Input2,GUictrlread($Input2)&"Hello")
        EndIf
        
    EndIf
            
    
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $input1
            $input=$input1
        Case $input2
            $input=$input2
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            GUICtrlSetData($Input,GUICtrlRead($Input)&"Hello")
    EndSwitch
WEnd

PS. You'll need _ControlHover.au3

Link to comment
Share on other sites

This will send 'hello' to the inputbox your mouse is over... not what you want, but might give you ideas. I'm off to bed now.

#include <GUIConstants.au3>
#include <_ControlHover.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 296, 231, 200, 135)
$Button1 = GUICtrlCreateButton("Hello", 32, 184, 225, 25, 0)
$Input1 = GUICtrlCreateInput("", 40, 64, 201, 21)
$Input2 = GUICtrlCreateInput("", 40, 94, 201, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$input=$Input1
_ControlHover(2, "", $Input1); add controls here
_ControlHover(2, "", $Input2); add controls here
While 1
    Sleep(25)
    $Over = _ControlHover(0, $Form1); or _ControlHover() - or _ControlHover(0)
    If $Over = 1 Then
        $tempID = @extended
        If $tempID = $input1 Then 
            GUICtrlSetData($Input1,GUictrlread($Input1)&"Hello")
        EndIf
        If $tempID = $input2 Then 
            GUICtrlSetData($Input2,GUictrlread($Input2)&"Hello")
        EndIf
        
    EndIf
            
    
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $input1
            $input=$input1
        Case $input2
            $input=$input2
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            GUICtrlSetData($Input,GUICtrlRead($Input)&"Hello")
    EndSwitch
WEnd

PS. You'll need _ControlHover.au3

TY!!! i got it to work

i just edited this script of yours a bit

#include <GUIConstants.au3>
#include <_ControlHover.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 296, 231, 200, 135)
$Button1 = GUICtrlCreateButton("Hello", 32, 184, 225, 25, 0)
$Input1 = GUICtrlCreateInput("", 40, 64, 201, 21)
$Input2 = GUICtrlCreateInput("", 40, 94, 201, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$input=$Input1
_ControlHover(2, "", $Input1); add controls here
_ControlHover(2, "", $Input2); add controls here
While 1
    Sleep(25)
    $Over = _ControlHover(0, $Form1); or _ControlHover() - or _ControlHover(0)
    If $Over = 1 Then
        $tempID = @extended
        If $tempID = $input1 Then
           $Input= $INput1
        EndIf
        If $tempID = $input2 Then
           $input = $input2
        EndIf
        
    EndIf
            
    
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            GUICtrlSetData($Input,GUICtrlRead($Input)&"Hello")
    EndSwitch
WEnd
Link to comment
Share on other sites

#include <GUIConstants.au3>
#include <_ControlHover.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 296, 231, 100, 135)
$Button1 = GUICtrlCreateButton("Hello", 32, 184, 225, 25, 0)
$Input1 = GUICtrlCreateInput("", 40, 64, 201, 21)
$Input2 = GUICtrlCreateInput("", 40, 94, 201, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Form2", 296, 231, 300, 135,-1,-1,$Form1)
$Input3 = GUICtrlCreateInput("", 40, 64, 201, 21)
$Input4 = GUICtrlCreateInput("", 40, 94, 201, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


_ControlHover(2, "", $Input1); add controls here
_ControlHover(2, "", $Input2); add controls here
_ControlHover(2, "", $Input3); add controls here
_ControlHover(2, "", $Input4); add controls here
$input=$input1
While 1
    Sleep(25)
    $Over = _ControlHover(0, $Form1); or _ControlHover() - or _ControlHover(0)
   ; or _ControlHover() - or _ControlHover(0)
    If $Over = 1 Then
        $tempID = @extended
        If $tempID = $input1 Then
           $Input= $INput1
        EndIf
        If $tempID = $input2 Then
           $input = $input2
        EndIf
        
    EndIf
    $Over2 = _ControlHover(0, $Form2)
    If $Over2 = 1 Then
        $tempID1 = @extended
        If $tempID1 = $input3 Then
           $Input= $INput3
        EndIf
        If $tempID1 = $input4 Then
           $input = $input4
        EndIf
        
    EndIf
            
    
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[0]
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            GUICtrlSetData($Input,GUICtrlRead($Input)&"Hello")
    EndSwitch
WEnd

Link to comment
Share on other sites

hey!!, do you know how to get it to send if my buttons and inputbox where in different Guis?

ControlSend should do the job. :) Use AutoIt V3 Info tool to get the control names... ;)
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...