Jump to content

Hackworth82

Members
  • Posts

    6
  • Joined

  • Last visited

Hackworth82's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. wow. yeah, that was the problem. so why this behaviour ?
  2. I have another question for you, or anyone here I am trying to create a GUI and the first task is to create a combo and a text input. In the combo user selects the partition and in the input the folder name. So my plan is to concatenate the two string in order to create a path so that i can create a folder. This is my code so far: ; Create a GUI with various controls. Local $hGUI = GUICreate("Move stuff", 500, 500) ; Create OK button Local $idOK = GUICtrlCreateButton("OK", 400, 460, 85, 25) ; Create Cancel button Local $cancel = GUICtrlCreateButton("Cancel", 300, 460, 85, 25) ; The possible partitions we can create/copy to a folder Global $aArray[2] = ["C:\", "D:\"] ; Put the possible partitions into a list $sList = "" For $i = 0 To UBound($aArray) - 1 $sList &= "|" & $aArray[$i] Next ; Create a label for the combo Local $idlabelPartition = GUICtrlCreateLabel("Please select the partition you want to create the folder in:", 10, 20) ; Create the combo Local $hCombo = GUICtrlCreateCombo("", 10, 40, 200, 20) ; put the list elements into the combo GUICtrlSetData($hCombo, $sList) ; Create a label for the input field Local $idlabelFolder = GUICtrlCreateLabel("Please write the desired folder name:", 10, 70) ;create a text area where user can input the foldername Local $idText = GUICtrlCreateInput("", 10, 90, 300, 20) ; Create a button that when pressed will create the folder with the user inputed name and on the selected partition Local $createFolder = GUICtrlCreateButton("Create Folder", 10, 120, 100, 20) ; Define a variable that contains the path depending on the user selection Local $userPath = GUICtrlRead($hCombo) & GUICtrlRead($idText) ;<<< problem seems to be here. the GUICtrlRead($hCombo) and ;GUICtrlRead($idText) are strings but $userPath will not be the output of string concatenation ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOK, $cancel ExitLoop Case $createFolder MsgBox(0, "", "The path to create a folder is: " & $userPath) ;<<< this does not return the concatenation, it returns nothing EndSwitch WEnd So the problem is that $userParh returns nothing. So please help if you can. Thx Florin
  3. Hello. I am new to AUTOIT. I have question for you guys. I have 3 check-boxes that I need to get the values from and output them as an array. I am trying to add an element to the $arrayToBeUsedLater array every time the value of an element from the $aArrayOfCheckBoxes is equal to 1 This is the code (I know it is not done by coding standards,; the end part of the code can be ignored if it is not the problem): #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <array.au3> Local $hGUI = GUICreate("Please select your profile", 500, 500) Local $OK = GUICtrlCreateButton("OK", 400, 460, 85, 25) Local $cancel = GUICtrlCreateButton("Cancel", 300, 460, 85, 25) Local $idCheckbox = GUICtrlCreateCheckbox("checkbox 1", 10, 200, 185, 25) Local $idCheckbox1 = GUICtrlCreateCheckbox("checkbox 2", 10, 220, 185, 25) Local $idCheckbox4 = GUICtrlCreateCheckbox("checkbox 3", 10, 240, 185, 25) Local $aArrayOfCheckBoxes[3] = [$idCheckbox, $idCheckbox1, $idCheckbox4] Local $control1 ;will use for output Local $arrayToBeUsedLater = [] For $j = 0 To UBound($aArrayOfCheckBoxes) if GUICtrlRead($aArrayOfCheckBoxes[$j]) = 1 Then $control1 = GUICtrlRead($aArrayOfCheckBoxes[$j], 1) _ArrayAdd($arrayToBeUsedLater, $control1) Exit ; <-- there might be a problem here EndIf Next GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $OK, $cancel ExitLoop EndSwitch WEnd While 1 $msg = GUIGetMsg() Select Case $msg = $OK MsgBox(0, "", "You selected: " & $arrayToBeUsedLater) Exit Case $msg = $cancel MsgBox(0, "", "Your data was not saved ") Exit EndSelect WEnd The error that i get is this: ....Desktop\AutoIt\test1.au3" (21) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: if GUICtrlRead($aArrayOfCheckBoxes[$j]) = 1 Then if GUICtrlRead(^ ERROR >Exit code: 1 Time: 0.2369 I believe that the problem might be in the For loop. Can anyone help me ? Thanks , Florin
  4. Btw, the 'Next' from the end of the first code posted did not copy from some reason, but it's there.
  5. Hello. I just started learning AUTOIT. I am trying to loop thru an array and return something if an array element has a specific value. Here is my code: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <array.au3> Local $idRadio3Result3 = 45454 Local $idRadio3Result2 = 12 Local $idRadio3Result1 = 1 Local $aArrayOfRadioButtons[3] = [$idRadio3Result1, $idRadio3Result2, $idRadio3Result3] Local $control ;loop thru the array and find the element that has value of 1 For $i = 0 To UBound($aArrayOfRadioButtons) if $aArrayOfRadioButtons[$i] = 1 Then $control = $aArrayOfRadioButtons[i] ExitLoop EndIf When I run the script, this error appears in console: ...\Desktop\AutoIt\test1.au3" (14) : ==> Unknown function name.: $control = $aArrayOfRadioButtons[i] $control = $aArrayOfRadioButtons[^ ERROR >Exit code: 1 Time: 0.2284 The problem seems to be when I try to assign the value of the found element to the $control variable. I tested the code by replacing this line: $control = $aArrayOfRadioButtons[i] with a console log like this: ConsoleWrite("Test blabla") and it works. So it might be some syntax problem. Thanks for the help.
×
×
  • Create New...