Sign in to follow this  
Followers 0
dufran3

Ugly GUI, how do I make better?

11 posts in this topic

I have a script that currently reads from file, and get the text, then runs it through a script. I am trying to make a GUI for it, because the names don't change. I was thinking of having checkboxes, check the ones I need to be run through the script, and shazaam! however, that means I would need 113 checkboxes on 1 GUI!!! OMG!!! I started doing it....and i'm not even half-way and it is an ugly mess....suggestions?

;PPM Printer GUI

#include <GUIConstantsEx.au3>
Opt("GUIOnEventMode", 1)

_MainGUI()

Func _MainGUI()
    
    GUICreate("Portal PPM Printer", 400, 400)
    
    ;First Column
    GUICtrlCreateCheckbox('1.3.09', 10, 10)
    GUICtrlCreateCheckbox('1.3.10A', 10, 30)
    GUICtrlCreateCheckbox('1.3.10B', 10, 50)
    GUICtrlCreateCheckbox('1.3.10C', 10, 70)
    GUICtrlCreateCheckbox('1.3.27', 10, 90)
    GUICtrlCreateCheckbox('1.3.30', 10, 110)
    GUICtrlCreateCheckbox('1.3.51', 10, 130)
    GUICtrlCreateCheckbox('1.3.56', 10, 150)
    GUICtrlCreateCheckbox('1.3.57', 10, 170)
    GUICtrlCreateCheckbox('1.3.62', 10, 190)
    GUICtrlCreateCheckbox('1.3.64', 10, 210)
    GUICtrlCreateCheckbox('1.3.68', 10, 230)
    GUICtrlCreateCheckbox('1.3.69', 10, 250)
    GUICtrlCreateCheckbox('1.3.76', 10, 270)
    GUICtrlCreateCheckbox('1.4.07', 10, 290)
    GUICtrlCreateCheckbox('1.20.1', 10, 310)
    GUICtrlCreateCheckbox('10.1.13', 10, 330)
    GUICtrlCreateCheckbox('10.1.21', 10, 350)
    GUICtrlCreateCheckbox('10.1.22', 10, 370)
    
    ;Second Column
    GUICtrlCreateCheckbox('10.2.07', 110, 10)
    GUICtrlCreateCheckbox('10.2.10', 110, 30)
    GUICtrlCreateCheckbox('10.2.13', 110, 50)
    GUICtrlCreateCheckbox('10.2.14', 110, 70)
    GUICtrlCreateCheckbox('10.2.17', 110, 90)
    GUICtrlCreateCheckbox('10.2.18', 110, 110)
    GUICtrlCreateCheckbox('10.2.23', 110, 130)
    GUICtrlCreateCheckbox('10.2.27', 110, 150)
    GUICtrlCreateCheckbox('10.2.28', 110, 170)
    GUICtrlCreateCheckbox('10.2.29', 110, 190)
    GUICtrlCreateCheckbox('10.2.31', 110, 210)
    GUICtrlCreateCheckbox('10.2.33', 110, 230)
    GUICtrlCreateCheckbox('10.2.34', 110, 250)
    GUICtrlCreateCheckbox('10.2.37', 110, 270)
    GUICtrlCreateCheckbox('10.2.41', 110, 290)
    GUICtrlCreateCheckbox('10.2.47', 110, 310)
    GUICtrlCreateCheckbox('10.2.51', 110, 330)
    GUICtrlCreateCheckbox('10.2.53', 110, 350)
    GUICtrlCreateCheckbox('10.2.79', 110, 370)
    
    ;Third Column
    GUICtrlCreateCheckbox('10.2.101', 210, 10)
    GUICtrlCreateCheckbox('10.4.01', 210, 30)
    GUICtrlCreateCheckbox('10.4.02', 210, 50)
    GUICtrlCreateCheckbox('10.4.03', 210, 70)
    GUICtrlCreateCheckbox('10.4.04', 210, 90)
    GUICtrlCreateCheckbox('10.4.10', 210, 110)
    GUICtrlCreateCheckbox('10.4.11', 210, 130)
    GUICtrlCreateCheckbox('10.4.12', 210, 150)
    GUICtrlCreateCheckbox('10.4.14', 210, 170)
    GUICtrlCreateCheckbox('10.23.1', 210, 190)
    GUICtrlCreateCheckbox('10.23.2', 210, 210)
    GUICtrlCreateCheckbox('10.23.4', 210, 230)
    GUICtrlCreateCheckbox('10.24.12', 210, 250)
    GUICtrlCreateCheckbox('10.24.235', 210, 270)
    GUICtrlCreateCheckbox('10.25.19', 210, 290)
    GUICtrlCreateCheckbox('10.25.46', 210, 310)
    GUICtrlCreateCheckbox('10.25.55', 210, 330)
    GUICtrlCreateCheckbox('10.25.57', 210, 350)
    GUICtrlCreateCheckbox('10.25.61', 210, 370)

    
    
    GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit")
    GUISetState()  ; display the GUI
    
    While 1
        Sleep(1000)
    WEnd
