LT_STTS

How to Copy Combobox value and paste into a Inputbox

11 posts in this topic

Hi

Please refer to GUI notes.jpg for explanation of the problem I encountered. Red color arrows and notes are the problematic area. Blue color "OK" means those are working.

$idButton2 objective - I need to let user copy and paste the Payload(Combo GUI) value into Cargo Quantity(Input GUI) and display the value.

User could also key in the number for Cargo Quantity If they want to.

Please look at attached  test UI_a.au3 and run it to check it. Please suggest a code for the $idButton2  objective. I have tried using GUICtrlSetData but don't seems to work.

Jpg files.rar contains all graphic labels for test UI_a.au3.

Thanks for helping, Cheers.

test UI_a.au3

Jpg files.rar

GUI Notes.jpg

Share this post


Link to post
Share on other sites



Just use GuiCtrlRead the get the value from the combo and GuiCtrlSetData to assing the value to the input.

Share this post


Link to post
Share on other sites
4 minutes ago, AutoBert said:

Just use GuiCtrlRead the get the value from the combo and GuiCtrlSetData to assing the value to the input.

Hi AutoBert

I added the following but Cargo Quantity input still won't show anything when $idButton2 is clicked.

Case $iMsg = $idButton2

GuiCtrlSetData($sCargoQuantityInput, GuiCtrlRead($idCombo_4))

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

2 hours ago, LT_STTS said:

I added the following but Cargo Quantity input still won't show anything when $idButton2 is clicked.

Case $iMsg = $idButton2

GuiCtrlSetData($sCargoQuantityInput, GuiCtrlRead($idCombo_4))

 

works without any problem:

; AutoIt Version 3.0.103
; Language:       English
; Author:         Larry Bailey
; Email:          psichosis@tvn.net
; Date: January 11, 2005
;
; Script Function
; Creates a simple GUI showing the use of
; a label, a combobox and a button
; Selecting an item from the combobox
; and clicking the button updates the label text
#Region includes ;<== usualy at begining
#include <GuiComboBox.au3>
#include <GuiConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <EditConstants.au3>
#include <GUIListBox.au3>
#include <FontConstants.au3>
#EndRegion includes ;<== usualy at begining

Global $sRepeatLoad, $sLastLoadQTY

_Main()

