Jump to content
Sign in to follow this  
22xboss

last focused element

Recommended Posts

22xboss

How to enter numbers to last focused input field when pressing a Autoit GUI button? I am trying to create a program for touch screen computer without using  - on screen keyboard  or keyboard to enter numbers in last active input field using program buttons to generate numbers

program example :

#Include <GUIConstants.Au3>
Opt ('GUIOnEventMode','1')

Global $Button_Row['5']['4'], $Display_String = '', $Real_String = ''

GUICreate ('test','151','300','-1','-1','-1','144')
GUISetOnEvent ($GUI_EVENT_CLOSE, '_Exit')
$Display = GUICtrlCreateInput ('','11','15','129','20','1')
$Display1 = GUICtrlCreateInput ('','11','130','129','20','1')
$Display2 = GUICtrlCreateInput ('','11','155','129','20','1')
$Display3 = GUICtrlCreateInput ('','11','180','129','20','1')
GUICtrlSetFont ($Display, '10','','','New Times Roman')
_Create_Buttons ()
_Set_Text ()
GUISetState (@SW_SHOW)
5899
While ('1')
Sleep ('750')
WEnd

Func _Create_Buttons ()
Local $Top = ('0')
For $Array_1 = '1' To '3'
For $Array_2 = '0' To '2'
$Button_Row[$Array_1][$Array_2] = GUICtrlCreateButton ('','30' * $Array_2 + '18', '50' + $Top, '25','23')
GUICtrlSetState (-1, $GUI_NOFOCUS)
GUICtrlSetFont ('-1', '10','','','Arial')
Next
$Top = $Top + '26'
Next
EndFunc

Func _Set_Text ()
GUICtrlSetData ($Button_Row['1']['0'], '7')
GUICtrlSetOnEvent ($Button_Row['1']['0'], '_Set_7')
GUICtrlSetData ($Button_Row['1']['1'], '8')
GUICtrlSetOnEvent ($Button_Row['1']['1'], '_Set_8')
GUICtrlSetData ($Button_Row['1']['2'], '9')
GUICtrlSetOnEvent ($Button_Row['1']['2'], '_Set_9')
GUICtrlSetData ($Button_Row['2']['0'], '4')
GUICtrlSetOnEvent ($Button_Row['2']['0'], '_Set_4')
GUICtrlSetData ($Button_Row['2']['1'], '5')
GUICtrlSetOnEvent ($Button_Row['2']['1'], '_Set_5')
GUICtrlSetData ($Button_Row['2']['2'], '6')
GUICtrlSetOnEvent ($Button_Row['2']['2'], '_Set_6')
GUICtrlSetData ($Button_Row['3']['0'], '1')
GUICtrlSetOnEvent ($Button_Row['3']['0'], '_Set_1')
GUICtrlSetData ($Button_Row['3']['1'], '2')
GUICtrlSetOnEvent ($Button_Row['3']['1'], '_Set_2')
GUICtrlSetData ($Button_Row['3']['2'], '3')
GUICtrlSetOnEvent ($Button_Row['3']['2'], '_Set_3')
GUICtrlSetData ($Button_Row['4']['0'], '0')
GUICtrlSetOnEvent ($Button_Row['4']['0'], '_Set_0')
EndFunc

Func _Set_0 ()
_Set_Number ('0')
EndFunc

Func _Set_1 ()
_Set_Number ('1')
EndFunc

Func _Set_2 ()
_Set_Number ('2')
EndFunc

Func _Set_3 ()
_Set_Number ('3')
EndFunc

Func _Set_4 ()
_Set_Number ('4')
EndFunc

Func _Set_5 ()
_Set_Number ('5')
EndFunc

Func _Set_6 ()
_Set_Number ('6')
EndFunc

Func _Set_7 ()
_Set_Number ('7')
EndFunc

Func _Set_8 ()
_Set_Number ('8')
EndFunc

Func _Set_9 ()
_Set_Number ('9')
EndFunc

Func _Set_Number ($Number)
$Display_String = ($Display_String & $Number)
$Real_String = ($Real_String & $Number)
GUICtrlSetData ($Display,$Display_String )

;MsgBox($MB_SYSTEMMODAL, "Title", , "30")
EndFunc

Func _Exit ()
Exit
EndFunc

 

Share this post


Link to post
Share on other sites
Synapsee

something like :

#Include <GUIConstants.Au3>
Opt ('GUIOnEventMode','1')

Global $Button_Row['5']['4'], $Display_String = '', $Real_String = ''