EndFunc

Func OnExit()
    Exit
EndFunc

Share this post


Link to post
Share on other sites



Perhaps use a loop instead of "hardcoding" the checkboxes. Have a look here >>


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Perhaps use a loop instead of "hardcoding" the checkboxes. Have a look here >>

Yeh, I have done that in the past, I wasn't even that far into the script yet, I just wanted to see what it would look like. I'm less worried about what the code looks like, more about the actual GUI. Did you run it? A GUI with 113 checkboxes would be madness!!!! madness I tell yoU!

Share this post


Link to post
Share on other sites

will this help?

_GUICtrlListView_SetItemChecked example

GUICtrlCreateListView

connection with it is $LVS_EX_CHECKBOXES


TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

will this help?

_GUICtrlListView_SetItemChecked example

GUICtrlCreateListView

connection with it is $LVS_EX_CHECKBOXES

hmmm...i'm thinking this might work, gonna work on building up the GUI using this, then see if I can read the controls and pass them to a function properly...

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

This is where I have gotten thus far. The Listview is working nicely, however I am having trouble reading whether or not the control is checked...anyone spot my problem?

#include <GuiListView.au3>
#include <GUIConstantsEx.au3>
#include <File.au3>

Opt("GUIOnEventMode", 1)

$file = FileOpen(@ScriptDir & '\' & 'PPM.txt',0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file: " & @ScriptDir & 'PPM.txt')
    Exit
EndIf

While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
    If $line == '' Then ExitLoop

Wend

;Create Array
Dim $aProcedure [112][3] = [ _
        ['1.3.9', 'PPM', 'PPI'], _
        ['1.3.10A', 'PPM', 'PPI'], _
        ['1.3.10B', 'PPM', 'PPI'], _
        ['1.3.10C', 'PPM', 'PPI'], _
        ['1.3.27', 'PPM', 'PPI'], _
        ['1.3.30', 'PPM', 'PPI'], _
        ['1.3.51', 'PPM', 'PPI'], _
        ['1.3.56', 'PPM', 'PPI'], _
        ['1.3.57', 'PPM', 'PPI'], _
        ['1.3.62', 'PPM', 'PPI'], _
        ['1.3.64', 'PPM', 'PPI'], _
        ['1.3.68', 'PPM', 'PPI'], _
        ['1.3.69', 'PPM', 'PPI'], _
        ['1.3.76', 'PPM', 'PPI'], _
        ['1.4.7', 'PPM', 'PPI'], _
        ['1.20.1', 'PPM', 'PPI'], _
        ['10.1.13', 'PPM', 'PPI'], _
        ['10.1.21', 'PPM', 'PPI'], _
        ['10.1.22', 'PPM', 'PPI'], _
        ['10.2.7', 'PPM', 'PPI'], _
        ['10.2.10', 'PPM', 'PPI'], _
        ['10.2.13', 'PPM', 'PPI'], _
        ['10.2.14', 'PPM', 'PPI'], _
        ['10.2.17', 'PPM', 'PPI'], _
        ['10.2.18', 'PPM', 'PPI'], _
        ['10.2.23', 'PPM', 'PPI'], _
        ['10.2.27', 'PPM', 'PPI'], _
        ['10.2.28', 'PPM', 'PPI'], _
        ['10.2.29', 'PPM', 'PPI'], _
        ['10.2.31', 'PPM', 'PPI'], _
        ['10.2.33', 'PPM', 'PPI'], _
        ['10.2.34', 'PPM', 'PPI'], _
        ['10.2.37', 'PPM', 'PPI'], _
        ['10.2.41', 'PPM', 'PPI'], _
        ['10.2.47', 'PPM', 'PPI'], _
        ['10.2.51', 'PPM', 'PPI'], _
        ['10.2.53', 'PPM', 'PPI'], _
        ['10.2.79', 'PPM', 'PPI'], _
        ['10.2.101', 'PPM', 'PPI'], _
        ['10.4.1', 'PPM', 'PPI'], _
        ['10.4.2', 'PPM', 'PPI'], _
        ['10.4.3', 'PPM', 'PPI'], _
        ['10.4.4', 'PPM', 'PPI'], _
        ['10.4.10', 'PPM', 'PPI'], _
        ['10.4.11', 'PPM', 'PPI'], _
        ['10.4.12', 'PPM', 'PPI'], _
        ['10.4.14', 'PPM', 'PPI'], _
        ['10.23.1', 'PPM', 'PPI'], _
        ['10.23.2', 'PPM', 'PPI'], _
        ['10.23.4', 'PPM', 'PPI'], _
        ['10.24.12', 'PPM', 'PPI'], _
        ['10.24.135', 'PPM', 'PPI'], _
        ['10.25.19', 'PPM', 'PPI'], _
        ['10.25.46', 'PPM', 'PPI'], _
        ['10.25.54', 'PPM', 'PPI'], _
        ['10.25.55', 'PPM', 'PPI'], _
        ['10.25.57', 'PPM', 'PPI'], _
        ['10.25.61', 'PPM', 'PPI'], _
        ['10.25.78', 'PPM', 'PPI'], _
        ['11.2.11.3', 'PPM', 'PPI'], _
        ['11.2.15.7', 'PPM', 'PPI'], _
        ['11.2.23.4', 'PPM', 'PPI'], _
        ['CIVES-5', 'ENG', 'PPI'], _
        ['CIVES-6', 'ENG', 'PPI'], _
        ['DES-2-1', 'ENG', 'PPI'], _
        ['DES-2-2', 'ENG', 'PPI'], _
        ['DES-2-7', 'ENG', 'PPI'], _
        ['DES-3-1', 'ENG', 'PPI'], _
        ['DES-3-2', 'ENG', 'PPI'], _
        ['DES-3-3', 'ENG', 'PPI'], _
        ['DES-4-1', 'ENG', 'PPI'], _
        ['DES-4-2', 'ENG', 'PPI'], _
        ['DES-4-12', 'ENG', 'PPI'], _
        ['DES-5-2', 'ENG', 'PPI'], _
        ['EMS-01', 'EMS', 'MAN'], _
        ['ENG-DES-02', 'ENG', 'PPI'], _
        ['GEN-RPP-04', 'PPM', 'PPI'], _
        ['GEN-RPP-10', 'PPM', 'PPI'], _
        ['HPI-0.19', 'HPI', 'PPI'], _
        ['ISPM-1', 'ISPM', 'PPI'], _
        ['ISPM-2', 'ISPM', 'PPI'], _
        ['ISPM-3', 'ISPM', 'PPI'], _
        ['ISPM-4', 'ISPM', 'PPI'], _
        ['ISPM-5', 'ISPM', 'PPI'], _
        ['ISPM-6', 'ISPM', 'PPI'], _
        ['ISPM-7', 'ISPM', 'PPI'], _
        ['ISPM-8', 'ISPM', 'PPI'], _
        ['ISPM-9', 'ISPM', 'PPI'], _
        ['ISPM-10', 'ISPM', 'PPI'], _
        ['ISPM-11', 'ISPM', 'PPI'], _
        ['ISPM-12', 'ISPM', 'PPI'], _
        ['ISPM-13', 'ISPM', 'PPI'], _
        ['ISPM-14', 'ISPM', 'PPI'], _
        ['ISPM-15', 'ISPM', 'PPI'], _
        ['ISPM-16', 'ISPM', 'PPI'], _
        ['ISPM-17', 'ISPM', 'PPI'], _
        ['ISPM-18', 'ISPM', 'PPI'], _
        ['ISPM-19', 'ISPM', 'PPI'], _
        ['ISPM-20', 'ISPM', 'PPI'], _
        ['MI-2.6.1', 'MAI', 'PPI'], _
        ['MWP-1', 'MWP', 'MAN'], _
        ['MWP-5', 'MWP', 'MAN'], _
        ['MWP-7', 'MWP', 'MAN'], _
        ['MWP-10', 'MWP', 'MAN'], _
        ['MWP-13', 'MWP', 'MAN'], _
        ['QCI-2', 'QCI', 'PPI'], _
        ['SWP-CHE-05', 'SWP', 'PPI'], _
        ['SWP-CM-01', 'SWP', 'PPI'], _
        ['SWP-DES-01', 'SWP', 'PPI'], _
        ['SWP-OSH-06', 'SWP', 'PPI'], _
        ['SWP-OSH-08', 'SWP', 'PPI'], _
        ['SWP-TST-01', 'SWP', 'PPI'] _
        ]

Dim $aProcedureSize = UBound($aProcedure)
Dim $aCheckControl[($aProcedureSize +1)]


Local $exStyles = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES)