Func _Main()
    Local Const $sFont = "News Gothic MT"

    Local $idLabel_1, $idLabel_2, $idCombo_1, $idCombo_2, $idCombo_3, $idCombo_4, $idButton1, $iMsg, $sICAO, $sBaseCapacity, $BaseCapacity, $sProduct, $sAircraftType, $sPayload, $CargoQuantity, $sCargoQuantityInput, $sCargoQuantity, $DisplayRepeatLoad, $DisplayLastLoadQTY, $AircraftDefaultCapacity, $sLocalSupplyRate, $LocalSupplyRate

    ;$RepeatLoad = 0
    ;$sBaseCapacity = 0
    ;$sCargoQuantityInput = 6546
    ;$AircraftDefaultCapacity = 0

    ; Create the GUI window and controls
    GUICreate("MyGUI", 950, 240); (@DesktopWidth - 1920) / 2, (@DesktopHeight - 1200) / 2)



    ;Manual input Label
    GUICtrlCreatePic("Label_ManualInput.jpg", 30, 10, 131, 21)

    ;Select Airport
    GUICtrlCreatePic("Label_ICAO.jpg", 30, 40, 131, 21)
    $idCombo_1 = GUICtrlCreateCombo("", 30, 60, 130, 40)
    GUICtrlSetData($idCombo_1, "YMML|YMEN|YPPH|YBAS|NZAA")
    GUICtrlSetFont($idCombo_1, 22, 700, $sFont)

    ;Show default Base Carpacity
    GUICtrlCreatePic("Label_BaseCapacity.jpg", 161, 40, 131, 21)
    $idCombo_2 = GUICtrlCreateCombo("", 161, 60, 131, 40)
    GUICtrlSetData($idCombo_2, "30000|22500|32500|12500|30000")
    GUICtrlSetFont($idCombo_2, 22, 700, $sFont)

    ;Local Supply Rate
    GUICtrlCreatePic("Label_LocalSupplyRate.jpg", 161, 105, 130, 21)
    $sLocalSupplyRate = GUICtrlCreateInput("", 161, 125, 130, 40, $ES_NUMBER)
    GUICtrlSetFont($sLocalSupplyRate, 22, 700, $sFont)

    ;Select Aircraft Type
    GUICtrlCreatePic("Label_Aircraft_Type.jpg", 330, 40, 130, 21)
    $idCombo_3 = GUICtrlCreateCombo("", 330, 60, 130, 40)
    GUICtrlSetData($idCombo_3, "An225|B777|B737|A320|RJ70|C27J|")
    GUICtrlSetFont($idCombo_3, 22, 700, $sFont)

    ;Select Payload
    GUICtrlCreatePic("Label_Payload.jpg", 461, 40, 130, 21)
    $idCombo_4 = GUICtrlCreateCombo("", 461, 60, 130, 40)
    GUICtrlSetData($idCombo_4, "943000|430000|73000|72000|39000|42000|")
    GUICtrlSetFont($idCombo_4, 22, 700, $sFont)

    ;Set Aircraft default capacity button
    $idButton2 = GUICtrlCreateButton(">>", 591, 60, 38, 40)
    GUICtrlSetFont($idButton2, 15, 300, $sFont)

    ;Input Cargo Quantity
    GUICtrlCreatePic("Label_CargoQuantity.jpg", 630, 40, 130, 21)
    $sCargoQuantityInput = GUICtrlCreateInput("", 630, 60, 130, 40, $ES_NUMBER)
    GUICtrlSetFont($sCargoQuantityInput, 22, 700, $sFont)

    ;Input Repeat Load
    GUICtrlCreatePic("Label_RepeatLoad.jpg", 791, 40, 130, 21)
    $DisplayRepeatLoad = GUICtrlCreateInput("", 791, 60, 130, 40)
    GUICtrlSetFont($DisplayRepeatLoad, 22, 700, $sFont)

    ;Input Last Load Quantity
    GUICtrlCreatePic("Label_LastLoadQTY.jpg", 791, 105, 130, 21)
    $DisplayLastLoadQTY = GUICtrlCreateInput("", 791, 125, 130, 40)
    GUICtrlSetFont($DisplayLastLoadQTY, 22, 700, $sFont)

    $idButton1 = GUICtrlCreateButton("Load Supply to Aircraft", 591, 180, 330, 40)
    GUICtrlSetFont($idButton1, 20, 700, $sFont)

    ; Run the GUI until it is closed
    GUISetState()
    While 1
        $iMsg = GUIGetMsg()

        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                ExitLoop

            Case GUICtrlRead($idCombo_1)

                $sICAO = GUICtrlRead($idCombo_1)
                If $sICAO = "YMML" Then
                    _GUICtrlComboBox_SelectString($idCombo_2, "30000")
                EndIf
                If $sICAO = "YMEN" Then
                    _GUICtrlComboBox_SelectString($idCombo_2, "22500")
                EndIf
                If $sICAO = "YPPH" Then
                    _GUICtrlComboBox_SelectString($idCombo_2, "32500")
                EndIf
                If $sICAO = "YBAS" Then
                    _GUICtrlComboBox_SelectString($idCombo_2, "12500")
                EndIf
                If $sICAO = "NZAA" Then
                    _GUICtrlComboBox_SelectString($idCombo_2, "30000")
                EndIf


                GUICtrlRead($idCombo_3)

                $sAircraftType = GUICtrlRead($idCombo_3)
                If $sAircraftType = "An225" Then
                    _GUICtrlComboBox_SelectString($idCombo_4, "943000")
                EndIf
                If $sAircraftType = "B777" Then
                    _GUICtrlComboBox_SelectString($idCombo_4, "430000")
                EndIf
                If $sAircraftType = "B737" Then
                    _GUICtrlComboBox_SelectString($idCombo_4, "73000")
                EndIf
                If $sAircraftType = "A320" Then
                    _GUICtrlComboBox_SelectString($idCombo_4, "72000")
                EndIf
                If $sAircraftType = "RJ70" Then
                    _GUICtrlComboBox_SelectString($idCombo_4, "39000")
                EndIf
                If $sAircraftType = "C27J" Then
                    _GUICtrlComboBox_SelectString($idCombo_4, "42000")
                EndIf

                $AircraftDefaultCapacity = GUICtrlRead($idCombo_4)


                GUICtrlRead(Number($sRepeatLoad))
                If $sICAO = "YMML" Then
                    $BaseCapacity = 30000
                EndIf
                If $sICAO = "YMEN" Then
                    $BaseCapacity = 22500
                EndIf
                If $sICAO = "YPPH" Then
                    $BaseCapacity = 32500
                EndIf
                If $sICAO = "YBAS" Then
                    $BaseCapacity = 12500
                EndIf
                If $sICAO = "NZAA" Then
                    $BaseCapacity = 30000
                EndIf

                $LocalSupplyRate = (GUICtrlRead($sLocalSupplyRate)) ;<-----------Make the Input becomce number
                $CargoQuantity = (GUICtrlRead($sCargoQuantityInput)) ;<-----------Make the Input becomce number

                If $LocalSupplyRate >= $BaseCapacity Then
                    GUICtrlSetData($sLocalSupplyRate, 0)
                ElseIf $LocalSupplyRate = 0 Then
                    $sRepeatLoad = Floor($CargoQuantity / $BaseCapacity)
                    $sLastLoadQTY = $CargoQuantity - $sRepeatLoad * $BaseCapacity
                ElseIf $LocalSupplyRate <> 0 Then
                    If $LocalSupplyRate < $BaseCapacity Then
                        $sRepeatLoad = Floor($CargoQuantity / $LocalSupplyRate)
                        $sLastLoadQTY = $CargoQuantity - $sRepeatLoad * $LocalSupplyRate
                    EndIf

                EndIf


                GUICtrlSetData($DisplayRepeatLoad, $sRepeatLoad) ;<----------------********
                GUICtrlSetData($DisplayLastLoadQTY, $sLastLoadQTY) ;<----------------********

            Case $iMsg = $idButton2
                GUICtrlSetData($sCargoQuantityInput, GUICtrlRead($idCombo_4))

                ;$AircraftDefaultCapacity = Number(GUICtrlRead($idCombo_4, 1))
                ;GUICtrlSetData($sCargoQuantityInput, $AircraftDefaultCapacity, "1")

                ;Load material to plane
                ;Case $idButton1
                ;LoadPlane1()


        EndSelect

        ;;ConsoleWrite("ICAO          : " & $sICAO & @CRLF)
        ;;ConsoleWrite("BaseCapacity  : " & $BaseCapacity & @CRLF)
        ;;ConsoleWrite("CargoQuantity : " & $CargoQuantity & @CRLF)
        ;ConsoleWrite("Repeat Load s   : " & $sRepeatLoad & @CRLF)
        ;ConsoleWrite("Combo 4  : " & Number($idCombo_4, "1") & @CRLF)
        ;ConsoleWrite("Cargo Quantity Input   : " & $sCargoQuantityInput & @CRLF)
        ;ConsoleWrite("Aircraft Default Capacity   : " & $AircraftDefaultCapacity & @CRLF)
        ;ConsoleWrite("Aircraft Type   : " & $sAircraftType & @CRLF)
    WEnd

EndFunc   ;==>_Main

Func WinWaitActivate($title, $text, $timeout = 5)
    WinWait($title, $text, $timeout)
    If Not WinActive($title, $text) Then WinActivate($title, $text)
    If Not WinWaitActive($title, $text, 5) Then
        Return 0
    Else
        Return 1
    EndIf
