PDA

Показать полную графическую версию : Получение данныз из формы в GUI c последующей отправкой в статус-бар.


winipox
25-09-2011, 22:46
Здравствуйте, возникла такая проблема - необходимо из созданной формы получить текст в статус-бар в следующем коде:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 299, 253, 254, 124)
$Input1 = GUICtrlCreateInput("Input1", 8, 16, 81, 21)
$StatusBar1 = _GUICtrlStatusBar_Create($Form1)
_GUICtrlStatusBar_SetText($StatusBar1, "03 "& GUIctrlread($Input1))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

EndSwitch
WEnd

Так как написано тут в статус-баре пишет Input1, но не как не то что я пишу после запуска, к чему и стремлюсь.

madmasles
25-09-2011, 23:27
winipox,
Попробуйте так.#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <GUIConstantsEx.au3>
#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <GuiStatusBar.au3>
#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <WindowsConstants.au3>
#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <EditConstants.au3>

$hForm = GUICreate (http://www.autoitscript.com/autoit3/docs/functions/GUICreate.htm)('Test', 299, 253, 254, 124)
$nInput = GUICtrlCreateInput (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateInput.htm)('Input', 8, 16, 81, 21)
$hStatusBar = _GUICtrlStatusBar_Create (http://dundats.mvps.org/help/html/libfunctions/_guictrlstatusbar_create.htm)($hForm)
_GUICtrlStatusBar_SetText (http://dundats.mvps.org/help/html/libfunctions/_guictrlstatusbar_settext.htm)($hStatusBar, '03 ' & GUICtrlRead (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlRead.htm)($nInput))
GUISetState (http://www.autoitscript.com/autoit3/docs/functions/GUISetState.htm)()
GUIRegisterMsg (http://www.autoitscript.com/autoit3/docs/functions/GUIRegisterMsg.htm)($WM_COMMAND, 'WM_COMMAND')

While (http://www.autoitscript.com/autoit3/docs/keywords.htm#While) 1
$nMsg = GUIGetMsg (http://www.autoitscript.com/autoit3/docs/functions/GUIGetMsg.htm)()
Switch (http://www.autoitscript.com/autoit3/docs/keywords.htm#Switch) $nMsg
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $GUI_EVENT_CLOSE
Exit (http://www.autoitscript.com/autoit3/docs/keywords.htm#Exit)
EndSwitch (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndSwitch)
WEnd (http://www.autoitscript.com/autoit3/docs/keywords.htm#WEnd)

Func (http://www.autoitscript.com/autoit3/docs/keywords.htm#Func) WM_COMMAND($hWnd, $imsg, $iwParam, $ilParam)
Local (http://www.autoitscript.com/autoit3/docs/keywords.htm#Local) $nNotifyCode, $nID
$nNotifyCode = BitShift (http://www.autoitscript.com/autoit3/docs/functions/BitShift.htm)($iwParam, 16)
$nID = BitAND (http://www.autoitscript.com/autoit3/docs/functions/BitAND.htm)($iwParam, 0xFFFF)
Switch (http://www.autoitscript.com/autoit3/docs/keywords.htm#Switch) $hWnd
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $hForm
Switch (http://www.autoitscript.com/autoit3/docs/keywords.htm#Switch) $nID
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $nInput
Switch (http://www.autoitscript.com/autoit3/docs/keywords.htm#Switch) $nNotifyCode
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $EN_UPDATE;$EN_CHANGE
_GUICtrlStatusBar_SetText (http://dundats.mvps.org/help/html/libfunctions/_guictrlstatusbar_settext.htm)($hStatusBar, '03 ' & GUICtrlRead (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlRead.htm)($nInput))
EndSwitch (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndSwitch)
EndSwitch (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndSwitch)
EndSwitch (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndSwitch)
Return (http://www.autoitscript.com/autoit3/docs/keywords.htm#Return) $GUI_RUNDEFMSG
EndFunc (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndFunc) ;==>WM_COMMAND

winipox
26-09-2011, 22:28
В посте выше все более-мене понятно за исключением самих принципов языка autoit. Какие операции необходимо прописывать чтобы данные из гуй можно было обрабатывать(а именно читать - посылать)?

madmasles
27-09-2011, 01:10
а именно читать - посылать »Что читать? Что и куда посылать?

ven00m
27-09-2011, 15:37
Еще вариант (попроще):
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 299, 253, 254, 124)
$Input1 = GUICtrlCreateInput("Input1", 8, 16, 81, 21)
$StatusBar1 = _GUICtrlStatusBar_Create($Form1)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$input1old = GUIctrlread($Input1)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

EndSwitch

if GUIctrlread($Input1)<>$input1old then
_GUICtrlStatusBar_SetText($StatusBar1, "03 "& GUIctrlread($Input1))
$input1old = GUIctrlread($Input1)
Endif
WEnd




© OSzone.net 2001-2012