GUICreate("ListView Set Item Checked State", 500, 300)
    $bPrint = GUICtrlCreateButton('Print',425,50,60)
    $bExit = GUICtrlCreateButton('Exit', 425, 90, 60)
    GUICtrlSetonEvent($bExit, '_OnExit')
    GUICtrlSetOnEvent($bPrint, '_Print')
    $hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
    _GUICtrlListView_SetExtendedListViewStyle($hListView, $exStyles)
    GUISetState()
    
    ; Add columns
    _GUICtrlListView_AddColumn($hListView, "Doc Type", 100)
    _GUICtrlListView_AddColumn($hListView, "Sub Type", 100)
    _GUICtrlListView_AddColumn($hListView, "Doc No.", 150)
    
    ;For $i = 0 to $aProcedureSize -1
    ;   $aListItem = _GuiCtrlListView_AddItem($hListView,$aProcedure[0][2], $i)
    ;Next
    ;For $i = 0 to $aProcedureSize -1
    ;   $aListSubItem = _GUICtrlListView_AddSubItem($hListView, $i,$aProcedure[0][1], 1)
    ;Next
    ;For $i = 0 to $aProcedureSize -1
    ;   $aCheckControl[$i] = _GUICtrlListView_AddSubItem($hListView, $i, $aProcedure[$i][0], 2)
    ;Next
    
    For $i = 0 to $aProcedureSize -1
        $aListItem = _GuiCtrlListView_AddItem($hListView,$aProcedure[$i][2], $i)
        $aListSubItem = _GUICtrlListView_AddSubItem($hListView, $i,$aProcedure[$i][1], 1)
        $aCheckControl[$i] = _GUICtrlListView_AddSubItem($hListView, $i, $aProcedure[$i][0], 2)
    Next
    
    GUISetOnEvent($GUI_EVENT_CLOSE, "_OnExit")

    GUISetState()  ; display the GUI

    While 1
        Sleep(1000)
    WEnd