EndFunc   ;==>WinWaitActivate

Func LoadPlane1()
    WinWaitActivate("Autodesk Maya 2008: .\untitled", "ELFdefaultFormLayout")
    MouseClick("left", 275, 129, 1)
    WinWaitActivate("STEEDM_UI", "ELFdefaultFormLayout")
    MouseClick("left", 241, 39, 1)
    MouseClick("left", 208, 180, 1)
    WinWaitActivate("smrt Assets Tools", "ELFdefaultColumnLayo")
    MouseClick("left", 180, 463, 2)
    Send($sLastLoadQTY)
    MouseClick("left", 200, 551, 1)
    MouseClick("left", 209, 626, 1)
EndFunc   ;==>LoadPlane1

I am using the latest stable 3.3.14.2

Edited by AutoBert

Share this post


Link to post
Share on other sites

Hi AutoBert

I updated to your version and run the script you posted. Attached image is  what I got . Clicking the $idButton2 does not grab the 943000 from Payload and paste into Cargo Quantity. Any thing to do the with the Included Au3?

Screenshot_571.png

Share this post


Link to post
Share on other sites

I only tested to select combo4 and then clicked button. After a complete test, i know it's your logic. I suggest use switch instead of select, it's easier to handle for this problem:

; AutoIt Version 3.0.103
; Language:       English
; Author:         Larry Bailey
; Email:          psichosis@tvn.net
; Date: January 11, 2005
;
; Script Function
; Creates a simple GUI showing the use of
; a label, a combobox and a button
; Selecting an item from the combobox
; and clicking the button updates the label text
#Region includes ;<== usualy at begining
#include <GuiComboBox.au3>
#include <GuiConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <EditConstants.au3>
#include <GUIListBox.au3>
#include <FontConstants.au3>
#EndRegion includes ;<== usualy at begining

Global $sRepeatLoad, $sLastLoadQTY

_Main()

