|
9551
|
Informática / Software / Re: ¿Algún programa que apague mi ordenador?
|
en: 17 Marzo 2013, 19:04 pm
|
El problema de los scripts que le están aconsejando es que se corre el riesgo de que se pueda apagar el equipo mientras el renderizado todavía no haya finalizado... es lo que digo desde un principio, esa opción debe ir (casi al 90% seguro) en la aplicación que se usa para renderizar, no es necesario más. Pero de hacer un script, como ya te dije te recomendaría que hagas mediciones del consumo de RAM de la aplicación, es decir, cuando no renderizas, cuando el proceso está en IDLE consume la memória normal (yo no puedo saber cuanto es porque no tengo la aplicación), pero cuando renderizas, el proceso consume MUCHA más memória, así que te hago un pequeño script:  REM Si el proceso está consumiendo menos de 104857600 Bytes (100 MB), el PC se apagará... REM de lo contrario, seguirá monitorizando el consumo de memória del proceso. Set "APP_Name=explorer.exe" Set /A "Max_Memory=104857600" :Loop For /F "Tokens=*" %%# in ('wmic.exe process where "caption=" %APP_Name%"" get WorkingSetSize ^| FINDSTR " ^[0-9].*[0-9]"' ) Do (Set /A "Process_Memory= %%#" ) If %Process_Memory% LSS %Max_Memory% ( Echo [ %TIME:~0,-3%] Process " %APP_Name%" is consuming less than %Max_Memory% Bytes of memory... Echo [ %TIME:~0,-3%] Turning off the computer... Shutdown.exe /S /F Echo [ %TIME:~0,-3%] Process " %APP_Name%" memory consumition: %Process_Memory% Bytes... Ping -n %Interval% LocalHost >NUL)
Saludos!
|
|
|
9552
|
Programación / .NET (C#, VB.NET, ASP) / Re: [APORTE] Snippets !! (Posteen aquí sus snippets)
|
en: 17 Marzo 2013, 15:19 pm
|
· Función para modificar el color del borde de un control.  Nota: Afecta a todos los controles handleados, es decir, si cambiamos el color de "button1", y luego el color de "button2", el color de "button1" pasará a ser el color que usa "button2", no he conseguido mejorarlo más, pero bueno, lo suyo es colorear todos los bordes dle mismo color, ¿no?, así que creo que no tiene mucha importancia...#Region " Set Control Border Color Function "
' [ Set Control Border Color Function ] ' ' // By Elektro H@cker ' ' Examples : ' Set_Control_Border_Color(Button1, Pens.Crimson, Pens.Red, Pens.DarkRed) ' Set_Control_Border_Color(Checkbox1, Pens.Transparent, Pens.Transparent, Pens.Transparent)
Dim Border_Color_Light As Pen Dim Border_Color_Middle As Pen Dim Border_Color_Dark As Pen
Private Function Set_Control_Border_Color(ByVal Control As Control, Color_Light As Pen, ByVal Color_Middle As Pen, ByVal Color_Dark As Pen) As Boolean Try Border_Color_Light = Color_Light Border_Color_Middle = Color_Middle Border_Color_Dark = Color_Dark Handled_Controls.Add(Control) AddHandler Control.Paint, AddressOf Control_Paint Return True Catch ex As Exception : Throw New Exception(ex.Message) End Try End Function
Private Sub Control_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Dim offset As Integer = 0 e.Graphics.DrawRectangle(Border_Color_Light, New Rectangle(New Point(offset, offset), New Size(e.ClipRectangle.Width - ((offset * 2) + 1), e.ClipRectangle.Height - ((offset * 2) + 1)))) offset += 1 e.Graphics.DrawRectangle(Border_Color_Middle, New Rectangle(New Point(offset, offset), New Size(e.ClipRectangle.Width - ((offset * 2) + 1), e.ClipRectangle.Height - ((offset * 2) + 1)))) offset += 1 e.Graphics.DrawRectangle(Border_Color_Dark, New Rectangle(New Point(offset, offset), New Size(e.ClipRectangle.Width - ((offset * 2) + 1), e.ClipRectangle.Height - ((offset * 2) + 1)))) End Sub
#End RegionMejorado: #Region " Set Control Border Color Function " ' [ Set Control Border Color Function ] ' ' // By Elektro H@cker ' ' Examples : ' Set_Control_Border_Color(Button1, Pens.Crimson, Pens.Red, Pens.DarkRed) ' Set_Control_Border_Color(Checkbox1, Pens.Transparent, Pens.Transparent, Pens.Transparent) Dim Border_Color_Light As Pen Dim Border_Color_Middle As Pen Dim Border_Color_Dark As Pen Dim Last_Handled_control As Control Private Function Set_Control_Border_Color(ByVal Control As Control, Color_Light As Pen, ByVal Color_Middle As Pen, ByVal Color_Dark As Pen) As Boolean Try Border_Color_Light = Color_Light Border_Color_Middle = Color_Middle Border_Color_Dark = Color_Dark AddHandler Control.Paint, AddressOf Control_Paint Last_Handled_control = Control Return True Catch ex As Exception : Throw New Exception(ex.Message) End Try End Function Private Sub Control_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) If sender.name = Last_Handled_control.Name Then Dim offset As Integer = 0 e.Graphics.DrawRectangle(Border_Color_Light, New Rectangle(New Point(offset, offset), New Size(e.ClipRectangle.Width - ((offset * 2) + 1), e.ClipRectangle.Height - ((offset * 2) + 1)))) offset += 1 e.Graphics.DrawRectangle(Border_Color_Middle, New Rectangle(New Point(offset, offset), New Size(e.ClipRectangle.Width - ((offset * 2) + 1), e.ClipRectangle.Height - ((offset * 2) + 1)))) offset += 1 e.Graphics.DrawRectangle(Border_Color_Dark, New Rectangle(New Point(offset, offset), New Size(e.ClipRectangle.Width - ((offset * 2) + 1), e.ClipRectangle.Height - ((offset * 2) + 1)))) End If End Sub #End Region
|
|
|
9553
|
Programación / .NET (C#, VB.NET, ASP) / Re: [APORTE] Snippets !! (Posteen aquí sus snippets)
|
en: 17 Marzo 2013, 13:13 pm
|
Obtener la edición de Windows (Sólo para windows VISTA o superior) #Region " Get OS Edition Function " ' [ Get OS Edition Function ] ' ' Examples : ' Dim Edition As String = Get_OS_Edition() ' MsgBox("You are running Windows " & Get_OS_Edition() & " Edition") Private Const STARTER As Integer = &HB Private Const HOME_BASIC As Integer = &H2 Private Const HOME_BASIC_N As Integer = &H5 Private Const HOME_PREMIUM As Integer = &H3 Private Const HOME_PREMIUM_N As Integer = &H1A Private Const BUSINESS As Integer = &H6 Private Const BUSINESS_N As Integer = &H10 Private Const ENTERPRISE As Integer = &H4 Private Const ENTERPRISE_N As Integer = &H1B Private Const ULTIMATE As Integer = &H1 Private Const ULTIMATE_N As Integer = &H1C Private Declare Function GetProductInfo Lib "kernel32" (ByVal dwOSMajorVersion As Integer, ByVal dwOSMinorVersion As Integer, ByVal dwSpMajorVersion As Integer, ByVal dwSpMinorVersion As Integer, ByRef pdwReturnedProductType As Integer) As Integer Public Function Get_OS_Edition() As String Dim Edition_Type As Integer If GetProductInfo(Environment.OSVersion.Version.Major, Environment.OSVersion.Version.Minor, 0, 0, Edition_Type) Then Select Case Edition_Type Case STARTER : Return "Starter" Case HOME_BASIC : Return "Home Basic" Case HOME_BASIC_N : Return "Home Basic N" Case HOME_PREMIUM : Return "Home Premium" Case HOME_PREMIUM_N : Return "Home Premium N" Case BUSINESS : Return "Business" Case BUSINESS_N : Return "Business N" Case ENTERPRISE : Return "Enterprise" Case ENTERPRISE_N : Return "Enterprise N" Case ULTIMATE : Return "Ultimate" Case ULTIMATE_N : Return "Ultimate N" Case Else : Return "Unknown" End Select End If Return Nothing ' Windows is not VISTA or Higher End Function #End Region
|
|
|
9554
|
Programación / .NET (C#, VB.NET, ASP) / Re: [APORTE] Snippets !! (Posteen aquí sus snippets)
|
en: 17 Marzo 2013, 11:18 am
|
Checkar si un número está entre un rango de números. PD: Si conocen un método mejor porfavor postéenlo #Region " Number Is In Range Function " ' [ Number Is In Range Function ] ' ' // By Elektro H@cker ' ' Examples : ' MsgBox(NumberIsInRange(50, 0, 100)) ' If NumberIsInRange(5, 1, 10) then... Private Function NumberIsInRange(ByVal Number As Integer, ByVal MIN As Integer, ByVal MAX As Integer) As Boolean Select Case Number Case MIN To MAX : Return True Case Else : Return False End Select End Function #End Region
Modificar permisos de archivos: #Region " Set File Access Function " ' [ Set File Access Function ] ' ' // By Elektro H@cker ' ' Examples : ' Set_File_Access("C:\File.txt", File_Access.Read + File_Access.Write, Action.Allow) ' Set_File_Access("C:\File.txt", File_Access.Full, Action.Deny) Public Enum File_Access Delete = System.Security.AccessControl.FileSystemRights.Delete + Security.AccessControl.FileSystemRights.DeleteSubdirectoriesAndFiles Read = System.Security.AccessControl.FileSystemRights.ExecuteFile + System.Security.AccessControl.FileSystemRights.Read Write = System.Security.AccessControl.FileSystemRights.Write + Security.AccessControl.FileSystemRights.WriteAttributes + Security.AccessControl.FileSystemRights.WriteExtendedAttributes Full = Security.AccessControl.FileSystemRights.FullControl End Enum Public Enum Action Allow = 0 Deny = 1 End Enum Private Function Set_File_Access (ByVal File As String, ByVal File_Access As File_Access, ByVal Action As Action ) As Boolean Try Dim File_Info As IO. FileInfo = New IO. FileInfo(File) Dim File_ACL As New System.Security.AccessControl.FileSecurity File_ACL.AddAccessRule(New System.Security.AccessControl.FileSystemAccessRule(My.User.Name, File_Access, Action)) File_Info.SetAccessControl(File_ACL) Return True Catch ex As Exception Throw New Exception(ex.Message) ' Return False End Try End Function #End Region
|
|
|
9555
|
Programación / .NET (C#, VB.NET, ASP) / Re: [APORTE] Snippets !! (Posteen aquí sus snippets)
|
en: 17 Marzo 2013, 11:12 am
|
Funciones para controlar el volumen maestro del PC... Se necesita la API "Vista Core Audio API" : http://www.codeproject.com/Articles/18520/Vista-Core-Audio-API-Master-Volume-Control· Obtener el volumen maestro: #Region " Get Master Volume Function " ' [ Get Master Volume Function ] ' ' // By Elektro H@cker ' ' Examples : ' Dim Volume As Integer = Get_Master_Volume(Volume_Measure.As_Integer) ' Dim Volume As String = Get_Master_Volume(Volume_Measure.As_Percent) Public Enum Volume_Measure As_Integer As_Decimal As_Single As_Percent End Enum Private Function Get_Master_Volume(ByVal Volume_Measure As Volume_Measure) Select Case Volume_Measure Case Form1.Volume_Measure.As_Integer : Return CInt(Audio_Device.AudioEndpointVolume.MasterVolumeLevelScalar * 100) Case Form1.Volume_Measure.As_Decimal : Return (String.Format("{0:n2}", Audio_Device.AudioEndpointVolume.MasterVolumeLevelScalar)) Case Form1.Volume_Measure.As_Single : Return CSng(Audio_Device.AudioEndpointVolume.MasterVolumeLevelScalar) Case Form1.Volume_Measure.As_Percent : Return CInt(Audio_Device.AudioEndpointVolume.MasterVolumeLevelScalar * 100) & "%" Case Else : Return Nothing End Select End Function #End Region
· Setear el volumen maestro: #Region " Set Master Volume Function " ' [ Set Master Volume Function ] ' ' // By Elektro H@cker ' ' Examples : ' Set_Master_Volume(50) Private Function Set_Master_Volume(ByVal Value As Integer) As Boolean Try : Audio_Device.AudioEndpointVolume.MasterVolumeLevelScalar = (Value / 100) Return True Catch ex As Exception : Throw New Exception(ex.Message) End Try End Function #End Region
· Mutear el volumen maestro: #Region " Mute Master Volume Function " ' [ Mute Master Volume Function ] ' ' // By Elektro H@cker ' ' Examples : ' Mute_Master_Volume(False) ' Mute_Master_Volume(True) Private Function Set_Master_Volume(ByVal Mute As Boolean) As Boolean Try : Audio_Device.AudioEndpointVolume.Mute = Mute Return True Catch ex As Exception : Throw New Exception(ex.Message) End Try End Function #End Region
· Deslizar el volumen maestro (Desvanecer o aumentar): (Corregido) Instrucciones: Fade_Master_Volume(Desde el volumen, Hasta el volumen, En "X" Milisegundos, Forzar/NoForzar el devanecimiento) #Region " Fade Master Volume Function " ' [ Fade Master Volume Function ] ' ' // By Elektro H@cker ' ' Examples : ' Fade_Master_Volume(0, 100, 5000, Fading_Mode.FadeIN, True) ' Fade_Master_Volume(80, 20, 5000, Fading_Mode.FadeOUT, False) ' Fade_Master_Volume(10, 50, 5000, Fading_Mode.None, True) Dim Fade_Value_MIN As Integer Dim Fade_Value_MAX As Integer Dim Fade_TimeOut As Long Dim Fade_Mode As Fading_Mode Dim Force_Fading As Boolean Dim Fader_Timer As New Timer Public Enum Fading_Mode FadeIN = 0 FadeOUT = 1 None = 2 End Enum ' Fade Master Volume Function Private Function Fade_Master_Volume(ByVal MIN As Integer, ByVal MAX As Integer, ByVal Milliseconds As Long, ByVal Mode As Fading_Mode, ByVal Force As Boolean) As Boolean If MIN <= 100 And MIN >= 0 And MAX <= 100 And MAX >= 0 Then Try Fade_Value_MIN = MIN Fade_Value_MAX = MAX Fade_TimeOut = Milliseconds Fade_Mode = Mode Force_Fading = Force Fader_Timer = New Timer AddHandler Fader_Timer.Tick, AddressOf Fade_Master_Volume_Timer_Tick Select Case Mode Case Fading_Mode.FadeIN : Fader_Timer.Interval = Milliseconds / (MAX - MIN) Case Fading_Mode.FadeOUT : Fader_Timer.Interval = Milliseconds / (MIN - MAX) Case Fading_Mode.None : Fader_Timer.Interval = Milliseconds End Select Fader_Timer.Enabled = True Return True Catch ex As Exception : Throw New Exception(ex.Message) End Try Else Throw New Exception("Number is not in range from 0 to 100") End If End Function ' Fade Master Volume Timer Tick Event Private Sub Fade_Master_Volume_Timer_Tick(sender As Object, e As EventArgs) Dim Current_Vol As Integer = CInt(Audio_Device.AudioEndpointVolume.MasterVolumeLevelScalar * 100) Select Case Fade_Mode Case Fading_Mode.FadeOUT If Not Force_Fading Then If Not Current_Vol <= Fade_Value_MAX Then : Audio_Device.AudioEndpointVolume.MasterVolumeLevelScalar -= 0.01 ElseIf Current_Vol >= Fade_Value_MAX Then : Fader_Timer.Stop() : Fader_Timer.Enabled = False End If ElseIf Force_Fading Then If Not Fade_Value_MIN < Fade_Value_MAX Then Audio_Device.AudioEndpointVolume.MasterVolumeLevelScalar = (Fade_Value_MIN / 100) Fade_Value_MIN -= 1 Else : Fader_Timer.Stop() : Fader_Timer.Enabled = False End If End If Case Fading_Mode.FadeIN If Not Force_Fading Then If Not Current_Vol >= Fade_Value_MAX Then : Audio_Device.AudioEndpointVolume.MasterVolumeLevelScalar += 0.01 ElseIf Current_Vol <= Fade_Value_MAX Then : Fader_Timer.Stop() : Fader_Timer.Enabled = False End If ElseIf Force_Fading Then If Not Fade_Value_MIN > Fade_Value_MAX Then Audio_Device.AudioEndpointVolume.MasterVolumeLevelScalar = (Fade_Value_MIN / 100) Fade_Value_MIN += 1 Else : Fader_Timer.Stop() : Fader_Timer.Enabled = False End If End If Case Fading_Mode.None Audio_Device.AudioEndpointVolume.MasterVolumeLevelScalar = Fade_Value_MAX Fader_Timer.Stop() : Fader_Timer.Enabled = False End Select End Sub #End Region
|
|
|
9556
|
Informática / Software / Re: ¿Algún programa que apague mi ordenador?
|
en: 17 Marzo 2013, 07:25 am
|
Aplicaciones para la programación del apagado del PC hay a patadas, pero la opción de apagar el equipo cuando los trabajos/conversiones se han finalizado... esa opción debería ir incluida en tu conversor de vídeos, sincéramente, no he visto ningún conversor de videos que no tenga dicha opción, si el tuyo no la tiene deberías ir pensando en cambiar de software por alguno más útil.
Si piensas usar una aplicación de terceros (un programador del apagado del equipo), y vas a intentar asociar el apagado para que se apague el PC cuando tu conversor finalize las conversiones... eso no vas a poder hacerlo, ni tampoco vas a poder hacerlo creando una taréa programada de Windows, por eso te digo que lo mejor es que uses un buen software con multitud de opciones...
O cambiar de conversor, o realizar un script para medir el consumo de RAM del executable de tu conversor, y cuando la RAM del proceso séa menor de "X", usar el comando mencionado por Saberuneko para apagar el PC...
EDITO: O tamvien puedes habilitar el modo de hibernación en tu PC... así cuando finalicen las conversiones (y teniendo en cuenta que no hayan otras operaciones en segundo plano), a los pocos minutos el PC entrará en modo hibernación y no consumirá casi energía...
Deberías comentar que aplicación usas porque estoy seguro que si es un software decente debe tener dicha opción.
Un saludo.
|
|
|
9558
|
Programación / .NET (C#, VB.NET, ASP) / Re: Problema matemático (vigésimo quinta edición xD)
|
en: 16 Marzo 2013, 15:11 pm
|
Me salvaste $Edu$  La verdad es que yo ya estaba empezando a no entender ni mi própio problema ni lo que debía obtener xD, pero lo entendiste bien, era eso lo que necesitaba... Asi que cada 3333,33.... milisegundos, a 50 se le restara 1 hasta llegar a 20, por lo tanto este Timer se ejecutara 30 veces cada 3333,33... milisegundos. Lo que pasa es que dependiendo de si quiero disminuir o aumentar el valor, deberé intercambiar "X" por "Y" en la resta, aquí: Hacemos la diferencia de x e y = 50 - 20 = 30. ¿Estoy en lo cierto?, supongo que sí, porque he hecho las mediciones de lo que tarda el proceso, y parece que funciona corréctamente: If Fade_IN Then Timer.Interval = Convert_Time(Time_Out, Time_Measure, MS) / (CInt(Target_Volume * 100) - CInt(Audio_Device.AudioEndpointVolume.MasterVolumeLevelScalar * 100)) Else Timer.Interval = Convert_Time(Time_Out, Time_Measure, MS) / (CInt(Audio_Device.AudioEndpointVolume.MasterVolumeLevelScalar * 100) - CInt(Target_Volume * 100)) End If
Bueno, gracias de nuevo, un saludo!
|
|
|
9559
|
Programación / .NET (C#, VB.NET, ASP) / Re: Problema matemático (vigésimo quinta edición xD)
|
en: 15 Marzo 2013, 18:27 pm
|
¿Nada?, ¿Alguien me puede ayudar a resolver del todo esa operación? Es para poder terminar esta aplicación, la cual pienso compartir, y sólo me falta eso... Aquí podeis entender mejor los factores de la operación que necesito realizar:  Uso las variables que he comentado en los posts de arriba, y el problema es que siempre se pasa (o no llega) al tiempo escojido, porque calculo mal la operación... Agradecería mucho una ayuda más para esto. Saludos...
|
|
|
9560
|
Informática / Hardware / Re: Pregunta sobre el efecto de rendimiento de una tarjeta gráfica
|
en: 15 Marzo 2013, 15:36 pm
|
PD: Doy por hecho de que te han mandado tu nueva gráfica, la tienes puesta y ningun problema como el de los de los hilos anteriores.... Pues nada a disfrutarla, esperemos que no te tengamos que ver por aqui con mas problemas  Gracias. A mi tampoco me gusta dar por culo xD, preferiría no tener problemas con algo que cuesta tanta pasta... pero bueno, si me surgen problemas con la "nueva" tarjeta no voy a preguntar, porque ya lo probé todo y más no puedo hacer, diréctamente me compraría la ATI que me dijiste (ya buscaré la numeración correcta en los posts anteriores) Tu eres el experto así que si me cuentas eso del rendimiento de las gráficas...pues me lo creo, y quizás ese bajón de rendimiento séa de nuevo por la única razón de que la tarjeta es una maldita nVidia y nVidia da problemas, ya le estoy cojiendo mucho asco a las tarjetas nVidia. Un saludo y gracias Aprendiz-Oscuro, Borracho, Raul, e Imoen.
|
|
|
|
|
|
|