Func _Print($line)
    For $i = 0 to $aProcedureSize -1
        $checkboxstatus = GUICtrlRead($aCheckControl[$i])
        If $checkboxstatus == 1 Then
            MsgBox(0,'',$aProcedure[$i][0])
        Else
            MsgBox(0,'Error','Make a selection and try again')
            Return
        EndIf
    Next
EndFunc

Func _OnExit()
    Exit
EndFunc

Edit: I tried checking every checkbox....still nothing

Edited by dufran3

Share this post


Link to post
Share on other sites

ok, I managed to successfully read the control, however, now, it thinks they are all checked....here is what I changed

Func _Print($line)
    For $i = 0 to $aProcedureSize -1
        MsgBox(0,'','$i = ' & $i)
        $checkboxstatus = _GUICtrlListView_GetItemChecked($hListView, $aCheckControl[$i])
        ;$checkboxstatus = GUICtrlRead($aCheckControl[$i])
        MsgBox(0,'','checkboxstatus = ' & $checkboxstatus)
        If $checkboxstatus == 'True' Then
            MsgBox(0,'',$aProcedure[$i][0])
        Else
            MsgBox(0,'Error','Make a selection and try again')
            Return
        EndIf
    Next
EndFunc

Share this post


Link to post
Share on other sites

Something like this?

#include <GuiListView.au3>
#include <GUIConstantsEx.au3>
#include <File.au3>