Func _Main()
    Local Const $sFont = "News Gothic MT"

    Local $idLabel_1, $idLabel_2, $idCombo_1, $idCombo_2, $idCombo_3, $idCombo_4, $idButton1, $iMsg, $sICAO, $sBaseCapacity, $BaseCapacity, $sProduct, $sAircraftType, $sPayload, $CargoQuantity, $sCargoQuantityInput, $sCargoQuantity, $DisplayRepeatLoad, $DisplayLastLoadQTY, $AircraftDefaultCapacity, $sLocalSupplyRate, $LocalSupplyRate

    ;$RepeatLoad = 0
    ;$sBaseCapacity = 0
    ;$sCargoQuantityInput = 6546
    ;$AircraftDefaultCapacity = 0

    ; Create the GUI window and controls
    GUICreate("MyGUI", 950, 240); (@DesktopWidth - 1920) / 2, (@DesktopHeight - 1200) / 2)



    ;Manual input Label
    GUICtrlCreatePic("Label_ManualInput.jpg", 30, 10, 131, 21)

    ;Select Airport
    GUICtrlCreatePic("Label_ICAO.jpg", 30, 40, 131, 21)
    $idCombo_1 = GUICtrlCreateCombo("", 30, 60, 130, 40)
    GUICtrlSetData($idCombo_1, "YMML|YMEN|YPPH|YBAS|NZAA")
    GUICtrlSetFont($idCombo_1, 22, 700, $sFont)

    ;Show default Base Carpacity
    GUICtrlCreatePic("Label_BaseCapacity.jpg", 161, 40, 131, 21)
    $idCombo_2 = GUICtrlCreateCombo("", 161, 60, 131, 40)
    GUICtrlSetData($idCombo_2, "30000|22500|32500|12500|30000")
    GUICtrlSetFont($idCombo_2, 22, 700, $sFont)

    ;Local Supply Rate
    GUICtrlCreatePic("Label_LocalSupplyRate.jpg", 161, 105, 130, 21)
    $sLocalSupplyRate = GUICtrlCreateInput("", 161, 125, 130, 40, $ES_NUMBER)
    GUICtrlSetFont($sLocalSupplyRate, 22, 700, $sFont)

    ;Select Aircraft Type
    GUICtrlCreatePic("Label_Aircraft_Type.jpg", 330, 40, 130, 21)
    $idCombo_3 = GUICtrlCreateCombo("", 330, 60, 130, 40)
    GUICtrlSetData($idCombo_3, "An225|B777|B737|A320|RJ70|C27J|")
    GUICtrlSetFont($idCombo_3, 22, 700, $sFont)

    ;Select Payload
    GUICtrlCreatePic("Label_Payload.jpg", 461, 40, 130, 21)
    $idCombo_4 = GUICtrlCreateCombo("", 461, 60, 130, 40)
    GUICtrlSetData($idCombo_4, "943000|430000|73000|72000|39000|42000|")
    GUICtrlSetFont($idCombo_4, 22, 700, $sFont)

    ;Set Aircraft default capacity button
    $idButton2 = GUICtrlCreateButton(">>", 591, 60, 38, 40)
    GUICtrlSetFont($idButton2, 15, 300, $sFont)

    ;Input Cargo Quantity
    GUICtrlCreatePic("Label_CargoQuantity.jpg", 630, 40, 130, 21)
    $sCargoQuantityInput = GUICtrlCreateInput("", 630, 60, 130, 40, $ES_NUMBER)
    GUICtrlSetFont($sCargoQuantityInput, 22, 700, $sFont)

    ;Input Repeat Load
    GUICtrlCreatePic("Label_RepeatLoad.jpg", 791, 40, 130, 21)
    $DisplayRepeatLoad = GUICtrlCreateInput("", 791, 60, 130, 40)
    GUICtrlSetFont($DisplayRepeatLoad, 22, 700, $sFont)

    ;Input Last Load Quantity
    GUICtrlCreatePic("Label_LastLoadQTY.jpg", 791, 105, 130, 21)
    $DisplayLastLoadQTY = GUICtrlCreateInput("", 791, 125, 130, 40)
    GUICtrlSetFont($DisplayLastLoadQTY, 22, 700, $sFont)

    $idButton1 = GUICtrlCreateButton("Load Supply to Aircraft", 591, 180, 330, 40)
    GUICtrlSetFont($idButton1, 20, 700, $sFont)

    ; Run the GUI until it is closed
    GUISetState()
    While 1
        $iMsg = GUIGetMsg()

        Switch $iMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $idCombo_1
                $sICAO = GUICtrlRead($idCombo_1)
                Switch $sICAO
                    Case "YMML"
                        _GUICtrlComboBox_SelectString($idCombo_2, "30000")
                    Case "YMEN"
                        _GUICtrlComboBox_SelectString($idCombo_2, "22500")
                    Case "YPPH"
                        _GUICtrlComboBox_SelectString($idCombo_2, "32500")
                    Case "YBAS"
                        _GUICtrlComboBox_SelectString($idCombo_2, "12500")
                    Case "NZAA"
                        _GUICtrlComboBox_SelectString($idCombo_2, "30000")
                EndSwitch
            Case $idCombo_3

                $sAircraftType = GUICtrlRead($idCombo_3)
                Switch $sAircraftType
                    Case "An225"
                        _GUICtrlComboBox_SelectString($idCombo_4, "943000")
                    Case "B777"
                        _GUICtrlComboBox_SelectString($idCombo_4, "430000")
                    Case "B737"
                        _GUICtrlComboBox_SelectString($idCombo_4, "73000")
                    Case "A320"
                        _GUICtrlComboBox_SelectString($idCombo_4, "72000")
                    Case "RJ70"
                        _GUICtrlComboBox_SelectString($idCombo_4, "39000")
                    Case "C27J"
                        _GUICtrlComboBox_SelectString($idCombo_4, "42000")
                EndSwitch

                $AircraftDefaultCapacity = GUICtrlRead($idCombo_4)


                GUICtrlRead(Number($sRepeatLoad))
                Switch $sICAO
                    Case "YMML"
                        $BaseCapacity = 30000
                    Case "YMEN"
                        $BaseCapacity = 22500
                    Case "YPPH"
                        $BaseCapacity = 32500
                    Case "YBAS"
                        $BaseCapacity = 12500
                    Case "NZAA"
                        $BaseCapacity = 30000
                EndSwitch

                $LocalSupplyRate = (GUICtrlRead($sLocalSupplyRate)) ;<-----------Make the Input becomce number
                $CargoQuantity = (GUICtrlRead($sCargoQuantityInput)) ;<-----------Make the Input becomce number

                If $LocalSupplyRate >= $BaseCapacity Then
                    GUICtrlSetData($sLocalSupplyRate, 0)
                ElseIf $LocalSupplyRate = 0 Then
                    $sRepeatLoad = Floor($CargoQuantity / $BaseCapacity)
                    $sLastLoadQTY = $CargoQuantity - $sRepeatLoad * $BaseCapacity
                ElseIf $LocalSupplyRate <> 0 Then
                    If $LocalSupplyRate < $BaseCapacity Then
                        $sRepeatLoad = Floor($CargoQuantity / $LocalSupplyRate)
                        $sLastLoadQTY = $CargoQuantity - $sRepeatLoad * $LocalSupplyRate
                    EndIf

                EndIf


                GUICtrlSetData($DisplayRepeatLoad, $sRepeatLoad) ;<----------------********
                GUICtrlSetData($DisplayLastLoadQTY, $sLastLoadQTY) ;<----------------********

            Case $iMsg = $idButton2
                GUICtrlSetData($sCargoQuantityInput, GUICtrlRead($idCombo_4))

                ;$AircraftDefaultCapacity = Number(GUICtrlRead($idCombo_4, 1))
                ;GUICtrlSetData($sCargoQuantityInput, $AircraftDefaultCapacity, "1")

                ;Load material to plane
                ;Case $idButton1
                ;LoadPlane1()


        EndSwitch

        ;;ConsoleWrite("ICAO          : " & $sICAO & @CRLF)
        ;;ConsoleWrite("BaseCapacity  : " & $BaseCapacity & @CRLF)
        ;;ConsoleWrite("CargoQuantity : " & $CargoQuantity & @CRLF)
        ;ConsoleWrite("Repeat Load s   : " & $sRepeatLoad & @CRLF)
        ;ConsoleWrite("Combo 4  : " & Number($idCombo_4, "1") & @CRLF)
        ;ConsoleWrite("Cargo Quantity Input   : " & $sCargoQuantityInput & @CRLF)
        ;ConsoleWrite("Aircraft Default Capacity   : " & $AircraftDefaultCapacity & @CRLF)
        ;ConsoleWrite("Aircraft Type   : " & $sAircraftType & @CRLF)
    WEnd

EndFunc   ;==>_Main

Func WinWaitActivate($title, $text, $timeout = 5)
    WinWait($title, $text, $timeout)
    If Not WinActive($title, $text) Then WinActivate($title, $text)
    If Not WinWaitActive($title, $text, 5) Then
        Return 0
    Else
        Return 1
    EndIf
EndFunc   ;==>WinWaitActivate

Func LoadPlane1()
    WinWaitActivate("Autodesk Maya 2008: .\untitled", "ELFdefaultFormLayout")
    MouseClick("left", 275, 129, 1)
    WinWaitActivate("STEEDM_UI", "ELFdefaultFormLayout")
    MouseClick("left", 241, 39, 1)
    MouseClick("left", 208, 180, 1)
    WinWaitActivate("smrt Assets Tools", "ELFdefaultColumnLayo")
    MouseClick("left", 180, 463, 2)
    Send($sLastLoadQTY)
    MouseClick("left", 200, 551, 1)
    MouseClick("left", 209, 626, 1)
