Jump to content
Sign in to follow this  
galan2015

Loop and set another data in GUICtrlCreateCombo

Recommended Posts

galan2015

 

;I'd like to on the end of the function, script changed for another option in the combolist. This will be part of the loop

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 418, 177, 192, 114)
$Combo1 = GUICtrlCreateCombo("exe Files", 16, 24, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GuiCtrlSetData(-1,'ini Files|Txt Files|Cfg files')
$Combo2 = GUICtrlCreateCombo("Find A", 176, 24, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GuiCtrlSetData(-1,'Find B')
$Input1 = GUICtrlCreateInput("Input1", 16, 56, 321, 21)
$Button = GUICTRLCreateButton("check", 10, 10, 20,20)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 16, 80, 97, 25)
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 120, 80, 97, 25)
$Checkbox3 = GUICtrlCreateCheckbox("Checkbox3", 224, 80, 113, 25)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg

        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

 

 

Edited by galan2015

Share this post


Link to post
Share on other sites
JLogan3o13

Can you please explain more clearly what you are trying to do? This...

script changed for another option in the combolist.

...is very vague. 


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
kylomas

galan2015,

Is your question related to this thread?  If so, does my response help?  If not, see JLogan3o13 above.

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites
galan2015

galan2015,

Is your question related to this thread?  If so, does my response help?  If not, see JLogan3o13 above.

kylomas

I would like to take a snapshot of data from text files. No.

1. My first combo [Select file]
2. My second combo [Male | Female]
3. My third combo [Michael | Jordan | Natasha]

I would like to function if it is proven options to choose from in ComboList1, ComboList2, Combolist3. After selecting ComboList3 (CL2 is a sub-CL1 and CL2 CL3 is a sub-category) and then to change to the next available option.

Share this post


Link to post
Share on other sites
Melba23

galan2015,

Does this help?

#include <GUIConstantsEx.au3>

$sData_1 = "Option 1|Option 2|Option 3"
$sData_2A = "|Option 101|Option 201|Option 301"
$sData_2B = "|Option 402|Option 502|Option 602"
$sData_2C = "|Option 703|Option 803|Option 903"

$hGUI = GUICreate("Test", 500, 500)

$cCombo_1 = GUICtrlCreateCombo("", 10, 10, 200, 20)
GUICtrlSetData($cCombo_1, $sData_1)

$cCombo_2 = GUICtrlCreateCombo("", 250, 10, 200, 20)
GUICtrlSetState($cCombo_2, $GUI_DISABLE)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cCombo_1
            Switch GUICtrlRead($cCombo_1)
                Case "Option 1"
                    GUICtrlSetData($cCombo_2, $sData_2A)
                    GUICtrlSetState($cCombo_2, $GUI_ENABLE)
                Case "Option 2"
                    GUICtrlSetData($cCombo_2, $sData_2B)
                    GUICtrlSetState($cCombo_2, $GUI_ENABLE)
                Case "Option 3"
                    GUICtrlSetData($cCombo_2, $sData_2C)
                    GUICtrlSetState($cCombo_2, $GUI_ENABLE)
            EndSwitch

    EndSwitch

WEnd

If this is nowhere close, then please try and explain what you are trying to do in more detail as you are not being very clear at present.

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
galan2015

I need to change the data in 60,000 files. The function appends a line to each file.
I have three combo list:
1. The first combo A | B | C | .. | Z after selecting a name in the pop Combo 2
2. The names of clients
3. The third combo contains a list of files in a folder on my misfortune number of files to be edited for any user: 8.

After selecting the data manually from the combo letter, after pressing the button that activates the function appends data to a single file.

But I would like to function After adding in the file lines jumped to the next file and performed the function again. The file names in a combo 2 and 3 are variable.

Share this post


Link to post
Share on other sites
Melba23

galan2015,

That reads nothing like what you described in your earlier posts - and really does not advance us very much further forward. I will try and ask specific questions to see if I can tease out some more details.

- 1. The combo which the user actions first - what does it contain?