Opt("GUIOnEventMode", 1)
#cs I've commented just for testing...
$file = FileOpen(@ScriptDir & '\' & 'PPM.txt')

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file: " & @ScriptDir & 'PPM.txt')
    Exit
EndIf

While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
    If $line == '' Then ExitLoop

Wend
#ce
;Create Array
Dim $aProcedure [112][3] = [ _
        ['1.3.9', 'PPM', 'PPI'], _
        ['1.3.10A', 'PPM', 'PPI'], _
        ['1.3.10B', 'PPM', 'PPI'], _
        ['1.3.10C', 'PPM', 'PPI'], _
        ['1.3.27', 'PPM', 'PPI'], _
        ['1.3.30', 'PPM', 'PPI'], _
        ['1.3.51', 'PPM', 'PPI'], _
        ['1.3.56', 'PPM', 'PPI'], _
        ['1.3.57', 'PPM', 'PPI'], _
        ['1.3.62', 'PPM', 'PPI'], _
        ['1.3.64', 'PPM', 'PPI'], _
        ['1.3.68', 'PPM', 'PPI'], _
        ['1.3.69', 'PPM', 'PPI'], _
        ['1.3.76', 'PPM', 'PPI'], _
        ['1.4.7', 'PPM', 'PPI'], _
        ['1.20.1', 'PPM', 'PPI'], _
        ['10.1.13', 'PPM', 'PPI'], _
        ['10.1.21', 'PPM', 'PPI'], _
        ['10.1.22', 'PPM', 'PPI'], _
        ['10.2.7', 'PPM', 'PPI'], _
        ['10.2.10', 'PPM', 'PPI'], _
        ['10.2.13', 'PPM', 'PPI'], _
        ['10.2.14', 'PPM', 'PPI'], _
        ['10.2.17', 'PPM', 'PPI'], _
        ['10.2.18', 'PPM', 'PPI'], _
        ['10.2.23', 'PPM', 'PPI'], _
        ['10.2.27', 'PPM', 'PPI'], _
        ['10.2.28', 'PPM', 'PPI'], _
        ['10.2.29', 'PPM', 'PPI'], _
        ['10.2.31', 'PPM', 'PPI'], _
        ['10.2.33', 'PPM', 'PPI'], _
        ['10.2.34', 'PPM', 'PPI'], _
        ['10.2.37', 'PPM', 'PPI'], _
        ['10.2.41', 'PPM', 'PPI'], _
        ['10.2.47', 'PPM', 'PPI'], _
        ['10.2.51', 'PPM', 'PPI'], _
        ['10.2.53', 'PPM', 'PPI'], _
        ['10.2.79', 'PPM', 'PPI'], _
        ['10.2.101', 'PPM', 'PPI'], _
        ['10.4.1', 'PPM', 'PPI'], _
        ['10.4.2', 'PPM', 'PPI'], _
        ['10.4.3', 'PPM', 'PPI'], _
        ['10.4.4', 'PPM', 'PPI'], _
        ['10.4.10', 'PPM', 'PPI'], _
        ['10.4.11', 'PPM', 'PPI'], _
        ['10.4.12', 'PPM', 'PPI'], _
        ['10.4.14', 'PPM', 'PPI'], _
        ['10.23.1', 'PPM', 'PPI'], _
        ['10.23.2', 'PPM', 'PPI'], _
        ['10.23.4', 'PPM', 'PPI'], _
        ['10.24.12', 'PPM', 'PPI'], _
        ['10.24.135', 'PPM', 'PPI'], _
        ['10.25.19', 'PPM', 'PPI'], _
        ['10.25.46', 'PPM', 'PPI'], _
        ['10.25.54', 'PPM', 'PPI'], _
        ['10.25.55', 'PPM', 'PPI'], _
        ['10.25.57', 'PPM', 'PPI'], _
        ['10.25.61', 'PPM', 'PPI'], _
        ['10.25.78', 'PPM', 'PPI'], _
        ['11.2.11.3', 'PPM', 'PPI'], _
        ['11.2.15.7', 'PPM', 'PPI'], _
        ['11.2.23.4', 'PPM', 'PPI'], _
        ['CIVES-5', 'ENG', 'PPI'], _
        ['CIVES-6', 'ENG', 'PPI'], _
        ['DES-2-1', 'ENG', 'PPI'], _
        ['DES-2-2', 'ENG', 'PPI'], _
        ['DES-2-7', 'ENG', 'PPI'], _
        ['DES-3-1', 'ENG', 'PPI'], _
        ['DES-3-2', 'ENG', 'PPI'], _
        ['DES-3-3', 'ENG', 'PPI'], _
        ['DES-4-1', 'ENG', 'PPI'], _
        ['DES-4-2', 'ENG', 'PPI'], _
        ['DES-4-12', 'ENG', 'PPI'], _
        ['DES-5-2', 'ENG', 'PPI'], _
        ['EMS-01', 'EMS', 'MAN'], _
        ['ENG-DES-02', 'ENG', 'PPI'], _
        ['GEN-RPP-04', 'PPM', 'PPI'], _
        ['GEN-RPP-10', 'PPM', 'PPI'], _
        ['HPI-0.19', 'HPI', 'PPI'], _
        ['ISPM-1', 'ISPM', 'PPI'], _
        ['ISPM-2', 'ISPM', 'PPI'], _
        ['ISPM-3', 'ISPM', 'PPI'], _
        ['ISPM-4', 'ISPM', 'PPI'], _
        ['ISPM-5', 'ISPM', 'PPI'], _
        ['ISPM-6', 'ISPM', 'PPI'], _
        ['ISPM-7', 'ISPM', 'PPI'], _
        ['ISPM-8', 'ISPM', 'PPI'], _
        ['ISPM-9', 'ISPM', 'PPI'], _
        ['ISPM-10', 'ISPM', 'PPI'], _
        ['ISPM-11', 'ISPM', 'PPI'], _
        ['ISPM-12', 'ISPM', 'PPI'], _
        ['ISPM-13', 'ISPM', 'PPI'], _
        ['ISPM-14', 'ISPM', 'PPI'], _
        ['ISPM-15', 'ISPM', 'PPI'], _
        ['ISPM-16', 'ISPM', 'PPI'], _
        ['ISPM-17', 'ISPM', 'PPI'], _
        ['ISPM-18', 'ISPM', 'PPI'], _
        ['ISPM-19', 'ISPM', 'PPI'], _
        ['ISPM-20', 'ISPM', 'PPI'], _
        ['MI-2.6.1', 'MAI', 'PPI'], _
        ['MWP-1', 'MWP', 'MAN'], _
        ['MWP-5', 'MWP', 'MAN'], _
        ['MWP-7', 'MWP', 'MAN'], _
        ['MWP-10', 'MWP', 'MAN'], _
        ['MWP-13', 'MWP', 'MAN'], _
        ['QCI-2', 'QCI', 'PPI'], _
        ['SWP-CHE-05', 'SWP', 'PPI'], _
        ['SWP-CM-01', 'SWP', 'PPI'], _
        ['SWP-DES-01', 'SWP', 'PPI'], _
        ['SWP-OSH-06', 'SWP', 'PPI'], _
        ['SWP-OSH-08', 'SWP', 'PPI'], _
        ['SWP-TST-01', 'SWP', 'PPI'] _
        ]

Dim $aProcedureSize = UBound($aProcedure)
Dim $aCheckControl[($aProcedureSize +1)]


Local $exStyles = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES)