EndFunc   ;==>LoadPlane1

 

Share this post


Link to post
Share on other sites

I tested your latest script...

The switch method wont work as the Input Cargo Quantity  cannot be keyed in by the user anymore. And calculation for the last 2 variables is no longer available,

Share this post


Link to post
Share on other sites
49 minutes ago, LT_STTS said:

The switch method wont work as the Input Cargo Quantity  cannot be keyed in by the user anymore.

Then work on your logic with the select method. It's your airplane wich chrashes if overloaded.

Share this post


Link to post
Share on other sites
On 9/23/2016 at 10:46 PM, AutoBert said:

Then work on your logic with the select method. It's your airplane wich chrashes if overloaded.

Hi AutoBert

The logic is not for preventing overloading the plane.

It is for calculating number of times of repeating similar load size(Repeat Load) and calculating the last load size(Last Load QTY). And all this depend on the Airbase Transfer capacity and cargo quantity. So $idButton2 is needed when user need to get the max capacity of the plane to be loaded in the case when Cargo quantity exceed the Max capacity of the plane.

I m just puzzled that the GUICtrlSetData didn't work in my case.

Well, for now I just use the copy and paste manually instead of $idButton1.

Thanks for help, Cheers.

 

 

Share this post


Link to post
Share on other sites
4 hours ago, LT_STTS said:

I m just puzzled that the GUICtrlSetData didn't work in my case.

The problem is not the GuiCtrlSetData, the problem is the logic of interaction the controls does. Test this:

; AutoIt Version 3.0.103
; Language:       English
; Author:         Larry Bailey
; Email:          psichosis@tvn.net
; Date: January 11, 2005
;
; Script Function
; Creates a simple GUI showing the use of
; a label, a combobox and a button
; Selecting an item from the combobox
; and clicking the button updates the label text
#Region includes ;<== usualy at begining
#include <GuiComboBox.au3>
#include <GuiConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <EditConstants.au3>
#include <GUIListBox.au3>
#include <FontConstants.au3>
#EndRegion includes ;<== usualy at begining

Global $sRepeatLoad, $sLastLoadQTY

_Main()

