Jump to content

Problem W/ Script


strate
 Share

Recommended Posts

In the following script when next is clicked it will not run the intended function.

#NoTrayIcon 
#include <H:\AutoIt3\Beta\include\GUIConstants.au3>
$Bulk_INI_File = "F:\LabelApp\Bulk Label Production.INI"

Declare()

HotKeySet("{ESC}","Terminate")

Run("C:\LVWIN70\lv.exe /usr garrett1 /pwd garrett1 /cmdm c:\lvwin70\labelapp\commands")
WinWaitActive("Command File Monitor", "Current Printer:")
WinSetState("Command File Monitor", "Current Printer:", @SW_HIDE)

IniWrite($Bulk_INI_File,"Step","Current","1")

$Main_Bulk_GUI = GUICreate("Label Production",@desktopwidth,@desktopheight)
$Back_Button = GUICtrlCreateButton("Back",10,10,40,20)
$Next_Button = GUICtrlCreateButton("Next",52,10,40,20)
$Process_Completion_Progress_Bar = GUICtrlCreateProgress (10,@DesktopHeight - 55,@DesktopWidth - 20,20)
WinSetState("Label Production","",@sw_maximize)
Sleep(100)
$Initial_Main_Bulk_GUI_size = WinGetPos("")

OnEvent()
Opt("GUIOnEventMode", 1)

$Refresh_Number = "1"
Refresh()

While 1
    Sleep(25)
    Monitor()
WEnd
Exit

Func Terminate()
    ProcessClose("LV.EXE")
    Exit
EndFunc

Func Monitor()
    $size = WinGetPos("")
    If $size[0] <> $Initial_Main_Bulk_GUI_size[0] Or $size[1] <> $Initial_Main_Bulk_GUI_size[1] Then
        WinMove("Label Production", "", -3, -3)
    EndIf
EndFunc  ;==>Monitor

Func Back_Refresh()
    $INI_Step = IniRead($Bulk_INI_File,"Step","Current","ERROR") 
    If $INI_Step = "1" Then
        Return
    EndIf
    $Refresh_Number = $INI_Step - 1
    Refresh()
EndFunc
Func Next_Refresh()
    $INI_Step = IniRead($Bulk_INI_File,"Step","Current","ERROR") 
    $Refresh_Number = $INI_Step + 1
    MsgBox(262144,'Debug line ~60','Selection:' & @lf & '$Refresh_Number' & @lf & @lf & 'Return:' & @lf & $Refresh_Number & @lf & @lf & '@Error:' & @lf & @Error);### Debug MSGBOX
    Refresh()
EndFunc

Func Refresh()
    Delete_All_Controls()
;~  $Function_to_Run = IniRead($Bulk_INI_File,"Step","Current","ERROR")
    Select 
        Case $Refresh_Number = 1
            Step1()
            IniWrite($Bulk_INI_File,"Step","Current","1")
        Case $Refresh_Number = 2
            Step2()
            IniWrite($Bulk_INI_File,"Step","Current","2")
    EndSelect
EndFunc

Func Step1()
    $Group_Frame = GuiCtrlCreateGraphic(5,35, 205,90,0)
    GUICtrlSetColor (-1, 0x666666)
    $Control_Width = 190
    $AIAG_Bulk_ESD_Selection_Button = GUICtrlCreateRadio("AIAG Bulk/ESD",10,40,$Control_Width,20)
    $AIAG_BPKG_BREC_Selection_Button = GUICtrlCreateRadio("AIAG Bulk Packaging/Bulk Record",10,60,$Control_Width,20)
    $GM_Bulk_ESD_Selection_Button = GUICtrlCreateRadio("GM Bulk/ESD",10,80,$Control_Width,20)
    $GM_BPKG_BREC_Selection_Button = GUICtrlCreateRadio("GM Bulk Packaging/Bulk Record",10,100,$Control_Width,20)
EndFunc