GUICreate("ListView Set Item Checked State", 500, 300)
    $bPrint = GUICtrlCreateButton('Print',425,50,60)
    $bExit = GUICtrlCreateButton('Exit', 425, 90, 60)
    GUICtrlSetonEvent($bExit, '_OnExit')
    GUICtrlSetOnEvent($bPrint, '_Print')
    $hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
    _GUICtrlListView_SetExtendedListViewStyle($hListView, $exStyles)

    ; Add columns
    _GUICtrlListView_AddColumn($hListView, "Doc Type", 100)
    _GUICtrlListView_AddColumn($hListView, "Sub Type", 100)
    _GUICtrlListView_AddColumn($hListView, "Doc No.", 150)
    Dim $aListItem[$aProcedureSize]
    For $i = 0 to $aProcedureSize -1
        $aListItem[$i] = _GuiCtrlListView_AddItem($hListView,$aProcedure[0][2], $i)
    Next
    For $i = 0 to $aProcedureSize -1
        $aListSubItem = _GUICtrlListView_AddSubItem($hListView, $i,$aProcedure[0][1], 1)
    Next
    For $i = 0 to $aProcedureSize -1
        $aCheckControl[$i] = _GUICtrlListView_AddSubItem($hListView, $i, $aProcedure[$i][0], 2)
    Next


    GUISetOnEvent($GUI_EVENT_CLOSE, "_OnExit")

    GUISetState()  ; display the GUI

    While 1
        Sleep(10)
    WEnd

Func _Print()
    For $i = 0 to $aProcedureSize -1
        If _GUICtrlListView_GetItemChecked($hListView, $i) Then ConsoleWrite("Item " & $i & " is checked" & @CRLF)
    Next
EndFunc

;_Main($line)

Func _OnExit()
    Exit
EndFunc

I've replaced the MsgBox in the _Print function with some console outputs, for testing.

Share this post


Link to post
Share on other sites

Perfect!

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Edit: slow brain day....ignore...haha

Edited by dufran3

Share this post


Link to post
Share on other sites

Everything has come along quite nicely. Here is my completed code. Anything that catches your eye as unnecessary? or...improper? Please let me know

#include <GuiListView.au3>
#include <GUIConstantsEx.au3>

Opt('MouseCoordMode', 0)        ;1=absolute, 0=relative, 2=client
Opt('GUIOnEventMode', 1)