$hGui = GUICreate ('test','151','300','-1','-1','-1','144')
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_MOUSEDOWN")
GUISetOnEvent($GUI_EVENT_SECONDARYDOWN, "_MOUSEDOWN")
GUISetOnEvent ($GUI_EVENT_CLOSE, '_Exit')
$Display = GUICtrlCreateInput ('','11','15','129','20','1')
$Display1 = GUICtrlCreateInput ('','11','130','129','20','1')
$Display2 = GUICtrlCreateInput ('','11','155','129','20','1')
$Display3 = GUICtrlCreateInput ('','11','180','129','20','1')
GUICtrlSetFont ($Display, '10','','','New Times Roman')
_Create_Buttons ()
_Set_Text ()
Local $CurrentDisplay = $Display

GUISetState (@SW_SHOW)

While ('1')
Sleep ('750')
WEnd

Func _MOUSEDOWN()
    $aCInfo = GUIGetCursorInfo($hGUI)


        Switch $aCInfo[4]
            Case $Display
                $CurrentDisplay = $Display
            Case $Display1
                $CurrentDisplay = $Display1
            Case $Display2
                $CurrentDisplay = $Display2
            Case $Display3
                $CurrentDisplay = $Display3
        EndSwitch


EndFunc



Func _Create_Buttons ()
Local $Top = ('0')
For $Array_1 = '1' To '3'
For $Array_2 = '0' To '2'
$Button_Row[$Array_1][$Array_2] = GUICtrlCreateButton ('','30' * $Array_2 + '18', '50' + $Top, '25','23')
GUICtrlSetState (-1, $GUI_NOFOCUS)
GUICtrlSetFont ('-1', '10','','','Arial')
Next
$Top = $Top + '26'
Next
EndFunc

Func _Set_Text ()
GUICtrlSetData ($Button_Row['1']['0'], '7')
GUICtrlSetOnEvent ($Button_Row['1']['0'], '_Set_7')
GUICtrlSetData ($Button_Row['1']['1'], '8')
GUICtrlSetOnEvent ($Button_Row['1']['1'], '_Set_8')
GUICtrlSetData ($Button_Row['1']['2'], '9')
GUICtrlSetOnEvent ($Button_Row['1']['2'], '_Set_9')
GUICtrlSetData ($Button_Row['2']['0'], '4')
GUICtrlSetOnEvent ($Button_Row['2']['0'], '_Set_4')
GUICtrlSetData ($Button_Row['2']['1'], '5')
GUICtrlSetOnEvent ($Button_Row['2']['1'], '_Set_5')
GUICtrlSetData ($Button_Row['2']['2'], '6')
GUICtrlSetOnEvent ($Button_Row['2']['2'], '_Set_6')
GUICtrlSetData ($Button_Row['3']['0'], '1')
GUICtrlSetOnEvent ($Button_Row['3']['0'], '_Set_1')
GUICtrlSetData ($Button_Row['3']['1'], '2')
GUICtrlSetOnEvent ($Button_Row['3']['1'], '_Set_2')
GUICtrlSetData ($Button_Row['3']['2'], '3')
GUICtrlSetOnEvent ($Button_Row['3']['2'], '_Set_3')
GUICtrlSetData ($Button_Row['4']['0'], '0')
GUICtrlSetOnEvent ($Button_Row['4']['0'], '_Set_0')
EndFunc

Func _Set_0 ()
_Set_Number ('0')
EndFunc

Func _Set_1 ()
_Set_Number ('1')
EndFunc

Func _Set_2 ()
_Set_Number ('2')
EndFunc

Func _Set_3 ()
_Set_Number ('3')
EndFunc

Func _Set_4 ()
_Set_Number ('4')
EndFunc

Func _Set_5 ()
_Set_Number ('5')
EndFunc

Func _Set_6 ()
_Set_Number ('6')
EndFunc

Func _Set_7 ()
_Set_Number ('7')
EndFunc

Func _Set_8 ()
_Set_Number ('8')
EndFunc

Func _Set_9 ()
_Set_Number ('9')
EndFunc

Func _Set_Number ($Number)
$Display_String = (GUICtrlRead($CurrentDisplay) & $Number)
$Real_String = ($Real_String & $Number)
GUICtrlSetData ($CurrentDisplay,$Display_String )

;MsgBox($MB_SYSTEMMODAL, "Title", , "30")
EndFunc

Func _Exit ()
Exit
EndFunc

 

  • Like 1

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.