Sign in to follow this  
Followers 0
aleph01

Buttons work inconsistently

11 posts in this topic

I set a variable as a return from a button click. Sometimes it works on the first click, but I have had to click the button 5 times for it to work at times.

Here's the code:

; Select items

;While $fin <> $FinishButton

While $fin <> 3

_GUICtrlListBox_SelItemRange($hListBox, -1, -1, $fSelect = True)

$can = GUIGetMsg()

If $can = 4 Then Exit

;If $can = $CancelButton Then Exit

$fin = GUIGetMsg()

WEnd

The Finish button ($FinishButton) returns a 3, the Cancel button returns a 4. Both of these buttons work inconsistently. Can someone embarrass me by pointing out a dumb mistake I've made, or perhaps just pointing out a more fool-proof way? Thanks!


Meds.  They're not just for breakfast anymore. :'(

Share this post


Link to post
Share on other sites



aleph01,

Where to start? ;)

What are you trying to do with the _GUICtrlListBox_SelItemRange line? :P

The parameters are not exactly what I would expect. $iFirst and $iLast shoudl be zero-based items - whay are you using -1? And the final parameter should just be True or False - the $fSelect = True part of the syntax in the Help file indicates that omitting the parameter will set a default of True. And why are you calling it in a loop - surely once would be enough? :)

Now the buttons. :)

As it is you are calling GUIGetMsg twice in the same loop. So if you press the one button its message is likely to be eaten by the other button's call to the function. You have to be very lucky to get your button press picked up by the correct GUIGetMsg - that is why your buttons seem unresponsive. Furthermore you should not use hardcoded ControlIDs to identify controls - it makes changing the code almost impossible. ;)

So what you should have is something like this: :)