;Create Array
#region
Dim $aProcedure [112][3] = [ _
        ['1.3.9', 'PPM', 'PPI'], _
        ['1.3.10A', 'PPM', 'PPI'], _
        ['1.3.10B', 'PPM', 'PPI'], _
        ['1.3.10C', 'PPM', 'PPI'], _
        ['1.3.27', 'PPM', 'PPI'], _
        ['1.3.30', 'PPM', 'PPI'], _
        ['1.3.51', 'PPM', 'PPI'], _
        ['1.3.56', 'PPM', 'PPI'], _
        ['1.3.57', 'PPM', 'PPI'], _
        ['1.3.62', 'PPM', 'PPI'], _
        ['1.3.64', 'PPM', 'PPI'], _
        ['1.3.68', 'PPM', 'PPI'], _
        ['1.3.69', 'PPM', 'PPI'], _
        ['1.3.76', 'PPM', 'PPI'], _
        ['1.4.7', 'PPM', 'PPI'], _
        ['1.20.1', 'PPM', 'PPI'], _
        ['10.1.13', 'PPM', 'PPI'], _
        ['10.1.21', 'PPM', 'PPI'], _
        ['10.1.22', 'PPM', 'PPI'], _
        ['10.2.7', 'PPM', 'PPI'], _
        ['10.2.10', 'PPM', 'PPI'], _
        ['10.2.13', 'PPM', 'PPI'], _
        ['10.2.14', 'PPM', 'PPI'], _
        ['10.2.17', 'PPM', 'PPI'], _
        ['10.2.18', 'PPM', 'PPI'], _
        ['10.2.23', 'PPM', 'PPI'], _
        ['10.2.27', 'PPM', 'PPI'], _
        ['10.2.28', 'PPM', 'PPI'], _
        ['10.2.29', 'PPM', 'PPI'], _
        ['10.2.31', 'PPM', 'PPI'], _
        ['10.2.33', 'PPM', 'PPI'], _
        ['10.2.34', 'PPM', 'PPI'], _
        ['10.2.37', 'PPM', 'PPI'], _
        ['10.2.41', 'PPM', 'PPI'], _
        ['10.2.47', 'PPM', 'PPI'], _
        ['10.2.51', 'PPM', 'PPI'], _
        ['10.2.53', 'PPM', 'PPI'], _
        ['10.2.79', 'PPM', 'PPI'], _
        ['10.2.101', 'PPM', 'PPI'], _
        ['10.4.1', 'PPM', 'PPI'], _
        ['10.4.2', 'PPM', 'PPI'], _
        ['10.4.3', 'PPM', 'PPI'], _
        ['10.4.4', 'PPM', 'PPI'], _
        ['10.4.10', 'PPM', 'PPI'], _
        ['10.4.11', 'PPM', 'PPI'], _
        ['10.4.12', 'PPM', 'PPI'], _
        ['10.4.14', 'PPM', 'PPI'], _
        ['10.23.1', 'PPM', 'PPI'], _
        ['10.23.2', 'PPM', 'PPI'], _
        ['10.23.4', 'PPM', 'PPI'], _
        ['10.24.12', 'PPM', 'PPI'], _
        ['10.24.135', 'PPM', 'PPI'], _
        ['10.25.19', 'PPM', 'PPI'], _
        ['10.25.46', 'PPM', 'PPI'], _
        ['10.25.54', 'PPM', 'PPI'], _
        ['10.25.55', 'PPM', 'PPI'], _
        ['10.25.57', 'PPM', 'PPI'], _
        ['10.25.61', 'PPM', 'PPI'], _
        ['10.25.78', 'PPM', 'PPI'], _
        ['11.2.11.3', 'PPM', 'PPI'], _
        ['11.2.15.7', 'PPM', 'PPI'], _
        ['11.2.23.4', 'PPM', 'PPI'], _
        ['CIVES-5', 'ENG', 'PPI'], _
        ['CIVES-6', 'ENG', 'PPI'], _
        ['DES-2-1', 'ENG', 'PPI'], _
        ['DES-2-2', 'ENG', 'PPI'], _
        ['DES-2-7', 'ENG', 'PPI'], _
        ['DES-3-1', 'ENG', 'PPI'], _
        ['DES-3-2', 'ENG', 'PPI'], _
        ['DES-3-3', 'ENG', 'PPI'], _
        ['DES-4-1', 'ENG', 'PPI'], _
        ['DES-4-2', 'ENG', 'PPI'], _
        ['DES-4-12', 'ENG', 'PPI'], _
        ['DES-5-2', 'ENG', 'PPI'], _
        ['EMS-01', 'EMS', 'MAN'], _
        ['ENG-DES-02', 'ENG', 'PPI'], _
        ['GEN-RPP-04', 'PPM', 'PPI'], _
        ['GEN-RPP-10', 'PPM', 'PPI'], _
        ['HPI-0.19', 'HPI', 'PPI'], _
        ['ISPM-1', 'ISPM', 'PPI'], _
        ['ISPM-2', 'ISPM', 'PPI'], _
        ['ISPM-3', 'ISPM', 'PPI'], _
        ['ISPM-4', 'ISPM', 'PPI'], _
        ['ISPM-5', 'ISPM', 'PPI'], _
        ['ISPM-6', 'ISPM', 'PPI'], _
        ['ISPM-7', 'ISPM', 'PPI'], _
        ['ISPM-8', 'ISPM', 'PPI'], _
        ['ISPM-9', 'ISPM', 'PPI'], _
        ['ISPM-10', 'ISPM', 'PPI'], _
        ['ISPM-11', 'ISPM', 'PPI'], _
        ['ISPM-12', 'ISPM', 'PPI'], _
        ['ISPM-13', 'ISPM', 'PPI'], _
        ['ISPM-14', 'ISPM', 'PPI'], _
        ['ISPM-15', 'ISPM', 'PPI'], _
        ['ISPM-16', 'ISPM', 'PPI'], _
        ['ISPM-17', 'ISPM', 'PPI'], _
        ['ISPM-18', 'ISPM', 'PPI'], _
        ['ISPM-19', 'ISPM', 'PPI'], _
        ['ISPM-20', 'ISPM', 'PPI'], _
        ['MI-2.6.1', 'MAI', 'PPI'], _
        ['MWP-1', 'MWP', 'MAN'], _
        ['MWP-5', 'MWP', 'MAN'], _
        ['MWP-7', 'MWP', 'MAN'], _
        ['MWP-10', 'MWP', 'MAN'], _
        ['MWP-13', 'MWP', 'MAN'], _
        ['QCI-2', 'QCI', 'PPI'], _
        ['SWP-CHE-05', 'SWP', 'PPI'], _
        ['SWP-CM-01', 'SWP', 'PPI'], _
        ['SWP-DES-01', 'SWP', 'PPI'], _
        ['SWP-OSH-06', 'SWP', 'PPI'], _
        ['SWP-OSH-08', 'SWP', 'PPI'], _
        ['SWP-TST-01', 'SWP', 'PPI'] _
        ]