Func _Main()
    Local Const $sFont = "News Gothic MT"

    Local $idLabel_1, $idLabel_2, $idCombo_1, $idCombo_2, $idCombo_3, $idCombo_4, $idButton1, $iMsg, $sICAO, $sBaseCapacity, $BaseCapacity, $sProduct, $sAircraftType, $sPayload, $CargoQuantity, $sCargoQuantityInput, $sCargoQuantity, $DisplayRepeatLoad, $DisplayLastLoadQTY, $AircraftDefaultCapacity, $sLocalSupplyRate, $LocalSupplyRate

    ;$RepeatLoad = 0
    ;$sBaseCapacity = 0
    ;$sCargoQuantityInput = 6546
    ;$AircraftDefaultCapacity = 0

    ; Create the GUI window and controls
    GUICreate("MyGUI", 950, 240); (@DesktopWidth - 1920) / 2, (@DesktopHeight - 1200) / 2)



    ;Manual input Label
    GUICtrlCreatePic("Label_ManualInput.jpg", 30, 10, 131, 21)

    ;Select Airport
    GUICtrlCreatePic("Label_ICAO.jpg", 30, 40, 131, 21)
    $idCombo_1 = GUICtrlCreateCombo("", 30, 60, 130, 40)
    GUICtrlSetData($idCombo_1, "YMML|YMEN|YPPH|YBAS|NZAA")
    GUICtrlSetFont($idCombo_1, 22, 700, $sFont)

    ;Show default Base Carpacity
    GUICtrlCreatePic("Label_BaseCapacity.jpg", 161, 40, 131, 21)
    $idCombo_2 = GUICtrlCreateCombo("", 161, 60, 131, 40)
    GUICtrlSetData($idCombo_2, "30000|22500|32500|12500|30000")
    GUICtrlSetFont($idCombo_2, 22, 700, $sFont)

    ;Local Supply Rate
    GUICtrlCreatePic("Label_LocalSupplyRate.jpg", 161, 105, 130, 21)
    $sLocalSupplyRate = GUICtrlCreateInput("", 161, 125, 130, 40, $ES_NUMBER)
    GUICtrlSetFont($sLocalSupplyRate, 22, 700, $sFont)

    ;Select Aircraft Type
    GUICtrlCreatePic("Label_Aircraft_Type.jpg", 330, 40, 130, 21)
    $idCombo_3 = GUICtrlCreateCombo("", 330, 60, 130, 40)
    GUICtrlSetData($idCombo_3, "An225|B777|B737|A320|RJ70|C27J|")
    GUICtrlSetFont($idCombo_3, 22, 700, $sFont)

    ;Select Payload
    GUICtrlCreatePic("Label_Payload.jpg", 461, 40, 130, 21)
    $idCombo_4 = GUICtrlCreateCombo("", 461, 60, 130, 40)
    GUICtrlSetData($idCombo_4, "943000|430000|73000|72000|39000|42000|")
    GUICtrlSetFont($idCombo_4, 22, 700, $sFont)

    ;Set Aircraft default capacity button
    $idButton2 = GUICtrlCreateButton(">>", 591, 60, 38, 40)
    GUICtrlSetFont($idButton2, 15, 300, $sFont)

    ;Input Cargo Quantity
    GUICtrlCreatePic("Label_CargoQuantity.jpg", 630, 40, 130, 21)
    $sCargoQuantityInput = GUICtrlCreateInput("", 630, 60, 130, 40, $ES_NUMBER)
    GUICtrlSetFont($sCargoQuantityInput, 22, 700, $sFont)

    ;Input Repeat Load
    GUICtrlCreatePic("Label_RepeatLoad.jpg", 791, 40, 130, 21)
    $DisplayRepeatLoad = GUICtrlCreateInput("", 791, 60, 130, 40)
    GUICtrlSetFont($DisplayRepeatLoad, 22, 700, $sFont)

    ;Input Last Load Quantity
    GUICtrlCreatePic("Label_LastLoadQTY.jpg", 791, 105, 130, 21)
    $DisplayLastLoadQTY = GUICtrlCreateInput("", 791, 125, 130, 40)
    GUICtrlSetFont($DisplayLastLoadQTY, 22, 700, $sFont)

    $idButton1 = GUICtrlCreateButton("Load Supply to Aircraft", 591, 180, 330, 40)
    GUICtrlSetFont($idButton1, 20, 700, $sFont)

    ; Run the GUI until it is closed
    GUISetState()
    While 1
        $iMsg = GUIGetMsg()

        Switch $iMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $idCombo_1
                $sICAO = GUICtrlRead($idCombo_1)
                Switch $sICAO
                    Case "YMML"
                        _GUICtrlComboBox_SelectString($idCombo_2, "30000")
                    Case "YMEN"
                        _GUICtrlComboBox_SelectString($idCombo_2, "22500")
                    Case "YPPH"
                        _GUICtrlComboBox_SelectString($idCombo_2, "32500")
                    Case "YBAS"
                        _GUICtrlComboBox_SelectString($idCombo_2, "12500")
                    Case "NZAA"
                        _GUICtrlComboBox_SelectString($idCombo_2, "30000")
                EndSwitch
            Case $idCombo_3

                $sAircraftType = GUICtrlRead($idCombo_3)
                Switch $sAircraftType
                    Case "An225"
                        _GUICtrlComboBox_SelectString($idCombo_4, "943000")
                    Case "B777"
                        _GUICtrlComboBox_SelectString($idCombo_4, "430000")
                    Case "B737"
                        _GUICtrlComboBox_SelectString($idCombo_4, "73000")
                    Case "A320"
                        _GUICtrlComboBox_SelectString($idCombo_4, "72000")
                    Case "RJ70"
                        _GUICtrlComboBox_SelectString($idCombo_4, "39000")
                    Case "C27J"
                        _GUICtrlComboBox_SelectString($idCombo_4, "42000")
                EndSwitch

                $AircraftDefaultCapacity = GUICtrlRead($idCombo_4)


                GUICtrlRead(Number($sRepeatLoad))
                Switch $sICAO
                    Case "YMML"
                        $BaseCapacity = 30000
                    Case "YMEN"
                        $BaseCapacity = 22500
                    Case "YPPH"
                        $BaseCapacity = 32500
                    Case "YBAS"
                        $BaseCapacity = 12500
                    Case "NZAA"
                        $BaseCapacity = 30000
                EndSwitch


            Case $iMsg = $idButton2
                GUICtrlSetData($sCargoQuantityInput, GUICtrlRead($idCombo_4))

                ;$AircraftDefaultCapacity = Number(GUICtrlRead($idCombo_4, 1))
                ;GUICtrlSetData($sCargoQuantityInput, $AircraftDefaultCapacity, "1")

                ;Load material to plane
                ;Case $idButton1
                ;LoadPlane1()


        EndSwitch

        ;;ConsoleWrite("ICAO          : " & $sICAO & @CRLF)
        ;;ConsoleWrite("BaseCapacity  : " & $BaseCapacity & @CRLF)
        ;;ConsoleWrite("CargoQuantity : " & $CargoQuantity & @CRLF)
        ;ConsoleWrite("Repeat Load s   : " & $sRepeatLoad & @CRLF)
        ;ConsoleWrite("Combo 4  : " & Number($idCombo_4, "1") & @CRLF)
        ;ConsoleWrite("Cargo Quantity Input   : " & $sCargoQuantityInput & @CRLF)
        ;ConsoleWrite("Aircraft Default Capacity   : " & $AircraftDefaultCapacity & @CRLF)
        ;ConsoleWrite("Aircraft Type   : " & $sAircraftType & @CRLF)
                $LocalSupplyRate = (GUICtrlRead($sLocalSupplyRate)) ;<-----------Make the Input becomce number
                $CargoQuantity = (GUICtrlRead($sCargoQuantityInput)) ;<-----------Make the Input becomce number

                If $LocalSupplyRate >= $BaseCapacity Then
                    GUICtrlSetData($sLocalSupplyRate, 0)
                ElseIf $LocalSupplyRate = 0 Then
                    $sRepeatLoad = Floor($CargoQuantity / $BaseCapacity)
                    $sLastLoadQTY = $CargoQuantity - $sRepeatLoad * $BaseCapacity
                ElseIf $LocalSupplyRate <> 0 Then
                    If $LocalSupplyRate < $BaseCapacity Then
                        $sRepeatLoad = Floor($CargoQuantity / $LocalSupplyRate)
                        $sLastLoadQTY = $CargoQuantity - $sRepeatLoad * $LocalSupplyRate
                    EndIf

                EndIf


                if GUICtrlRead($DisplayRepeatLoad)<> $sRepeatLoad Then GUICtrlSetData($DisplayRepeatLoad, $sRepeatLoad) ;<== to avoid flicker
                if GUICtrlRead( $DisplayLastLoadQTY)<> $sLastLoadQTY Then GUICtrlSetData($DisplayLastLoadQTY, $sLastLoadQTY) ;<== to avoid flicker
    WEnd

EndFunc   ;==>_Main

Func WinWaitActivate($title, $text, $timeout = 5)
    WinWait($title, $text, $timeout)
    If Not WinActive($title, $text) Then WinActivate($title, $text)
    If Not WinWaitActive($title, $text, 5) Then
        Return 0
    Else
        Return 1
    EndIf
EndFunc   ;==>WinWaitActivate-