[ When you create the buttons

$hCancel_Button = GUICtrlCreateButton("Cancel", ....
$hFinish_Button = GUICtrlCreateButton("Finish", ....

; And then in the loop

While 1
    Switch GUIGetMsg()
        Case $hCancel_Button
            Exit
        Case $hFinish_Button
            ExitLoop
    EndSwitch
WEnd

As you seem to have little idea about how AutoIt actually works, could I recommend reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References)- it will help you enormously. You should also look at the excellent tutorials that you will find here and here - you will find other tutorials in the Wiki (the link is at the top of the page). :D

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

After you retrieve the GuiGetMsg() once, check it for all cases you want to handle before retrieving it again. Something more like this:

While 1
     Switch GuiGetMsg()
          Case 3
               ; Do stuff for Finsh
          Case 4
               ; Do stuff for Cancel
     EndSwitch
WEnd

:)

Edit: Out-typed by the Melba-bird!

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

First, thanks again, M23! I guess I have a lot of explaining to do.

I had the _GUICtrlListBox_SelItemRange line in the loop because the selection box was just flashing for a moment before I put in the loop. I don't know why it happened then but not now without the line in a loop.

The $iFirst and $iLast were set to 3 and 5 in the help file because the author was intending to make a couple of selections. I saw that they should be zero-based, but when I set them to 0, some items on the list could not be selected. -1 seemed to resolve that.

As for using the GUIGetMsg twice, I had two variables that I was wanting to compare to GUIGetMsg. It didn't occur to me that I only needed to call it once.

I had no idea of Switch / Case / EndSwitch. I'll mentally file that away for future use.

This is my first attempt to write a GUI more complex than InputBox or MsgBox. I'll definately read Using AutoIt and the other items you suggested.

I believe that in April, when I begin a Visual Basic class, I'll code each assignment in VB for class and in AutoIt for experience.

Thanks again for taking a noob under your wing.


Meds.  They're not just for breakfast anymore. :'(

Share this post


Link to post
Share on other sites

aleph01,

If you wanted to post the whole script, I would be happy to take a look and make any suggestions that might occur to me. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Here's the script. It appears that my computernames aren't being populated as elements in the arrray. At least, that's the conclusion I com to from looking at the output of _ArrayDisplay ($aItems)

Thanks for being so geneerous withyour time.

aleph01

#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6

#include <GUIListBox.au3>

#include <GuiConstantsEx.au3>

#include <Array.au3>

#Include <Misc.au3>

_Singleton("CUOPACScreensaverReplacement", 0)

Opt("MustDeclareVars", 1)

;$Debug_LB = False ; Check ClassName being passed to ListBox functions, set to True and use a handle to another control to see it work

dim $cancel = 1

dim $cancel2 = 1

Global $iI

$cancel = MsgBox (1, "Replace the Screensaver on CUOPACs", "Save your screensaver image, correctly sized, as a bitmap (.bmp extension) directly on your desktop.")

If $cancel = 2 Then Exit

Local $SourceFile

Local $z = 1

While $z = 1

$SourceFile = InputBox ("Screensaver Filename", "Type the name of your screensaver file without the extension. Example: Great Decisions", "", "", 300,130)

If @Error = 1 Then Exit

If Not FileExists ("C:\Documents and Settings\" & @UserName & "\Desktop\" & $SourceFile & ".bmp") Then

$cancel2 = MsgBox (1, "File Does Not Exist", "Please check your filename and spelling.")

If $cancel2 = 2 Then Exit

Else

$SourceFile = ($SourceFile & ".bmp")

$z = 2

EndIf

WEnd

_Main()

For $sItems = 1 To $aItems[0]

FileCopy ("C:\Documents and Settings\" & @UserName & "\desktop\" & $SourceFile, "\\" & $sItems & "\C$\Program Files\EnvisionWare\PC Reservation\Client Module\images\FCPLpcRes.bmp", 1)

Next

MsgBox (0, "Screensaver Replacement Completed", "The screensavers on the systems specified have been replaced. A reboot of the systems is required before the new screensavers will display. You may now move the screensaver file from your desktop to where you archive your screensaver files.")

Exit

Func _Main()

Local $hListBox, $FinishButton, $CancelButton

; Create GUI

GUICreate("Select Computers", 210, 515)

$FinishButton = GUICtrlCreateButton("Finish", 4, 490, 120)

$CancelButton = GUICtrlCreateButton("Cancel", 126, 490, 80)

$hListBox = GUICtrlCreateList("", 2, 2, 396, 496, BitOR($LBS_STANDARD, $LBS_EXTENDEDSEL))

GUISetState()

; Add strings

_GUICtrlListBox_BeginUpdate($hListBox)

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPAC1", 0))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPAC2", 1))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPAC3", 2))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPAC4", 3))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPAC5", 4))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACS1", 5))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACS2", 6))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACS3", 7))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACS4", 8))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACS5", 9))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACS6", 10))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACS7", 11))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACS8", 12))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACS9", 13))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACS10", 14))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACS11", 15))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACS12", 16))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACS13", 17))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACS14", 18))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACS15", 19))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACS16", 20))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACS17", 21))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACS18", 22))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACS19", 23))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACS20", 24))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACS21", 25))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACS22", 26))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACS23", 27))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACS24", 28))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACS25", 29))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACS26", 30))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACS27", 31))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACS28", 32))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACS29", 33))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACEC1", 34))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACEC2", 35))

_GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACEC3", 36))

_GUICtrlListBox_EndUpdate($hListBox)

; Select items

While 1

Switch GUIGetMsg()

Case $CancelButton

Exit

Case $FinishButton

ExitLoop

EndSwitch

WEnd

; Get indexes of selected items

Global $aItems

Global $sItems

$aItems = _GUICtrlListBox_GetSelItems($hListBox)

For $iI = 1 To $aItems[0]

If $iI > 1 Then $sItems &= ", "

$sItems &= $aItems[$iI]

Next

GUIDelete()

; Show the item selection state

_ArrayDisplay ($aItems)

EndFunc ;==>_Main


Meds.  They're not just for breakfast anymore. :'(

Share this post


Link to post
Share on other sites

aleph01,

You need to use _GUICtrlListBox_GetSelItemsText - look for the <<<<<<<<< line: :)

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GUIListBox.au3>
#include <GuiConstantsEx.au3>
#include <Array.au3>
#include <Misc.au3>

_Singleton("CUOPACScreensaverReplacement", 0)