#endregion

Dim $aProcedureSize = UBound($aProcedure)
Dim $aCheckControl[($aProcedureSize +1)]


Local $exStyles = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES,$LVS_EX_GRIDLINES)
GUICreate('ListView Set Item Checked State', 500, 500)
$bPrint = GUICtrlCreateButton('Print',425,50,60)
$bExit = GUICtrlCreateButton('Exit', 425, 90, 60)
GUICtrlSetonEvent($bExit, '_OnExit')
GUICtrlSetOnEvent($bPrint, '_Print')
$hListView = GUICtrlCreateListView('', 2, 2, 394, 468)
_GUICtrlListView_SetExtendedListViewStyle($hListView, $exStyles)
GUISetState()

; Add columns
_GUICtrlListView_AddColumn($hListView, 'Doc Type', 100)
_GUICtrlListView_AddColumn($hListView, 'Sub Type', 100)
_GUICtrlListView_AddColumn($hListView, 'Doc No.', 150)

;Add items and subitems
For $i = 0 to $aProcedureSize -1
    $aListItem = _GuiCtrlListView_AddItem($hListView,$aProcedure[$i][2], 0)
    $aListSubItem = _GUICtrlListView_AddSubItem($hListView, $i,$aProcedure[$i][1], 1)
    $aCheckControl[$i] = _GUICtrlListView_AddSubItem($hListView, $i, $aProcedure[$i][0], 2)
Next

GUISetOnEvent($GUI_EVENT_CLOSE, '_OnExit')

GUISetState()  ; display the GUI

While 1
    Sleep(1000)
WEnd

Func _Print()
GUISetState(@SW_HIDE )
    For $i = 0 to $aProcedureSize -1
        If _GUICtrlListView_GetItemChecked($hListView, $i) Then
            WinActivate('TIM')
            $PortalWait = WinWaitActive('TIM','',10)
                If $PortalWait == 0 Then
                    MsgBox(0,'Error','Portal window not found')
                    GuiSetState(@SW_SHOW)
                    Return
                EndIf
            MouseClick('Left',378,75)
            WinWait('TIMX000 - VENTYX INCORPORATED - [ PAS6 ]')
            MouseClick('Left',461,432)
            WinWait ('TIMMENU - [ PAS6 ]')
            MouseClick('Left',211,110)
            WinWait('TIMC010 - CONT DOC - INFORMATION - [ PAS6 ]')
            MouseClick('Left',119,151)
            Send($aProcedure[$i][2])
            MouseClick('Left',440,151)
            Send($aProcedure[$i][1])
            MouseClick('Left',200,174)
            Send($aProcedure[$i][0])
            Send('{ENTER}')
            Sleep(1500)
            MouseClick('Left',376,533)
            ;New window
            WinWait('File Download')
            WinActivate('FileDownload')
            Sleep(500)
            ControlClick('File Download', '', '[ID:4423]')
            WinActivate('00')
            WinWaitActive('00')
            Sleep(1000)
            Send('!{F4}')
            Return
            ;Adobe
            WinActivate('00')
            WinWaitActive('00')
            Send('^p')
            ;Printing
            WinWaitActive('Print')
            ControlClick('Print','','Button27')
            WinWait('Progress')
            WinWaitClose('Progress')
            WinActivate('00')
            Sleep(1000)
            Send('!{F4}')
        EndIf
    Next
    MsgBox(0,'','Done')
    Exit
EndFunc

Func _OnExit()
    Exit
EndFunc

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  
Followers 0