Func Step2()
    $Group_Frame = GuiCtrlCreateGraphic(245,5, 150,260,0)
    GUICtrlSetColor (-1, 0x666666)
    $Sales_Order_Number_Label = GUICtrlCreateLabel("Sales Order Number:",250,10,100,20)
    $Sales_Order_Number_Input = GUICtrlCreateInput("",250,25,100,20)
    $Customer_Part_Number_Label = GUICtrlCreateLabel("Customer Part Number:",250,55,200,20)
    $Customer_Part_Number_Input = GUICtrlCreateInput("",250,70,100,20)
    $TRW_Part_Number_Label = GUICtrlCreateLabel("TRW Kit Number:",250,100,200,20)
    $TRW_Part_Number_Input = GUICtrlCreateInput("",250,115,100,20)
    $Description_Label = GUICtrlCreateLabel("Description:", 250, 145, 100, 15)
    $Description_Button = GUICtrlCreateButton("Click to Choose Description", 250, 160, 140, 20)
    $Due_Date_Label = GUICtrlCreateLabel("Due Date:",250,190, 50, 15)
    $Due_Date_Input = GUICtrlCreateInput("",250, 205, 50, 20)
    GUICtrlSetLimit(-1, 6)
EndFunc

Func Delete_All_Controls()
    GUICtrlDelete($Group_Frame)
    GUICtrlDelete($AIAG_Bulk_ESD_Selection_Button)
    GUICtrlDelete($AIAG_BPKG_BREC_Selection_Button)
    GUICtrlDelete($GM_Bulk_ESD_Selection_Button)
    GUICtrlDelete($GM_BPKG_BREC_Selection_Button)
    GUICtrlDelete($Sales_Order_Number_Label)
    GUICtrlDelete($Sales_Order_Number_Input)
    GUICtrlDelete($Customer_Part_Number_Label)
    GUICtrlDelete($Customer_Part_Number_Input)
    GUICtrlDelete($TRW_Part_Number_Label)
    GUICtrlDelete($TRW_Part_Number_Input)
    GUICtrlDelete($Description_Label)
    GUICtrlDelete($Description_Button)
    GUICtrlDelete($Due_Date_Label)
    GUICtrlDelete($Due_Date_Input)
EndFunc
Func Declare()
    Global $Group_Frame = ""
    Global $AIAG_Bulk_ESD_Selection_Button = ""
    Global $AIAG_BPKG_BREC_Selection_Button = ""
    Global $GM_Bulk_ESD_Selection_Button = ""
    Global $GM_BPKG_BREC_Selection_Button = ""
    Global $Sales_Order_Number_Label = ""
    Global $Sales_Order_Number_Input = ""
    Global $Customer_Part_Number_Label = ""
    Global $Customer_Part_Number_Input = ""
    Global $TRW_Part_Number_Label = ""
    Global $TRW_Part_Number_Input = ""
    Global $Description_Label = ""
    Global $Description_Button = ""
    Global $Due_Date_Label = ""
    Global $Due_Date_Input = ""
    Global $Refresh_Number = ""
    Global $Back_Button = ""
    Global $Next_Button = ""
EndFunc

Func OnEvent()
    GuiCtrlSetOnEvent($Back_Button,"Back_Refresh")
    GuiCtrlSetOnEvent($Next_Button,"Next_Refresh")
EndFunc

Any ideas as to why this is? I placed the MsgBox inside Next_Refresh() so that I knew it was activated while troubleshooting it. No luck though the MsgBox will not open. Ideas?

INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...
Link to comment
Share on other sites

  • Moderators

Wow, never thought of making a GUI like that...lol

2 things I can see anyway...

Probably need to Dim this: $Refresh_Number = "1"

And I don't see GUISetState() anywhere.

Hope that helps!

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Wow, never thought of making a GUI like that...lol

2 things I can see anyway...

Probably need to Dim this: $Refresh_Number = "1"

And I don't see GUISetState() anywhere.

Hope that helps!

I'm not sure what fixed it but it works now. Thanks alot I thought it would be something simple.

By the way, what did you mean by "Wow, never thought of making a GUI like that"? Was it 'cause of the Declare() Func?

INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...
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...