Func LoadPlane1()
    WinWaitActivate("Autodesk Maya 2008: .\untitled", "ELFdefaultFormLayout")
    MouseClick("left", 275, 129, 1)
    WinWaitActivate("STEEDM_UI", "ELFdefaultFormLayout")
    MouseClick("left", 241, 39, 1)
    MouseClick("left", 208, 180, 1)
    WinWaitActivate("smrt Assets Tools", "ELFdefaultColumnLayo")
    MouseClick("left", 180, 463, 2)
    Send($sLastLoadQTY)
    MouseClick("left", 200, 551, 1)
    MouseClick("left", 209, 626, 1)
EndFunc   ;==>LoadPlane1

 

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

18 hours ago, AutoBert said:

The problem is not the GuiCtrlSetData, the problem is the logic of interaction the controls does. Test this:

; AutoIt Version 3.0.103
; Language:       English
; Author:         Larry Bailey
; Email:          psichosis@tvn.net
; Date: January 11, 2005
;
; Script Function
; Creates a simple GUI showing the use of
; a label, a combobox and a button
; Selecting an item from the combobox
; and clicking the button updates the label text
#Region includes ;<== usualy at begining
#include <GuiComboBox.au3>
#include <GuiConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <EditConstants.au3>
#include <GUIListBox.au3>
#include <FontConstants.au3>
#EndRegion includes ;<== usualy at begining

Global $sRepeatLoad, $sLastLoadQTY

_Main()

Func _Main()
    Local Const $sFont = "News Gothic MT"

    Local $idLabel_1, $idLabel_2, $idCombo_1, $idCombo_2, $idCombo_3, $idCombo_4, $idButton1, $iMsg, $sICAO, $sBaseCapacity, $BaseCapacity, $sProduct, $sAircraftType, $sPayload, $CargoQuantity, $sCargoQuantityInput, $sCargoQuantity, $DisplayRepeatLoad, $DisplayLastLoadQTY, $AircraftDefaultCapacity, $sLocalSupplyRate, $LocalSupplyRate

    ;$RepeatLoad = 0
    ;$sBaseCapacity = 0
    ;$sCargoQuantityInput = 6546
    ;$AircraftDefaultCapacity = 0

    ; Create the GUI window and controls
    GUICreate("MyGUI", 950, 240); (@DesktopWidth - 1920) / 2, (@DesktopHeight - 1200) / 2)



    ;Manual input Label
    GUICtrlCreatePic("Label_ManualInput.jpg", 30, 10, 131, 21)

    ;Select Airport
    GUICtrlCreatePic("Label_ICAO.jpg", 30, 40, 131, 21)
    $idCombo_1 = GUICtrlCreateCombo("", 30, 60, 130, 40)
    GUICtrlSetData($idCombo_1, "YMML|YMEN|YPPH|YBAS|NZAA")
    GUICtrlSetFont($idCombo_1, 22, 700, $sFont)

    ;Show default Base Carpacity
    GUICtrlCreatePic("Label_BaseCapacity.jpg", 161, 40, 131, 21)
    $idCombo_2 = GUICtrlCreateCombo("", 161, 60, 131, 40)
    GUICtrlSetData($idCombo_2, "30000|22500|32500|12500|30000")
    GUICtrlSetFont($idCombo_2, 22, 700, $sFont)

    ;Local Supply Rate
    GUICtrlCreatePic("Label_LocalSupplyRate.jpg", 161, 105, 130, 21)
    $sLocalSupplyRate = GUICtrlCreateInput("", 161, 125, 130, 40, $ES_NUMBER)
    GUICtrlSetFont($sLocalSupplyRate, 22, 700, $sFont)

    ;Select Aircraft Type
    GUICtrlCreatePic("Label_Aircraft_Type.jpg", 330, 40, 130, 21)
    $idCombo_3 = GUICtrlCreateCombo("", 330, 60, 130, 40)
    GUICtrlSetData($idCombo_3, "An225|B777|B737|A320|RJ70|C27J|")
    GUICtrlSetFont($idCombo_3, 22, 700, $sFont)

    ;Select Payload
    GUICtrlCreatePic("Label_Payload.jpg", 461, 40, 130, 21)
    $idCombo_4 = GUICtrlCreateCombo("", 461, 60, 130, 40)
    GUICtrlSetData($idCombo_4, "943000|430000|73000|72000|39000|42000|")
    GUICtrlSetFont($idCombo_4, 22, 700, $sFont)

    ;Set Aircraft default capacity button
    $idButton2 = GUICtrlCreateButton(">>", 591, 60, 38, 40)
    GUICtrlSetFont($idButton2, 15, 300, $sFont)

    ;Input Cargo Quantity
    GUICtrlCreatePic("Label_CargoQuantity.jpg", 630, 40, 130, 21)
    $sCargoQuantityInput = GUICtrlCreateInput("", 630, 60, 130, 40, $ES_NUMBER)
    GUICtrlSetFont($sCargoQuantityInput, 22, 700, $sFont)

    ;Input Repeat Load
    GUICtrlCreatePic("Label_RepeatLoad.jpg", 791, 40, 130, 21)
    $DisplayRepeatLoad = GUICtrlCreateInput("", 791, 60, 130, 40)
    GUICtrlSetFont($DisplayRepeatLoad, 22, 700, $sFont)

    ;Input Last Load Quantity
    GUICtrlCreatePic("Label_LastLoadQTY.jpg", 791, 105, 130, 21)
    $DisplayLastLoadQTY = GUICtrlCreateInput("", 791, 125, 130, 40)
    GUICtrlSetFont($DisplayLastLoadQTY, 22, 700, $sFont)

    $idButton1 = GUICtrlCreateButton("Load Supply to Aircraft", 591, 180, 330, 40)
    GUICtrlSetFont($idButton1, 20, 700, $sFont)

    ; Run the GUI until it is closed
    GUISetState()
    While 1
        $iMsg = GUIGetMsg()

        Switch $iMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $idCombo_1
                $sICAO = GUICtrlRead($idCombo_1)
                Switch $sICAO
                    Case "YMML"
                        _GUICtrlComboBox_SelectString($idCombo_2, "30000")
                    Case "YMEN"
                        _GUICtrlComboBox_SelectString($idCombo_2, "22500")
                    Case "YPPH"
                        _GUICtrlComboBox_SelectString($idCombo_2, "32500")
                    Case "YBAS"
                        _GUICtrlComboBox_SelectString($idCombo_2, "12500")
                    Case "NZAA"
                        _GUICtrlComboBox_SelectString($idCombo_2, "30000")
                EndSwitch
            Case $idCombo_3

                $sAircraftType = GUICtrlRead($idCombo_3)
                Switch $sAircraftType
                    Case "An225"
                        _GUICtrlComboBox_SelectString($idCombo_4, "943000")
                    Case "B777"
                        _GUICtrlComboBox_SelectString($idCombo_4, "430000")
                    Case "B737"
                        _GUICtrlComboBox_SelectString($idCombo_4, "73000")
                    Case "A320"
                        _GUICtrlComboBox_SelectString($idCombo_4, "72000")
                    Case "RJ70"
                        _GUICtrlComboBox_SelectString($idCombo_4, "39000")
                    Case "C27J"
                        _GUICtrlComboBox_SelectString($idCombo_4, "42000")
                EndSwitch

                $AircraftDefaultCapacity = GUICtrlRead($idCombo_4)


                GUICtrlRead(Number($sRepeatLoad))
                Switch $sICAO
                    Case "YMML"
                        $BaseCapacity = 30000
                    Case "YMEN"
                        $BaseCapacity = 22500
                    Case "YPPH"
                        $BaseCapacity = 32500
                    Case "YBAS"
                        $BaseCapacity = 12500
                    Case "NZAA"
                        $BaseCapacity = 30000
                EndSwitch


            Case $iMsg = $idButton2
                GUICtrlSetData($sCargoQuantityInput, GUICtrlRead($idCombo_4))

                ;$AircraftDefaultCapacity = Number(GUICtrlRead($idCombo_4, 1))
                ;GUICtrlSetData($sCargoQuantityInput, $AircraftDefaultCapacity, "1")

                ;Load material to plane
                ;Case $idButton1
                ;LoadPlane1()


        EndSwitch

        ;;ConsoleWrite("ICAO          : " & $sICAO & @CRLF)
        ;;ConsoleWrite("BaseCapacity  : " & $BaseCapacity & @CRLF)
        ;;ConsoleWrite("CargoQuantity : " & $CargoQuantity & @CRLF)
        ;ConsoleWrite("Repeat Load s   : " & $sRepeatLoad & @CRLF)
        ;ConsoleWrite("Combo 4  : " & Number($idCombo_4, "1") & @CRLF)
        ;ConsoleWrite("Cargo Quantity Input   : " & $sCargoQuantityInput & @CRLF)
        ;ConsoleWrite("Aircraft Default Capacity   : " & $AircraftDefaultCapacity & @CRLF)
        ;ConsoleWrite("Aircraft Type   : " & $sAircraftType & @CRLF)
                $LocalSupplyRate = (GUICtrlRead($sLocalSupplyRate)) ;<-----------Make the Input becomce number
                $CargoQuantity = (GUICtrlRead($sCargoQuantityInput)) ;<-----------Make the Input becomce number

                If $LocalSupplyRate >= $BaseCapacity Then
                    GUICtrlSetData($sLocalSupplyRate, 0)
                ElseIf $LocalSupplyRate = 0 Then
                    $sRepeatLoad = Floor($CargoQuantity / $BaseCapacity)
                    $sLastLoadQTY = $CargoQuantity - $sRepeatLoad * $BaseCapacity
                ElseIf $LocalSupplyRate <> 0 Then
                    If $LocalSupplyRate < $BaseCapacity Then
                        $sRepeatLoad = Floor($CargoQuantity / $LocalSupplyRate)
                        $sLastLoadQTY = $CargoQuantity - $sRepeatLoad * $LocalSupplyRate
                    EndIf

                EndIf


                if GUICtrlRead($DisplayRepeatLoad)<> $sRepeatLoad Then GUICtrlSetData($DisplayRepeatLoad, $sRepeatLoad) ;<== to avoid flicker
                if GUICtrlRead( $DisplayLastLoadQTY)<> $sLastLoadQTY Then GUICtrlSetData($DisplayLastLoadQTY, $sLastLoadQTY) ;<== to avoid flicker
    WEnd

