tsue Posted December 10, 2010 Share Posted December 10, 2010 hello, im trying to make a links, automatically with an increasing number, but i have to set some options in some of the links example link1.html link2.html link3.html ..... link11.htmñ (normal number increasing) link01.html link02.html link03.html..... link11.html (number increasing with one zero) link001.html link002.html link003.html .... link011.html .... link111.html (number increasing with two zero) im having trouble with the third one here is my code expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=C:\Users\luis\Desktop\incremento.kxf $Form1 = GUICreate("Form1", 621, 500, 192, 124) $texruta = GUICtrlCreateInput("", 104, 24, 489, 21) $texlimite = GUICtrlCreateInput("", 104, 56, 33, 21) $check1 = GUICtrlCreateCheckbox("01", 152, 56, 33, 17) $check2 = GUICtrlCreateCheckbox("001", 192, 56, 33, 17) $check3 = GUICtrlCreateCheckbox("0001", 232, 56, 41, 17) $texrutafinal = GUICtrlCreateInput("", 104, 88, 185, 21) $iniciar = GUICtrlCreateButton("iniciar", 24, 128, 75, 25, $WS_GROUP) $Limpiar = GUICtrlCreateButton("Limpiar", 112, 128, 75, 25, $WS_GROUP) $Edit1 = GUICtrlCreateEdit("", 24, 168, 569, 297) $Limitefinal = GUICtrlCreateLabel("Incrementador", 24, 64, 72, 17) $Rutainicial = GUICtrlCreateLabel("Ruta Inicial", 24, 32, 57, 17) $Rutafinal = GUICtrlCreateLabel("Ruta Final", 24, 96, 52, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;HotKeySet("k","start") $j = "" $k = "" $l = "" ;notas lo k se ponga en folder drive y drivea va a cambiar a input1,2 y 3 respectivamente While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $check1 If BitAnd(GUICtrlRead($check1),$GUI_CHECKED) = $GUI_CHECKED then GUICtrlSetState ($check2, $GUI_UNCHECKED) GUICtrlSetState ($check3, $GUI_UNCHECKED) $j = 0 $k = "" $l = "" Else $j = "" $k = "" $l = "" EndIf Case $check2 If BitAnd(GUICtrlRead($check2),$GUI_CHECKED) = $GUI_CHECKED then GUICtrlSetState ($check1, $GUI_UNCHECKED) GUICtrlSetState ($check3, $GUI_UNCHECKED) $j = 0 $k = 0 $l = "" Else $j = "" $k = "" $l = "" EndIf Case $check3 If BitAnd(GUICtrlRead($check3),$GUI_CHECKED) = $GUI_CHECKED then GUICtrlSetState ($check2, $GUI_UNCHECKED) GUICtrlSetState ($check1, $GUI_UNCHECKED) $j = 0 $k = 0 $l = 0 Else $j = "" $k = "" $l = "" EndIf Case $iniciar ;$iniciar = GUICtrlCreateButton("press k in workspace", 296, 64, 75, 25, $WS_GROUP) ;Func start() For $i = 0 to GUICtrlRead($texlimite, 1) ;case BitAnd(GUICtrlRead($check1),$GUI_CHECKED) = $GUI_CHECKED then $i = 0 & $i ;If BitAnd(GUICtrlRead($check2),$GUI_CHECKED) = $GUI_CHECKED then $i = 0 & 0 & $i ;If BitAnd(GUICtrlRead($check3),$GUI_CHECKED) = $GUI_CHECKED then $i = 0 &0 & 0 & $i ;If $texlimite < 10 Then $i = $j & $i ;If $texlimite < 100 Then $i = $j & $k & $i If $texlimite < 10 Then $i = $j & $k & $l & $i ;If $i < 1000 Then $i = $j & $k & $l & $i $input = GUICtrlRead($texruta, 1) $input2 = $i ;$input2 = GUICtrlRead($i, 1) $input3 = GUICtrlRead($texrutafinal, 1) GUICtrlSetData($Edit1, $input & $input2 & $input3 & @CRLF, 1) ;send ($input & $input2 & $input3) Next ;EndFunc Case $Limpiar GUICtrlSetData($Edit1, "") EndSwitch WEnd Link to comment Share on other sites More sharing options...
KaFu Posted December 10, 2010 Share Posted December 10, 2010 Take a look at the StringFormat() function, switch according to your needs... For $i = 1 to 10 ConsoleWrite("link_" & $i & ".html" & @crlf) Next For $i = 1 to 10 ConsoleWrite("link_" & StringFormat("%02s", $i) & ".html" & @crlf) Next For $i = 1 to 10 ConsoleWrite("link_" & StringFormat("%03s", $i) & ".html" & @crlf) Next OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
tsue Posted December 10, 2010 Author Share Posted December 10, 2010 Take a look at the StringFormat() function, switch according to your needs... For $i = 1 to 10 ConsoleWrite("link_" & $i & ".html" & @crlf) Next For $i = 1 to 10 ConsoleWrite("link_" & StringFormat("%02s", $i) & ".html" & @crlf) Next For $i = 1 to 10 ConsoleWrite("link_" & StringFormat("%03s", $i) & ".html" & @crlf) Next wow thanks it worked, here is the code expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=C:\Users\luis\Desktop\incremento.kxf $Form1 = GUICreate("Incrementor", 621, 500, 192, 124) $texruta = GUICtrlCreateInput("", 104, 24, 489, 21) $texlimite = GUICtrlCreateInput("", 104, 56, 33, 21) $check1 = GUICtrlCreateCheckbox("01", 152, 56, 33, 17) $check2 = GUICtrlCreateCheckbox("001", 192, 56, 33, 17) $check3 = GUICtrlCreateCheckbox("0001", 232, 56, 41, 17) $texrutafinal = GUICtrlCreateInput("", 104, 88, 185, 21) $iniciar = GUICtrlCreateButton("iniciar", 24, 128, 75, 25, $WS_GROUP) $Limpiar = GUICtrlCreateButton("Limpiar", 112, 128, 75, 25, $WS_GROUP) $Edit1 = GUICtrlCreateEdit("", 24, 168, 569, 297) $Limitefinal = GUICtrlCreateLabel("Incrementador", 24, 64, 72, 17) $Rutainicial = GUICtrlCreateLabel("Ruta Inicial", 24, 32, 57, 17) $Rutafinal = GUICtrlCreateLabel("Ruta Final", 24, 96, 52, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $check1 If BitAnd(GUICtrlRead($check1),$GUI_CHECKED) = $GUI_CHECKED then GUICtrlSetState ($check2, $GUI_UNCHECKED) GUICtrlSetState ($check3, $GUI_UNCHECKED) EndIf Case $check2 If BitAnd(GUICtrlRead($check2),$GUI_CHECKED) = $GUI_CHECKED then GUICtrlSetState ($check1, $GUI_UNCHECKED) GUICtrlSetState ($check3, $GUI_UNCHECKED) EndIf Case $check3 If BitAnd(GUICtrlRead($check3),$GUI_CHECKED) = $GUI_CHECKED then GUICtrlSetState ($check2, $GUI_UNCHECKED) GUICtrlSetState ($check1, $GUI_UNCHECKED) EndIf Case $iniciar For $i = 0 to GUICtrlRead($texlimite, 1) If BitAnd(GUICtrlRead($check1),$GUI_CHECKED) = $GUI_CHECKED then $input2 = StringFormat("%02s", $i) If BitAnd(GUICtrlRead($check2),$GUI_CHECKED) = $GUI_CHECKED then $input2 = StringFormat("%03s", $i) If BitAnd(GUICtrlRead($check3),$GUI_CHECKED) = $GUI_CHECKED then $input2 = StringFormat("%04s", $i) If BitAnd(GUICtrlRead($check1),$GUI_UNCHECKED) = $GUI_UNCHECKED and BitAnd(GUICtrlRead($check2),$GUI_UNCHECKED) = $GUI_UNCHECKED and BitAnd(GUICtrlRead($check3),$GUI_UNCHECKED) = $GUI_UNCHECKED then $input2 = $i $input = GUICtrlRead($texruta, 1) ;$input2 = $i ;$input2 = GUICtrlRead($i, 1) $input3 = GUICtrlRead($texrutafinal, 1) GUICtrlSetData($Edit1, $input & $input2 & $input3 & @CRLF, 1) Next Case $Limpiar GUICtrlSetData($Edit1, "") EndSwitch WEnd one morething, do you know how can i use less code, specially in this part of the code, i think i make a lot of unnecesary coding. thanks For $i = 0 to GUICtrlRead($texlimite, 1) If BitAnd(GUICtrlRead($check1),$GUI_CHECKED) = $GUI_CHECKED then $input2 = StringFormat("%02s", $i) If BitAnd(GUICtrlRead($check2),$GUI_CHECKED) = $GUI_CHECKED then $input2 = StringFormat("%03s", $i) If BitAnd(GUICtrlRead($check3),$GUI_CHECKED) = $GUI_CHECKED then $input2 = StringFormat("%04s", $i) If BitAnd(GUICtrlRead($check1),$GUI_UNCHECKED) = $GUI_UNCHECKED and BitAnd(GUICtrlRead($check2),$GUI_UNCHECKED) = $GUI_UNCHECKED and BitAnd(GUICtrlRead($check3),$GUI_UNCHECKED) = $GUI_UNCHECKED then $input2 = $i $input = GUICtrlRead($texruta, 1) ;$input2 = $i ;$input2 = GUICtrlRead($i, 1) $input3 = GUICtrlRead($texrutafinal, 1) GUICtrlSetData($Edit1, $input & $input2 & $input3 & @CRLF, 1) Next Link to comment Share on other sites More sharing options...
whim Posted December 10, 2010 Share Posted December 10, 2010 Defining a 1-line mini function helps to clean it up (messed up your code indentation though, sorry) expandcollapse popup#include #include #include #include #include #Region ### START Koda GUI section ### Form=C:\Users\luis\Desktop\incremento.kxf $Form1 = GUICreate("Incrementor", 621, 500, 192, 124) $texruta = GUICtrlCreateInput("", 104, 24, 489, 21) $texlimite = GUICtrlCreateInput("", 104, 56, 33, 21) $check1 = GUICtrlCreateCheckbox("01", 152, 56, 33, 17) $check2 = GUICtrlCreateCheckbox("001", 192, 56, 33, 17) $check3 = GUICtrlCreateCheckbox("0001", 232, 56, 41, 17) $texrutafinal = GUICtrlCreateInput("", 104, 88, 185, 21) $iniciar = GUICtrlCreateButton("iniciar", 24, 128, 75, 25, $WS_GROUP) $Limpiar = GUICtrlCreateButton("Limpiar", 112, 128, 75, 25, $WS_GROUP) $Edit1 = GUICtrlCreateEdit("", 24, 168, 569, 297) $Limitefinal = GUICtrlCreateLabel("Incrementador", 24, 64, 72, 17) $Rutainicial = GUICtrlCreateLabel("Ruta Inicial", 24, 32, 57, 17) $Rutafinal = GUICtrlCreateLabel("Ruta Final", 24, 96, 52, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $check1 If IsChecked($check1) then GUICtrlSetState ($check2, $GUI_UNCHECKED) GUICtrlSetState ($check3, $GUI_UNCHECKED) EndIf Case $check2 If IsChecked($check2) then GUICtrlSetState ($check1, $GUI_UNCHECKED) GUICtrlSetState ($check3, $GUI_UNCHECKED) EndIf Case $check3 If IsChecked($check3) then GUICtrlSetState ($check2, $GUI_UNCHECKED) GUICtrlSetState ($check1, $GUI_UNCHECKED) EndIf Case $iniciar For $i = 0 to GUICtrlRead($texlimite, 1) If IsChecked($check1) then $input2 = StringFormat("%02s", $i) If IsChecked($check2) then $input2 = StringFormat("%03s", $i) If IsChecked($check3) then $input2 = StringFormat("%04s", $i) If IsChecked($check1) and IsChecked($check2) and IsChecked($check3) then $input2 = $i $input = GUICtrlRead($texruta, 1) ;$input2 = $i ;$input2 = GUICtrlRead($i, 1) $input3 = GUICtrlRead($texrutafinal, 1) GUICtrlSetData($Edit1, $input & $input2 & $input3 & @CRLF, 1) Next Case $Limpiar GUICtrlSetData($Edit1, "") EndSwitch WEnd Func IsChecked($control) Return BitAND(GUICtrlRead($control), $GUI_CHECKED) EndFunc ;==>IsChecked Link to comment Share on other sites More sharing options...
tsue Posted December 10, 2010 Author Share Posted December 10, 2010 Defining a 1-line mini function helps to clean it up (messed up your code indentation though, sorry) expandcollapse popup#include #include #include #include #include #Region ### START Koda GUI section ### Form=C:\Users\luis\Desktop\incremento.kxf $Form1 = GUICreate("Incrementor", 621, 500, 192, 124) $texruta = GUICtrlCreateInput("", 104, 24, 489, 21) $texlimite = GUICtrlCreateInput("", 104, 56, 33, 21) $check1 = GUICtrlCreateCheckbox("01", 152, 56, 33, 17) $check2 = GUICtrlCreateCheckbox("001", 192, 56, 33, 17) $check3 = GUICtrlCreateCheckbox("0001", 232, 56, 41, 17) $texrutafinal = GUICtrlCreateInput("", 104, 88, 185, 21) $iniciar = GUICtrlCreateButton("iniciar", 24, 128, 75, 25, $WS_GROUP) $Limpiar = GUICtrlCreateButton("Limpiar", 112, 128, 75, 25, $WS_GROUP) $Edit1 = GUICtrlCreateEdit("", 24, 168, 569, 297) $Limitefinal = GUICtrlCreateLabel("Incrementador", 24, 64, 72, 17) $Rutainicial = GUICtrlCreateLabel("Ruta Inicial", 24, 32, 57, 17) $Rutafinal = GUICtrlCreateLabel("Ruta Final", 24, 96, 52, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $check1 If IsChecked($check1) then GUICtrlSetState ($check2, $GUI_UNCHECKED) GUICtrlSetState ($check3, $GUI_UNCHECKED) EndIf Case $check2 If IsChecked($check2) then GUICtrlSetState ($check1, $GUI_UNCHECKED) GUICtrlSetState ($check3, $GUI_UNCHECKED) EndIf Case $check3 If IsChecked($check3) then GUICtrlSetState ($check2, $GUI_UNCHECKED) GUICtrlSetState ($check1, $GUI_UNCHECKED) EndIf Case $iniciar For $i = 0 to GUICtrlRead($texlimite, 1) If IsChecked($check1) then $input2 = StringFormat("%02s", $i) If IsChecked($check2) then $input2 = StringFormat("%03s", $i) If IsChecked($check3) then $input2 = StringFormat("%04s", $i) If IsChecked($check1) and IsChecked($check2) and IsChecked($check3) then $input2 = $i $input = GUICtrlRead($texruta, 1) ;$input2 = $i ;$input2 = GUICtrlRead($i, 1) $input3 = GUICtrlRead($texrutafinal, 1) GUICtrlSetData($Edit1, $input & $input2 & $input3 & @CRLF, 1) Next Case $Limpiar GUICtrlSetData($Edit1, "") EndSwitch WEnd Func IsChecked($control) Return BitAND(GUICtrlRead($control), $GUI_CHECKED) EndFunc ;==>IsChecked thanks Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now