Necesito ayuda con mi codigo Topic is solved

Esta sección es para preguntas sobre programación/scripting usando AutoHotkey.

Moderator: Flipeador

imloza

Necesito ayuda con mi codigo

28 Dec 2022, 07:24

Tengo el siguiente código, pero necesito que al darle al botón reiniciar, el código se pare y todos los valores que había añadido se borren y pueda iniciar de nuevo la secuencia sin llegar a tener que cerrar y volver a abrir el script



Code: Select all

Gui, Add, Text, x10 y13, Mes:
Gui, Add, DropDownList, x42 y10 w83 vMes, Enero|Febrero|Marzo|Abril|Mayo|Junio|Julio|Agosto|Septiembre|Octubre||Noviembre|Diciembre
Gui, Add, DropDownList, x148 y10 w83 vAnyo, 2022||2023
Gui, Add, Button, default x155 y43 w60 h50, Lectura
Gui, Add, Button, x220 y43 w60 h50, Reset
Gui, Add, Text, x10 y46, Repeticiones:
Gui, Add, Edit, x85 y43 w40 Number vRepeticiones, 40
Gui, Add, Text, x24 y76, Segundos:
Gui, Add, Edit, x85 y73 w40 Number vSegundos, 155
Gui, Add, Text, x130 y76 w25 cRed vCounter
Gui, Add, Text, x130 y46 w25 cRed vIteracion
Gui, Add, Edit, center ReadOnly x10 y106 w230 cRed vPlanta
Gui, Show, w300 h135, Lectura curvas 
return


GuiClose:
	ExitApp

ButtonSiguiente:
	Gui, Submit, NoHide
	Next = 1

ButtonLectura:
	Gui, Submit, NoHide
	Reps = %Repeticiones%