- 2. The combo which holds the "names of clients" - from where does it get these? Is its content alphabetically linked to the "A-Z" combo?

- 3. Where does the combo with a file list come in? I really hope you do not intend to put all 60,000 filenames in it!  You say you want to "jump[...] to the next file" - how do you define "the next file" if you can only select one at a time in the combo?

You answer those points clearly and we might be able to make some progress.

M23

  • Like 1

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
galan2015

Combo1 contains a list from A to Z.
Combo2
contains a list of names from txt file.              ;;;;;;;;;; Made by myself, User1|User2|User4

Combo 3 contains a list of paths to files from txt file ;;;;;;;;;;;; usrini.txt|user.txt|backup.txt|class.txt|forum.txt|log.txt ... and two others

I want to do :
Pick Combo1[A]
Pick Combo2[Andrzej1]
PIck Combo3[1] ; $i = 8, 8 files
Function
Pick Combo3[2]
Function
Pick Combo3[3]
Function

Pick Combo3[4]
Function

Pick Combo3[5]
Function

Pick Combo3[6]
Function

Pick Combo3[7]
Function
Pick Combo3[8]
Function

Pick Combo2[Andrzej2]
Pick Combo3[1]

Function
Pick Combo3[2]
Function
Pick Combo3[3]
Function

Pick Combo3[4]
Function

Pick Combo3[5]
Function

Pick Combo3[6]
Function

Pick Combo3[7]
Function
Pick Combo3[8]
Function


.........

Edited by galan2015

Share this post


Link to post
Share on other sites
galan2015

Otherwise, how to count the number of options in comboList?

Share this post


Link to post
Share on other sites
kylomas

galan2015,

Total entries or selected entries?  As I said in the thread that I pointed you to earlier, definition of the relationships of the data in the combo controls is the only difficult task here.  Combo1 is related to combo2...is related to combo2...etc...

Perhaps if you post some real world example data with an explanation of it's use it will become clearer. 

kylomas

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites
Melba23

galan2015,

Looking at what you want to do, why are you even thinking of using combos? All you do is run through their entries one by one in order - and that is a job for loops, not combos.

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
galan2015

im gonna make some sample :P  give me a time

Share this post