Opt("MustDeclareVars", 1)

Global $aItems, $sItems

;$Debug_LB = False ; Check ClassName being passed to ListBox functions, set to True and use a handle to another control to see it work

If MsgBox(1, "Replace the Screensaver on CUOPACs", "Save your screensaver image, correctly sized, as a bitmap (.bmp extension) directly on your desktop.") = 2 Then Exit

Global $SourceFile ; Everything is Global in the main script

While 1
    $SourceFile = InputBox("Screensaver Filename", "Type the name of your screensaver file without the extension. Example: Great Decisions", "", "", 300, 130)
    If @error = 1 Then Exit
    If Not FileExists("C:\Documents and Settings\" & @UserName & "\Desktop\" & $SourceFile & ".bmp") Then
        ;If MsgBox(1, "File Does Not Exist", "Please check your filename and spelling.") = 2 Then Exit
        ExitLoop
    Else
        $SourceFile = ($SourceFile & ".bmp")
        ExitLoop
    EndIf
WEnd

_Main()

For $sItems = 1 To $aItems[0]
    ; Write computernames to the SciTE console after removing the number and colon
    ConsoleWrite(StringTrimLeft($aItems[$sItems], 6) & @CRLF)
    ;FileCopy("C:\Documents and Settings\" & @UserName & "\desktop\" & $SourceFile, "\\" & $sItems & "\C$\Program Files\EnvisionWare\PC Reservation\Client Module\images\FCPLpcRes.bmp", 1)
Next

MsgBox(0, "Screensaver Replacement Completed", "The screensavers on the systems specified have been replaced. A reboot of the systems is required before the new screensavers will display. You may now move the screensaver file from your desktop to where you archive your screensaver files.")
Exit

Func _Main()
    Local $hListBox, $FinishButton, $CancelButton

    ; Create GUI
    GUICreate("Select Computers", 210, 515)
    $FinishButton = GUICtrlCreateButton("Finish", 4, 490, 120)
    $CancelButton = GUICtrlCreateButton("Cancel", 126, 490, 80)

    $hListBox = GUICtrlCreateList("", 2, 2, 396, 496, BitOR($LBS_STANDARD, $LBS_EXTENDEDSEL))
    GUISetState()

    ; Add strings
    _GUICtrlListBox_BeginUpdate($hListBox)
    For $i = 0 To 4
        _GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPAC1", $i))
    Next
    For $i = 1 To 29
        _GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACS" & $i, $i + 4))
    Next
    For $i = 1 To 3
        _GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACEC" & $i, $i + 33))
    Next
    _GUICtrlListBox_EndUpdate($hListBox)

    ; Select items
    While 1
        Switch GUIGetMsg()
            Case $CancelButton
                Exit
            Case $FinishButton
                ExitLoop
        EndSwitch
    WEnd

    ; Get text of selected items
    $aItems = _GUICtrlListBox_GetSelItemsText($hListBox) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    GUIDelete()
    ; Show the selected item text
    _ArrayDisplay($aItems)

EndFunc   ;==>_Main

One or two other things to note:

- Just use the return value from the MsgBox directly - no need for a temp variable.

- Use loops to reduce the wear and tear on the typing fingers.

- And a few other code modifications for you to ponder. :D

Please ask if anything is unclear or if I have misunderstood what you wanted from the code. :)

M23

P.S. When you post code please use Code tags. Put [autoit] before and [/autoit] after your posted code. :P


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

M23,

Thanks again for your help. I’m still not having success with the script. It just isn’t copying the file to the selected computers.

I get the list box showing 000 : CUOPAC1 (the1st computername) … 036 : CUOPACEC3 (the 37th computername), so that looks right, (except is there a way to show only the computernames and not the numbers in the listbox? – I know my boss is going to ask for that), and when I select all of the computers on the list, _ArrayDisplay shows index [0] 37 (the number of computers selected), index [1] 000 : CUOPAC1 … index [37] CUOPACEC3, so it looks like the computernames are being placed in the array correctly.

When I rewrote the ConsoleWrite line to make it MsgBox output, it gave me 5 messageboxes with “9” as the output, 9 with “10”, and 24 with “11” (no quotes, just the numerals), so it looks like that’s where my current problem is. Of course, the output isn’t my computernames, but also note that there are 38 outputs for 37 selections. It appears that I’m getting output from array index [0], which doesn’t hold a computername.

I’m in way over my head. Can you take another look?

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GUIListBox.au3>
#include <GuiConstantsEx.au3>
#include <Array.au3>
#include <Misc.au3>

_Singleton("CUOPACScreensaverReplacement", 0)

Opt("MustDeclareVars", 1)

Dim $aItems, $sItems, $SourceFile

;$Debug_LB = False ; Check ClassName being passed to ListBox functions, set to True and use a handle to another control to see it work

If MsgBox(1, "Replace the Screensaver on CUOPACs", "Save your screensaver image, correctly sized, as a bitmap (.bmp extension) directly on your desktop.") = 2 Then Exit

While 1
    $SourceFile = InputBox("Screensaver Filename", "Type the name of your screensaver file without the extension. Example: Great Decisions", "", "", 300, 130)
    If @error = 1 Then Exit
      If Not FileExists("C:\Documents and Settings\" & @UserName & "\Desktop\" & $SourceFile & ".bmp") Then
        If MsgBox(1, "File Does Not Exist", "Please check your filename and spelling.") = 2 Then Exit
    Else
        $SourceFile = ($SourceFile & ".bmp")
        ExitLoop
    EndIf
WEnd

_Main()

For $sItems = 1 To $aItems[0]
    ; Write computernames to the SciTE console after removing the number and colon
    MsgBox (1, "", ConsoleWrite(StringTrimLeft($aItems[$sItems], 6) & @CRLF))
   ; FileCopy("C:\Documents and Settings\" & @UserName & "\desktop\" & $SourceFile, "\\" & $sItems & "\C$\Program Files\EnvisionWare\PC Reservation\Client Module\images\FCPLpcRes.bmp", 1)
Next

MsgBox(0, "Screensaver Replacement Completed", "The screensavers on the systems specified have been replaced. A reboot of the systems is required before the new screensavers will display. You may now move the screensaver file from your desktop to where you archive your screensaver files.")
Exit

Func _Main()
    Local $hListBox, $FinishButton, $CancelButton

    ; Create GUI
    GUICreate("Select Computers", 210, 515)
    $FinishButton = GUICtrlCreateButton("Finish", 4, 490, 120)
    $CancelButton = GUICtrlCreateButton("Cancel", 126, 490, 80)

    $hListBox = GUICtrlCreateList("", 2, 2, 396, 496, BitOR($LBS_STANDARD, $LBS_EXTENDEDSEL))
    GUISetState()

    ; Add strings
    _GUICtrlListBox_BeginUpdate($hListBox)
    For $i = 0 To 4
        _GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPAC" & $i + 1, $i))
    Next
    For $i = 1 To 29
        _GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACS" & $i, $i + 4))
    Next
    For $i = 1 To 3
        _GUICtrlListBox_AddString($hListBox, StringFormat("%03d : CUOPACEC" & $i, $i + 33))
    Next
    _GUICtrlListBox_EndUpdate($hListBox)

    ; Select items
    While 1
        Switch GUIGetMsg()
            Case $CancelButton
                Exit
            Case $FinishButton
                ExitLoop
        EndSwitch
    WEnd

    ; Get text of selected items
    $aItems = _GUICtrlListBox_GetSelItemsText($hListBox) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    GUIDelete()
    _ArrayDisplay($aItems)

EndFunc   ;==>_Main

Meds.  They're not just for breakfast anymore. :'(

Share this post


Link to post
Share on other sites

aleph01,

When I rewrote the ConsoleWrite line to make it MsgBox output

Which gave complete rubbish as a result becuse you did not do it correctly. :)

Here is how you get the names without the numbers into the list (who gave you the complicated StringFormat code to begin with?) and the correct way to get the computer names into a string to use in your FileCopy line.

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GUIListBox.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <Misc.au3>

_Singleton("CUOPACScreensaverReplacement", 0)

Opt("MustDeclareVars", 1)

Dim $aItems, $sItems, $SourceFile

;$Debug_LB = False ; Check ClassName being passed to ListBox functions, set to True and use a handle to another control to see it work
#cs
If MsgBox(1, "Replace the Screensaver on CUOPACs", "Save your screensaver image, correctly sized, as a bitmap (.bmp extension) directly on your desktop.") = 2 Then Exit

While 1
    $SourceFile = InputBox("Screensaver Filename", "Type the name of your screensaver file without the extension. Example: Great Decisions", "", "", 300, 130)
    If @error = 1 Then Exit
      If Not FileExists("C:\Documents and Settings\" & @UserName & "\Desktop\" & $SourceFile & ".bmp") Then
        If MsgBox(1, "File Does Not Exist", "Please check your filename and spelling.") = 2 Then Exit
    Else
        $SourceFile = ($SourceFile & ".bmp")
        ExitLoop
    EndIf
WEnd
#ce
_Main()

For $sItems = 1 To $aItems[0]
    ; Write path including computernames in a MsgBox
    MsgBox (0, "","\\" & $aItems[$sItems] & "\C$\Program Files\EnvisionWare\PC Reservation\Client Module\images\FCPLpcRes.bmp")
   ; FileCopy("C:\Documents and Settings\" & @UserName & "\desktop\" & $SourceFile, "\\" & $sItems & "\C$\Program Files\EnvisionWare\PC Reservation\Client Module\images\FCPLpcRes.bmp", 1)
Next

MsgBox(0, "Screensaver Replacement Completed", "The screensavers on the systems specified have been replaced. A reboot of the systems is required before the new screensavers will display. You may now move the screensaver file from your desktop to where you archive your screensaver files.")
Exit

Func _Main()
    Local $hListBox, $FinishButton, $CancelButton

    ; Create GUI
    GUICreate("Select Computers", 210, 515)
    $FinishButton = GUICtrlCreateButton("Finish", 4, 490, 120)
    $CancelButton = GUICtrlCreateButton("Cancel", 126, 490, 80)

    $hListBox = GUICtrlCreateList("", 2, 2, 396, 496, BitOR($WS_BORDER, $WS_VSCROLL, $LBS_EXTENDEDSEL))
    GUISetState()

    ; Add strings
    _GUICtrlListBox_BeginUpdate($hListBox)
    For $i = 0 To 4
        _GUICtrlListBox_AddString($hListBox, "CUOPAC" & $i + 1) ;StringFormat("%03d : CUOPAC" & $i + 1, $i))
    Next
    For $i = 1 To 29
        _GUICtrlListBox_AddString($hListBox, "CUOPACS" & $i) ; StringFormat("%03d : CUOPACS" & $i, $i + 4))
    Next
    For $i = 1 To 3
        _GUICtrlListBox_AddString($hListBox, "CUOPACEC" & $i) ; StringFormat("%03d : CUOPACEC" & $i, $i + 33))
    Next
    _GUICtrlListBox_EndUpdate($hListBox)

    ; Select items
    While 1
        Switch GUIGetMsg()
            Case $CancelButton
                Exit
            Case $FinishButton
                ExitLoop
        EndSwitch
    WEnd

    ; Get text of selected items
    $aItems = _GUICtrlListBox_GetSelItemsText($hListBox) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    GUIDelete()
    _ArrayDisplay($aItems)

EndFunc   ;==>_Main

Just check if the MsgBox content is what you use to transfer the files manually and you should be good to go. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

M23,

It works great! I can't begin to express my gratitude. If you are (or are ever) in the Atlanta area, I owe you a dinner and a drink. I'll modify this for my two other branch libraries, but then, I'm going to go over it with a fine-tooth comb with my help file open and try to get a handle on some of the things that confuse me. I've had limited time to try to analyze the script - a desktop support tech is always subject to interruption. I may just do that this weekend. And thanks for dropping the StringFormat. I don't think I'm ready for that yet.

I hope you reap what you sow, because you did me a really big favor here.

Thanks again.


Meds.  They're not just for breakfast anymore. :'(

Share this post


Link to post
Share on other sites

aleph01,

Glad I could help. :)

If you do have any questions then please do ask them in the forum - that is why we are here after all. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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