Loop, %Repeticiones%{
	GuiControl,, Iteracion, %Reps%
	Reps -= 1
	Sleep, 2000
	Send, {F10}
	Sleep, 60
	Send, {Right}
	Sleep, 60
	Send, {Right}
	Sleep, 60
	Send, {Right}
	Sleep, 60
	Send, {Down}
	Sleep, 60
	Send, {Down}
	Sleep, 60
	Send, {Enter}
	Sleep, 60
	Loop, 5{
	    Send, {TAB}
	    Sleep, 60
	}
	Send, {Space}
	Sleep, 60
	Send, {TAB}
	Sleep, 60

	if(Mes = "Enero"){
		month = 01
		nextMonth = 02
	} else if(Mes = "Febrero"){
		month = 02
		nextMonth = 03
	} else if(Mes = "Marzo"){
		month = 03
		nextMonth = 04
	} else if(Mes = "Abril"){
		month = 04
		nextMonth = 05
	} else if(Mes = "Mayo"){
		month = 05
		nextMonth = 06
	} else if(Mes = "Junio"){
		month = 06
		nextMonth = 07
	} else if(Mes = "Julio"){
		month = 07
		nextMonth = 08
	} else if(Mes = "Agosto"){
		month = 08
		nextMonth = 09
	} else if(Mes = "Septiembre"){
		month = 09
		nextMonth = 10
	} else if(Mes = "Octubre"){
		month = 10
		nextMonth = 11
	} else if(Mes = "Noviembre"){
		month = 11
		nextMonth = 12
	} else if(Mes = "Diciembre"){
		month = 12
		nextMonth = 01
	}
	Send, 01/
	Sleep, 60
	Send, %month%
	Sleep, 60
	Send, /%anyo%
	Sleep, 60
	Send {TAB}
	Sleep, 60
	Send, 01/
	Sleep, 60
	Send, %nextMonth%
	Sleep, 60
	if(Mes = "Diciembre"){
		Send, 2022
	} else{
		Send, /%anyo%
	}
	Loop, 4{
	    Send, {TAB}
	    Sleep, 60
	}
	Send {Enter}
	Sleep, 500
	Send {TAB}
	Sleep, 60
	Send {TAB}
	myVariable := CopyToVar()
	CopyToVar(Wait=1) {
		Save := ClipboardAll, Clipboard := ""
		SendInput, {ctrl down}c{ctrl up}
		ClipWait % Wait
		Clip := Clipboard, Clipboard := Save
		Return Clip
	}
	splitArray := StrSplit(myVariable, "\")
	nombreArchivo := splitArray[7]
	GuiControl,, Planta, %nombreArchivo%
	ruta = C:\Curvas\%anyo%\%month%\
	Send %ruta%
	Sleep, 60
	Send, {TAB}
	Sleep, 60
	Send, %nombreArchivo%
	Send, {TAB}
	Send, {TAB}
	Send, {Enter}
	Next = 0
	Contador = %Segundos%
	Loop, %Contador%{
		if(Contador = 0) break
		if(Next = 1) break
		continue
		Contador -= 1
		GuiControl,, Counter, %contador%
		Sleep, 1000
	}
	Sleep, 2000
	Send, {Enter}
	Sleep, 60
	Send, {Down}
}
[Mod edit: [code][/code] tags added.]
garry
Posts: 3788
Joined: 22 Dec 2013, 12:50

Re: Necesito ayuda con mi codigo  Topic is solved

28 Dec 2022, 13:50

Ejemplo eliminar solo variables GUI / button RELOAD

Code: Select all

#singleinstance,force
Gui,1:default
time:=a_now
;time:=a_nowutc
;time:=20221120140022
;FormatTime,Spain           , %time% L1034  , dddd   MMM   MMMM yyyy-MM-dd  HH:mm  ;- Spain > miércoles   dic    diciembre 2022-12-07  21:49
FormatTime,Mesx           , %time% L1034  , MMMM
Gui, Add, Text, x10 y13, Mes:
Gui, Add, DropDownList, x42 y10 w83 vMes, Enero|Febrero|Marzo|Abril|Mayo|Junio|Julio|Agosto|Septiembre|Octubre|Noviembre|Diciembre
Gui, Add, DropDownList, x148 y10 w83 vAnyo, 2022|2023|2024|2025
Gui, Add, Button, default x155 y43 w60 h50 gLectura, Lectura
Gui, Add, Button, x220 y43 w60 h50 gReset, Reset
Gui, Add, Button, x220 y140 w60 h25 gRELOAD, RELOAD
Gui, Add, Text, x10 y46, Repeticiones:
Gui, Add, Edit, x85 y43 w40 Number vRepeticiones, 40
Gui, Add, Text, x24 y76, Segundos:
Gui, Add, Edit, x85 y73 w40 Number vSegundos, 155
Gui, Add, Text, x130 y76 w25 cRed vCounter
Gui, Add, Text, x130 y46 w25 cRed vIteracion
Gui, Add, Edit, center ReadOnly x10 y106 w230 cRed vPlanta
Guicontrol,1:Choosestring,mes,%mesx%        ;- seleccione el mes real
yr:=a_year
Guicontrol,1:Choosestring,anyo,%yr%   ;- seleccione el año real
Gui, Show, w300 h185, Lectura curvas 
return
;------
GuiClose:
ExitApp
;------
Reload:
reload
return
;------
Lectura:
Gui, Submit, NoHide
Reps = %Repeticiones%
I:=0
Loop, %Repeticiones%
    {
	i++
	GuiControl,1:, Iteracion, %i%
	sleep,200
	}
return
;------
Reset:
Gui,1: Submit,nohide
FormatTime,Mesx           , %time% L1034  , MMMM
Guicontrol,1:Choosestring,mes,%mesx%
yr:=a_year
Guicontrol,1:Choosestring,anyo,%yr%
;- clear variables
Guicontrol,1:,Repeticiones
Guicontrol,1:,Segundos
Guicontrol,1:,Counter
Guicontrol,1:,Iteracion
return
;==========================
imloza
Posts: 2
Joined: 28 Dec 2022, 07:28

Re: Necesito ayuda con mi codigo

03 Jan 2023, 08:33

@garry
Muchas gracias, la funcion no es exactamente esa pero me has dado una idea de como hacerlo mas o menos, probare a ver si puedo solucionarlo por completo. Pero gracias igualmente
gmoises
Posts: 74
Joined: 18 Nov 2017, 16:43

Re: Necesito ayuda con mi codigo

04 Jan 2023, 20:37

modifica esta línea así

Code: Select all

Gui, Add, Button, x220 y43 w60 h50 gReset, Reset
añade esta rutina

Code: Select all

Reset:
	; borra las variables que debas
	Counter := Iteracion := 0
	
	; ajusta los controles de la forma con los valores iniciales
	GuiControl, Choose, Mes, 10
	GuiControl, Choose, Anyo, 1
	GuiControl, Text, Repeticiones, 40
	GuiControl, Text, Segundos, 155
Return
Cuando oprimas Reset, los valores iniciales regresarán

Return to “Pedir Ayuda”

Who is online

Users browsing this forum: No registered users and 6 guests