Link to post
Share on other sites
galan2015

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 458, 122, 192, 114)
$Combo1 = GUICtrlCreateCombo("ComboA", 0, 8, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUiCtrlSetData(-1,"ComboB")
$Combo2 = GUICtrlCreateCombo("Sex", 152, 8, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Combo3 = GUICtrlCreateCombo("Combo3", 304, 8, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 8, 56, 97, 17)
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 120, 56, 97, 17)
$Button = GUICtrlCreateButton('write file',280,56,50,30)
GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

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

            Exit
        Case $Combo1
        $if1 = GuiCtrlRead($combo1)
IF      $if1 = 'ComboA' then
            GuiCtrlSetData($Combo2,"")
    GuiCtrlSetData($Combo2,"Male")
    EndIf
IF      $if1 = 'ComboB' then
        GuiCtrlSetData($Combo2,"")
    GuiCtrlSetData($Combo2,"Female")
    EndIf
        Case $Combo2
        $if1 = GuiCtrlRead($combo2)
IF      $if1 = 'Female' then
    GuiCtrlSetData($Combo3,"")
    GuiCtrlSetData($Combo3,"Agnieszka|Ania")
    EndIf
IF      $if1 = 'Male' then
    GuiCtrlSetData($Combo3,"")
    GuiCtrlSetData($Combo3,"Andrzej|Adam")
    Endif
        Case $Combo3
IF      $if1 = 'Andrzej' then
EndIf
        Case $Button
              GUICtrlSetState($Checkbox2,1)
              Sleep(150)
            GUICtrlSetState($Checkbox2,1)
            MSgBox(1,'ANd what now script should do','Script should pick Another option from $combo3. That is it')
    EndSwitch
WEnd

 

Share this post


Link to post
Share on other sites
kylomas

Script should pick Another option from $combo3

Based on what?

 


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites
JLogan3o13

Personally I would do something like this. Of course, if you get into multiple sub choices this is going to be a PITA to support:

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 458, 122, 192, 114)
$Combo1 = GUICtrlCreateCombo("Choose Combo", 0, 8, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
    GUiCtrlSetData(-1,"ComboA|ComboB", "Choose Combo")
$Combo2 = GUICtrlCreateCombo("Choose Sex", 152, 8, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
    GUiCtrlSetData(-1,"Male|Female", "Choose Sex")
$Combo3 = GUICtrlCreateCombo("Choose Name", 304, 8, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
        GUiCtrlSetData(-1,"Fred|Judy", "Choose Name")

$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 8, 56, 97, 17)
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 120, 56, 97, 17)
$Button = GUICtrlCreateButton('write file',280,56,50,30)
GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo1
            If GUICtrlRead($Combo1) = "Choose Combo" Then
                GUICtrlSetData($Combo2, "Choose Sex")
                GUICtrlSetData($Combo3, "Choose Name")
            Else
                GUICtrlSetData($Combo2, (GUICtrlRead($combo1) = "ComboA") ? "Male" : "Female")
                    If GUICtrlRead($Combo2) <> "Choose Sex" Then GUICtrlSetData($Combo3, (GUICtrlRead($combo2) = "Male") ? "Fred" : "Judy")
            EndIf
    EndSwitch
WEnd

 


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
galan2015

Personally I would do something like this. Of course, if you get into multiple sub choices this is going to be a PITA to support:

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 458, 122, 192, 114)
$Combo1 = GUICtrlCreateCombo("Choose Combo", 0, 8, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
    GUiCtrlSetData(-1,"ComboA|ComboB", "Choose Combo")
$Combo2 = GUICtrlCreateCombo("Choose Sex", 152, 8, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
    GUiCtrlSetData(-1,"Male|Female", "Choose Sex")
$Combo3 = GUICtrlCreateCombo("Choose Name", 304, 8, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
        GUiCtrlSetData(-1,"Fred|Judy", "Choose Name")

$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 8, 56, 97, 17)
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 120, 56, 97, 17)
$Button = GUICtrlCreateButton('write file',280,56,50,30)
GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo1
            If GUICtrlRead($Combo1) = "Choose Combo" Then
                GUICtrlSetData($Combo2, "Choose Sex")
                GUICtrlSetData($Combo3, "Choose Name")
            Else
                GUICtrlSetData($Combo2, (GUICtrlRead($combo1) = "ComboA") ? "Male" : "Female")
                    If GUICtrlRead($Combo2) <> "Choose Sex" Then GUICtrlSetData($Combo3, (GUICtrlRead($combo2) = "Male") ? "Fred" : "Judy")
            EndIf
    EndSwitch
WEnd

 

​no that is big fail :P hope i will learn by myself and show u how  how i solve the problem

 

Share this post


Link to post
Share on other sites
JLogan3o13

As I said, it would be a pain in the ass to manage, but you're insisting to do it with combos rather than a loop (as at least one member has already suggested).


√-1 2^3 ∑ π, and it was delicious!

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  

  • Similar Content

    • Skeletor
      By Skeletor
      Hi Guys,
      Is it possible to get a variable on your For..Next loop? 
       
      Local $Lines1 = _FileCountLines(C:\temp\test.txt) Local $linesToCount2 = $Lines1 + 2 $var = Number($linesToCount2) For $count = 1 To _FileCountLines($FileRead2) Step 1 For $i = $var To $count Next ;Code does stuff here Next Somehow my code doesn't work even though I thought I could convert the variable to a Integer / Number.
      This code I posted above does not move to the next value.
      But the code below does... why is that?
      For $count = 1 To _FileCountLines($FileRead2) Step 1 For $i = 2 To $count Next ;Code does stuff here Next  
      Why is the For loop resetting itself?
      Is it because the program does not cache the variable and needs to keep on acquiring this variable each time?
      If so , how would you make this variable static?

       
    • BogdanNicolescu
      By BogdanNicolescu
      While 1 / / / A whole bunch of codes found in help and here: https://www.autoitscript.com/autoit3/docs/ / / / WEnd OR:

       
      HotKeySet("{ESC}", "Terminate") While 1 MouseClick("Right",674,422) MouseClick("Left",673,447) Sleep(2000) / / / A whole bunch of codes found in help and here: https://www.autoitscript.com/autoit3/docs/ / / / MouseClick("Left",675,339) SLeep(3000) WEnd Func Terminate()     Exit 0 EndFunc  
      Sorry if i should't let this here to be found by newbies like me -.-'
    • MrCheese
      By MrCheese
      Hi guys,
       
      Wondering, is there a better way, likely to use 'for...next' to add a letter to each range, by moving right -> along a range of columns in excel.
      I currently use this, but its clunky.
      If $run = 1 Then $range = "B6:B41" If $run = 2 Then $range = "C6:C41" If $run = 3 Then $range = "D6:D41" If $run = 4 Then $range = "E6:E41" If $run = 5 Then $range = "F6:F41" If $run = 6 Then $range = "G6:G41" If $run = 7 Then $range = "H6:H41" If $run = 8 Then $range = "I6:I41" If $run = 9 Then $range = "J6:J41" If $run = 10 Then $range = "K6:K41" If $run = 11 Then $range = "L6:L41" If $run = 12 Then $range = "M6:M41" If $run = 13 Then $range = "N6:N41" If $run = 14 Then $range = "O6:O41" If $run = 15 Then $range = "P6:P41" If $run = 16 Then $range = "Q6:Q41" If $run = 17 Then $range = "R6:R41" If $run = 18 Then $range = "S6:S41" If $run = 19 Then $range = "T6:T41" If $run = 20 Then $range = "U6:U41" If $run = 21 Then $range = "V6:V41" If $run = 22 Then $range = "W6:W41" If $run = 23 Then $range = "X6:X41" If $run = 24 Then $range = "Y6:Y41" If $run = 25 Then $range = "Z6:Z41" If $run = 26 Then $range = "AA6:AA41" If $run = 27 Then $range = "AB6:AB41" If $run = 28 Then $range = "AC6:AC41" If $run = 29 Then $range = "AD6:AD41" If $run = 30 Then $range = "AE6:AE41" If $run = 31 Then $range = "AF6:AF41" If $run = 32 Then $range = "AG6:AG41" If $run = 33 Then $range = "AH6:AH41" If $run = 34 Then $range = "AI6:AI41" If $run = 35 Then $range = "AJ6:AJ41" If $run = 36 Then $range = "AK6:AK41" If $run = 37 Then $range = "AL6:AL41" If $run = 38 Then $range = "AM6:AM41" If $run = 39 Then $range = "AN6:AN41" If $run = 40 Then $range = "AO6:AO41" If $run = 41 Then $range = "AP6:AP41" If $run = 42 Then $range = "AQ6:AQ41" If $run = 43 Then $range = "AR6:AR41" If $run = 44 Then $range = "AS6:AS41" If $run = 45 Then $range = "AT6:AT41" If $run = 46 Then $range = "AU6:AU41" If $run = 47 Then $range = "AV6:AV41" If $run = 48 Then $range = "AW6:AW41" If $run = 49 Then $range = "AX6:AX41" If $run = 50 Then $range = "AY6:AY41"  
      Normally, if it was going down the rows, i'd use this:
       
      For $i = 0 To UBound($iRowCount) - 1 $row = $i + 1 $range = "B"&$row&":B"&$row+1 Next  
      so something like this, but i don't know how to code sequential columns:
      For $i = 0 To UBound($iColCount) - 1 $col = $i + 1 $range = $col&"1:"&$col&"40" Next  
      If I don't make sense, let me know.
      Any help would be great. thanks
    • KING_NK
      By KING_NK
      #RequireAdmin
      Global $x=0
      Global $y=0
      Func Start()
      While 1
      AutoItSetOption('MouseCoordMode',0)
      AutoItSetOption('SendKeyDelay',10)
      WinActivate('XXX')
      MouseClick('Primary',852,62,1,10)
      sleep(2200)
      MouseClick('Primary',880,196,1,10)
      Send('260',0)      -----------------------> $a as 260
      MouseClick('Primary',880,196,1,0)
      sleep(2200)
      MouseClick('Primary',1019,194,1,10)
      Sleep(2200)
      Send('98',0) ------------------------->$b as 98
      sleep(1000)
      Wend
      EndFunc
       
       
      I want to use Different number in every loop in the place of $a and  $b.
      Is it possble?If it possible Kindly help me
    • amphoric
      By amphoric
      Hi,
      I am struggling converting my 1D array to a 2D array and then showing that in my List View. Below is my current code, where I would like to take the array from the input box, and have that displayed as a list within the list view this is a list of computer names, and then update the 2nd column of each line once I have ran a ping and a registry change on each computer name, with either 'Completed' and 'Failed'
      I have checked out the AutoIt Arrays page here: https://www.autoitscript.com/wiki/Arrays , but unfortunately I cannot get my head around it. Any help would be greatly appreciated.
      I hope this makes sense.
      Thanks
       
      #include <Date.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <MsgBoxConstants.au3> #include <GUIListBox.au3> #include <GuiListView.au3> #Region ### $Form1 = GUICreate("Title", 515, 533, -1, -1) GUISetBkColor(0xFFFFFF) $Pic2 = GUICtrlCreatePic("Images\pic.jpg", 16, 16, 212, 28) $Label1 = GUICtrlCreateLabel("Label", 240, 16, 271, 33, $SS_CENTER) GUICtrlSetFont(-1, 17, 800, 0, "") $Combo1 = GUICtrlCreateCombo("", 256, 406, 241, 25, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_SIMPLE)) $Label2 = GUICtrlCreateLabel("Please select the location", 45, 401, 210, 20, $SS_CENTER) GUICtrlSetFont(-1, 10, 800, 0, "") $ChangeButton = GUICtrlCreateButton("Change", 286, 487, 75, 25) $RePromptButton = GUICtrlCreateButton("Re-prompt User", 366, 487, 139, 25) $Checkbox1 = GUICtrlCreateCheckbox("I have ensured that my selection is correct.", 10, 487, 273, 25) GUICtrlSetFont(-1, 10, 400, 0, "") $ManLocation = GUICtrlCreateLabel("Please enter the location:", 59, 448, 189, 20, $SS_RIGHT) GUICtrlSetFont(-1, 10, 800, 0, "") GUICtrlSetState(-1, $GUI_HIDE) $ManLocInput = GUICtrlCreateInput("", 256, 445, 241, 24) GUICtrlSetState(-1, $GUI_HIDE) $Label5 = GUICtrlCreateLabel("for this device:", 138, 418, 109, 20, $SS_CENTER) GUICtrlSetFont(-1, 10, 800, 0, "") $Label3 = GUICtrlCreateLabel("Asset Number:", 98, 72, 107, 20, $SS_CENTER) GUICtrlSetFont(-1, 10, 800, 0, "") $Input1 = GUICtrlCreateInput("", 215, 69, 241, 24) $AddMulti = GUICtrlCreateLabel("Add Multiple Assets", 356, 55, 98, 13, $SS_RIGHT) GUICtrlSetFont(-1, 8, 400, 6, "") GUICtrlSetColor(-1, 0x808080) GUICtrlSetCursor (-1, 0) $List1 = GUICtrlCreateListView("", 16, 104, 481, 278) $Add = GUICtrlCreateButton("Add", 461, 68, 35, 25) GUISetState(@SW_SHOW) #EndRegion ### ;### StartForm ### $FormaMultiple = GUICreate("Title", 277, 418, -1, -1) GUISetBkColor(0xFFFFFF) $Label1 = GUICtrlCreateLabel("Please add 1 asset number per line.", 8, 11, 253, 20, $SS_CENTER) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $OK = GUICtrlCreateButton("OK", 56, 375, 75, 25) $Edit1 = GUICtrlCreateEdit("", 20, 40, 233, 329) $Cancel = GUICtrlCreateButton("Cancel", 136, 375, 75, 25) GUISetState(@SW_HIDE) ;### EndForm ### ;### Add List View Columns START ### ;### Add List View Columns END ### ;### Read Locations START ### ;Read the LOCAL ini file SECTIONS Global $aSections = IniReadSectionNames("Locations.ini") ;If the above succeeded, convert the array to a string with each item separated by a | (pipe) and set the default selected item to $aSections[1] If(Not @Error) Then GUICtrlSetData($Combo1, _ArraytoString($aSections, "|", 1), $aSections[1]) ;### Read Locations END ### ;### Require Admin START ### ;#RequireAdmin ;### Require Admin END ### While 1 $nMsg = GUIGetMsg() ;### Data Validation START ### ;Set Checkbox = ENABLE/DISABLE if not GUICtrlRead($Combo1) = "" AND GUICtrlRead($Combo1) = "Not In List" then if not GUICtrlRead($ManLocInput) = "" Then If not ControlCommand($Form1, "", $Checkbox1, "IsEnabled") Then GUICtrlSetState($Checkbox1, $GUI_ENABLE) Else If ControlCommand($Form1, "", $Checkbox1, "IsEnabled") Then GUICtrlSetState($Checkbox1, $GUI_DISABLE) EndIf Else if GUICtrlRead($Combo1) = "" Then If ControlCommand($Form1, "", $Checkbox1, "IsEnabled") Then GUICtrlSetState($Checkbox1, $GUI_DISABLE) Else If not ControlCommand($Form1, "", $Checkbox1, "IsEnabled") Then GUICtrlSetState($Checkbox1, $GUI_ENABLE) EndIf EndIf ;Set Button = ENABLE/DISABLE If GUICtrlRead($Checkbox1) = 1 Then If Not ControlCommand($Form1, "", $ChangeButton, "IsEnabled") Then GUICtrlSetState($ChangeButton, $GUI_ENABLE) Else If ControlCommand($Form1, "", $ChangeButton, "IsEnabled") Then GUICtrlSetState($ChangeButton, $GUI_DISABLE) EndIf ;### Data Validation END ### Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $Add Case $AddMulti GUISetState(@SW_SHOW, $FormaMultiple) Case $Cancel GUISetState(@SW_HIDE, $FormaMultiple) Case $OK $sText = GUICtrlRead($Edit1) $aText = StringSplit($sText, @CRLF, 1) $bText = _ArrayToString($aText, ";", 1, -1) $cText = StringStripWS($bText, $STR_STRIPALL ) $dText = StringReplace($cText,";;",";") GUICtrlSetData($Input1, $dText) GUICtrlSetData($Edit1, "") GUISetState(@SW_HIDE, $FormaMultiple) For $i = 1 To $aText[0] Next Case $Combo1 ; If the combo is actioned Switch GUICtrlRead($Combo1) Case "Not In List" ; Show the manual input controls GUICtrlSetState($ManLocation, $GUI_SHOW) GUICtrlSetState($ManLocInput, $GUI_SHOW) if ControlCommand($Form1, "", $Checkbox1, "IsChecked") then ControlCommand($Form1, "", $Checkbox1, "Uncheck") GUICtrlSetData($ManLocInput, "") Case Else ; Hide them GUICtrlSetState($ManLocation, $GUI_HIDE) GUICtrlSetState($ManLocInput, $GUI_HIDE) if ControlCommand($Form1, "", $Checkbox1, "IsChecked") then ControlCommand($Form1, "", $Checkbox1, "Uncheck") GUICtrlSetData($ManLocInput, "") EndSwitch Case $ChangeButton ChangeReg() Case $RePromptButton RemoveReg() EndSwitch WEnd Func ChangeReg() $MultiAssets = StringSplit(GUICtrlRead($Input1), ";", 1) For $i = 1 To $MultiAssets[0] ; Ping with a timeout of 250ms. Local $iPing = Ping($MultiAssets[$i], 250) If $iPing Then ; If a value greater than 0 was returned then do the following: if not GUICtrlRead($ManLocInput) = "" Then RegWrite("\\" & $MultiAssets[$i] & "\HKLM\SOFTWARE\Location", "Location", "REG_SZ", "# - " & GUICtrlRead($ManLocInput)) RegWrite("\\" & $MultiAssets[$i] & "\HKLM64\SOFTWARE\Location", "Location", "REG_SZ", "# - " & GUICtrlRead($ManLocInput)) RegWrite("\\" & $MultiAssets[$i] & "\HKLM\SOFTWARE\Location", "LocationLog", "REG_SZ", @MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC) RegWrite("\\" & $MultiAssets[$i] & "\HKLM64\SOFTWARE\Location", "LocationLog", "REG_SZ", @MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC) MsgBox($MB_SYSTEMMODAL, "Completed", "Completed") Else If not GUICtrlRead($Input1) = "" Then RegWrite("\\" & $MultiAssets[$i] & "\HKLM\SOFTWARE\Location", "Location", "REG_SZ", GUICtrlRead($Combo1)) RegWrite("\\" & $MultiAssets[$i] & "\HKLM64\SOFTWARE\Location", "Location", "REG_SZ", GUICtrlRead($Combo1)) RegWrite("\\" & $MultiAssets[$i] & "\HKLM\SOFTWARE\Location", "LocationLog", "REG_SZ", @MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC) RegWrite("\\" & $MultiAssets[$i] & "\HKLM64\SOFTWARE\Location", "LocationLog", "REG_SZ", @MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC) MsgBox($MB_SYSTEMMODAL, "Completed", $MultiAssets[$i] & @CRLF & " Changed to: " & GUICtrlRead($Combo1)) Else MsgBox($MB_SYSTEMMODAL, "Error", "Please ensure all boxes are completed") EndIf EndIf Else MsgBox($MB_SYSTEMMODAL, "Error", "This asset may be OFFLINE, unable to complete") EndIf Next EndFunc ;==>PingReg Func RemoveReg() $MultiAssets = StringSplit(GUICtrlRead($Input1), ";", 1) For $i = 1 To $MultiAssets[0] ; Ping with a timeout of 250ms. Local $iPing = Ping($MultiAssets[$i], 250) If $iPing Then ; If a value greater than 0 was returned then do the following: if not GUICtrlRead($ManLocInput) = "" Then RegWrite("\\" & $MultiAssets[$i] & "\HKLM\SOFTWARE\Location", "Location", "REG_SZ", "") RegWrite("\\" & $MultiAssets[$i] & "\HKLM64\SOFTWARE\Location", "Location", "REG_SZ", "") RegWrite("\\" & $MultiAssets[$i] & "\HKLM\SOFTWARE\Location", "LocationLog", "REG_SZ", "") RegWrite("\\" & $MultiAssets[$i] & "\HKLM64\SOFTWARE\Location", "LocationLog", "REG_SZ", "") MsgBox($MB_SYSTEMMODAL, "Completed", "Completed") Else If not GUICtrlRead($Input1) = "" Then RegWrite("\\" & $MultiAssets[$i] & "\HKLM\SOFTWARE\Location", "Location", "REG_SZ", "") RegWrite("\\" & $MultiAssets[$i] & "\HKLM64\SOFTWARE\Location", "Location", "REG_SZ", "") RegWrite("\\" & $MultiAssets[$i] & "\HKLM\SOFTWARE\Location", "LocationLog", "REG_SZ", "") RegWrite("\\" & $MultiAssets[$i] & "\HKLM64\SOFTWARE\Location", "LocationLog", "REG_SZ", "") MsgBox($MB_SYSTEMMODAL, "Completed", $MultiAssets[$i] & @CRLF & "CLEARED") Else MsgBox($MB_SYSTEMMODAL, "Error", "Please ensure all boxes are completed") EndIf EndIf Else MsgBox($MB_SYSTEMMODAL, "Error", "This asset may be OFFLINE, unable to complete") EndIf Next EndFunc ;==>PingReg1  
×