EndFunc   ;==>_Main

Func WinWaitActivate($title, $text, $timeout = 5)
    WinWait($title, $text, $timeout)
    If Not WinActive($title, $text) Then WinActivate($title, $text)
    If Not WinWaitActive($title, $text, 5) Then
        Return 0
    Else
        Return 1
    EndIf
EndFunc   ;==>WinWaitActivate-

Func LoadPlane1()
    WinWaitActivate("Autodesk Maya 2008: .\untitled", "ELFdefaultFormLayout")
    MouseClick("left", 275, 129, 1)
    WinWaitActivate("STEEDM_UI", "ELFdefaultFormLayout")
    MouseClick("left", 241, 39, 1)
    MouseClick("left", 208, 180, 1)
    WinWaitActivate("smrt Assets Tools", "ELFdefaultColumnLayo")
    MouseClick("left", 180, 463, 2)
    Send($sLastLoadQTY)
    MouseClick("left", 200, 551, 1)
    MouseClick("left", 209, 626, 1)
EndFunc   ;==>LoadPlane1

 

Tested this version :

The flicker avoid is great!

But..the 2 functions below need to be rectified If possible:

1. Cargo Quantity input not available. This is the primary objective because the $idButton2 is for additional convenience only. 90% of the time user input into Cargo Quantity is required.

2. Repeat Load and Last Load Qty do not refresh results when user change ICAO. This open for computation error.

Thanks

 

Edited by LT_STTS
typo

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