HardPlay Soldado
Mensagens : 16 Idade : 32 Data de inscrição : 16/05/2011 Localização : Campinas-SP
Personagem Level: 200/200 Nome: N Posto :) Jogo: WYD
| Assunto: Autoupdate bom para jogos :) (autoit) Seg 16 maio 2011 - 15:16 | |
| Aew Galera Vou Passar Aki Um Sistema Bem Simples De AutoUpdate Como Que Ele Funciona? Simples, Ele Vai Ler A Verção Do Arquivo No Servidor, E Vai Ver Se Esta Igual A Do Client, Se Naum Estiver Ele Faz O Download Do Arquivo Escolhido. Arquivos Necessarios: Unrar.dll: [Tens de ter uma conta e sessão iniciada para poderes visualizar este link]Unrar.au3: [Tens de ter uma conta e sessão iniciada para poderes visualizar este link]1º Crie Uma GUI Com 1 Label, 2 Botoes. 2º Crie Outra GUI Com 1 Label, 1 Botão. 3º Crie Outra GUI Com 2 Progress Bar, 2 Label. 4º Agora Abra O Scite 5º Agora Vamos Declarar Os Includes, E Tirar O Icone Do AutoIt Da Barra De Tarefas, Faça Assim Va Até O Topo E Digite: - Código:
-
; Inicio Dos Includes E # #NoTrayIcon #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ProgressConstants.au3> ; Fim Dos Includes E # 6º Agora Vamos Declarar Algumas Variaveis: - Código:
-
; Variaveis $Vercao_Servidor = InetRead("http://127.0.0.1/Verção.txt") $Vercao_Client = FileRead("Verção.txt", 1) $Link_Download = "http://127.0.0.1/AutoIt.rar" ; Fim Das Variaveis 7º Agora Vamos Verificar Se Tem Alguma Atualização, Crie Um Arquivo Chamado Verção.txt E Escreva 0.0 Nele, Depois Cole Na Pasta Do Servidor (ex: EasyPhp), Depois Cole Esse Arquivo Na Pasta Do Client Tbem. Agora Debaixo Dos Includes Coloque: - Código:
-
; Verificando Atualizações If $Vercao_Servidor = $Vercao_Client Then Form2() Else Form1() EndIf ; Fim Da Verificação 8º Agora Vamos Criar O Form 1. Crie Um Func, E De O Nome De Form1 Assim: - Código:
-
Form1() Agora Dentro Dela Coloque O Codigo Gerado Pelo Koda, Mais Retire Os Includes, Depois De Um EndFunc, Ficando Assim +/-: - Código:
-
; Inicio Do Form 1 Func Form1() $Form1 = GUICreate("Atualizador", 226, 99, -1, -1, -1, $WS_EX_TOOLWINDOW) $Group1 = GUICtrlCreateGroup("Atualizações", 8, 8, 209, 81, BitOR($BS_CENTER,$BS_FLAT)) $Label1 = GUICtrlCreateLabel("Á Novas Atualizações Deseja Atualizar?", 16, 32, 193, 17) $Button1 = GUICtrlCreateButton("Sim", 16, 56, 75, 25, $WS_GROUP) $Button2 = GUICtrlCreateButton("Não", 136, 56, 75, 25, $WS_GROUP) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW)
While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit
EndSwitch WEnd EndFunc ; Fim Do Form 1 9º Adicionando O Codigo Nos Notoes Do Form1, Primeiro Crie A Case Do Button1 E Do Button2, Dai No Button Adicione, Form3(), E No Button2 Adicione, Exit, Ficando +/- Assim: - Código:
-
Func Form1() $Form1 = GUICreate("Atualizador", 226, 99, -1, -1, -1, $WS_EX_TOOLWINDOW) $Group1 = GUICtrlCreateGroup("Atualizações", 8, 8, 209, 81, BitOR($BS_CENTER,$BS_FLAT)) $Label1 = GUICtrlCreateLabel("Á Novas Atualizações Deseja Atualizar?", 16, 32, 193, 17) $Button1 = GUICtrlCreateButton("Sim", 16, 56, 75, 25, $WS_GROUP) $Button2 = GUICtrlCreateButton("Não", 136, 56, 75, 25, $WS_GROUP) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW)
While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Form3() Case $Button2 Exit
EndSwitch WEnd EndFunc 10º Agora Vamos Criar O Form 2 , Para Criar O Form 2 É Só Fazer Igual O Form 1 Só Q Com A GUI Do Form 2, Ficando +/- Assim: - Código:
-
; Inicio Do Form 2 Func Form2() $Form2 = GUICreate("Atualizador", 162, 99, -1, -1, -1, $WS_EX_TOOLWINDOW) $Group1 = GUICtrlCreateGroup("Atualizações", 8, 8, 145, 81, BitOR($BS_CENTER,$BS_FLAT)) $Label1 = GUICtrlCreateLabel("Não Á Novas Atualizações", 16, 32, 131, 17) $Button1 = GUICtrlCreateButton("Fechar Atualizador", 16, 56, 129, 25, $WS_GROUP) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW)
While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit
EndSwitch WEnd EndFunc ; Fim Do Form 2 11º Adicionando O Codigo Do Form 2, Na Case Do Buton1 Coloque Exit, Ficando +/- Assim: - Código:
-
; Inicio Do Form 2 Func Form2() $Form2 = GUICreate("Atualizador", 162, 99, -1, -1, -1, $WS_EX_TOOLWINDOW) $Group1 = GUICtrlCreateGroup("Atualizações", 8, 8, 145, 81, BitOR($BS_CENTER,$BS_FLAT)) $Label1 = GUICtrlCreateLabel("Não Á Novas Atualizações", 16, 32, 131, 17) $Button1 = GUICtrlCreateButton("Fechar Atualizador", 16, 56, 129, 25, $WS_GROUP) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW)
While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Exit
EndSwitch WEnd EndFunc ; Fim Do Form 2 12º Agora Vamos Criar O Form3, Fassa Igual Os Outro Forms, Ficando +/- Assim: - Código:
-
; Form 3 Func Form3() $Form3 = GUICreate("Atualizador", 315, 212, -1, -1, -1, $WS_EX_TOOLWINDOW) $Group1 = GUICtrlCreateGroup("Progressos", 8, 8, 297, 193, BitOR($BS_CENTER,$BS_FLAT)) $Group2 = GUICtrlCreateGroup("Download", 16, 24, 281, 81, $BS_FLAT) $Progress1 = GUICtrlCreateProgress(24, 48, 265, 17) $Label1 = GUICtrlCreateLabel("Porcentagem De Download: 0%", 24, 76, 265, 17, BitOR($SS_CENTER,$WS_BORDER)) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group3 = GUICtrlCreateGroup("Descompactação", 16, 112, 281, 81, $BS_FLAT) $Progress2 = GUICtrlCreateProgress(24, 136, 265, 17) $Label2 = GUICtrlCreateLabel("Porcentagem De Descompactação", 24, 164, 265, 17, BitOR($SS_CENTER,$WS_BORDER)) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW)
EndFunc ; Fim Do Form 3 13º Agora Vamos Fazer O For Por Causa Do ProgressBar, E Tbem Fazer O Download Do Arquivo.ra, Coloque O Codigo Do Form3, Ficando +/- Assim: - Código:
-
; Form 3 Func Form3() $Form3 = GUICreate("Atualizador", 315, 212, -1, -1, -1, $WS_EX_TOOLWINDOW) $Group1 = GUICtrlCreateGroup("Progressos", 8, 8, 297, 193, BitOR($BS_CENTER,$BS_FLAT)) $Group2 = GUICtrlCreateGroup("Download", 16, 24, 281, 81, $BS_FLAT) $Progress1 = GUICtrlCreateProgress(24, 48, 265, 17) $Label1 = GUICtrlCreateLabel("Porcentagem De Download: 0%", 24, 76, 265, 17, BitOR($SS_CENTER,$WS_BORDER)) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group3 = GUICtrlCreateGroup("Descompactação", 16, 112, 281, 81, $BS_FLAT) $Progress2 = GUICtrlCreateProgress(24, 136, 265, 17) $Label2 = GUICtrlCreateLabel("Porcentagem De Descompactação", 24, 164, 265, 17, BitOR($SS_CENTER,$WS_BORDER)) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW)
For $Download = 1 To 100 Step 10 GUICtrlSetData($Progress1, $Download) GUICtrlSetData($Label1, "Porcentagem De Download: " & $Download & "%") InetGet($Link_Download, "Download.rar", 1) Next GUICtrlSetData($Label1, "Download Concluido Com Sucesso")
EndFunc ; Fim Do Form 3 14º Agora Vamos Fazer Ele Descompactar O Arquivo.rar, Cole O unrar.dll Na Pasta Do Programa, Depois Coloque O Codigo Do Form3, Ficando +/- Assim: - Código:
-
; Form 3 Func Form3() $Form3 = GUICreate("Atualizador", 315, 212, -1, -1, -1, $WS_EX_TOOLWINDOW) $Group1 = GUICtrlCreateGroup("Progressos", 8, 8, 297, 193, BitOR($BS_CENTER,$BS_FLAT)) $Group2 = GUICtrlCreateGroup("Download", 16, 24, 281, 81, $BS_FLAT) $Progress1 = GUICtrlCreateProgress(24, 48, 265, 17) $Label1 = GUICtrlCreateLabel("Porcentagem De Download: 0%", 24, 76, 265, 17, BitOR($SS_CENTER,$WS_BORDER)) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group3 = GUICtrlCreateGroup("Descompactação", 16, 112, 281, 81, $BS_FLAT) $Progress2 = GUICtrlCreateProgress(24, 136, 265, 17) $Label2 = GUICtrlCreateLabel("Porcentagem De Descompactação", 24, 164, 265, 17, BitOR($SS_CENTER,$WS_BORDER)) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW)
For $Download = 1 To 100 Step 10 GUICtrlSetData($Progress1, $Download) GUICtrlSetData($Label1, "Porcentagem De Download: " & $Download & "%") InetGet($Link_Download, "Download.rar", 1) Next GUICtrlSetData($Label1, "Download Concluido Com Sucesso")
For $Descompactacao = 1 To 100 Step 1 GUICtrlSetData($Progress2, $Descompactacao) GUICtrlSetData($Label2, "Porcentagem De Descompactação: " & $Descompactacao & "%")
$hUnRAR_CallBack = DllCallbackRegister("_UnRARProc", "int", "uint;int;int;int")
$comment = _Rar_GetComment("Atualização.rar") ConsoleWrite("!> Archive comment: " & $comment & @LF) $hArchive = _RAR_OpenArchive("Atualização.rar")
_Rar_TestArchive($hArchive) _RAR_CloseArchive($hArchive) $hArchive = _RAR_OpenArchive("Atualização.rar")
_RAR_SetCallback($hArchive, $hUnRAR_CallBack) _Rar_UnpackArchive($hArchive, "")
DllCallbackFree($hUnRAR_CallBack) Next GUICtrlSetData($Label2, "Descompactado Com Sucesso") MsgBox("","","Parabens Atualizado Com Sucesso") Exit
EndFunc ; Fim Do Form 3 Código Completo Fica Assim: - Código:
-
; Inicio Dos Includes E # #NoTrayIcon #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ProgressConstants.au3> #include <unrar.au3> ; Fim Dos Includes E #
; Variaveis $Vercao_Servidor = InetRead("http://127.0.0.1/Verção.txt") $Vercao_Client = FileReadLine("Verção.txt", 1) $Link_Download = "http://127.0.0.1/AutoIt.rar" ; Fim Das Variaveis
; Verificando Atualizações If $Vercao_Servidor = $Vercao_Client Then Form2() Else Form1() EndIf ; Fim Da Verificação
; Inicio Do Form 1 Func Form1() $Form1 = GUICreate("Atualizador", 226, 99, -1, -1, -1, $WS_EX_TOOLWINDOW) $Group1 = GUICtrlCreateGroup("Atualizações", 8, 8, 209, 81, BitOR($BS_CENTER,$BS_FLAT)) $Label1 = GUICtrlCreateLabel("Á Novas Atualizações Deseja Atualizar?", 16, 32, 193, 17) $Button1 = GUICtrlCreateButton("Sim", 16, 56, 75, 25, $WS_GROUP) $Button2 = GUICtrlCreateButton("Não", 136, 56, 75, 25, $WS_GROUP) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW)
While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Form3() Case $Button2 Exit
EndSwitch WEnd EndFunc ; Fim Do Form 1
; Inicio Do Form 2 Func Form2() $Form2 = GUICreate("Atualizador", 162, 99, -1, -1, -1, $WS_EX_TOOLWINDOW) $Group1 = GUICtrlCreateGroup("Atualizações", 8, 8, 145, 81, BitOR($BS_CENTER,$BS_FLAT)) $Label1 = GUICtrlCreateLabel("Não Á Novas Atualizações", 16, 32, 131, 17) $Button1 = GUICtrlCreateButton("Fechar Atualizador", 16, 56, 129, 25, $WS_GROUP) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW)
While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Exit
EndSwitch WEnd EndFunc ; Fim Do Form 2
; Form 3 Func Form3() $Form3 = GUICreate("Atualizador", 315, 212, -1, -1, -1, $WS_EX_TOOLWINDOW) $Group1 = GUICtrlCreateGroup("Progressos", 8, 8, 297, 193, BitOR($BS_CENTER,$BS_FLAT)) $Group2 = GUICtrlCreateGroup("Download", 16, 24, 281, 81, $BS_FLAT) $Progress1 = GUICtrlCreateProgress(24, 48, 265, 17) $Label1 = GUICtrlCreateLabel("Porcentagem De Download: 0%", 24, 76, 265, 17, BitOR($SS_CENTER,$WS_BORDER)) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group3 = GUICtrlCreateGroup("Descompactação", 16, 112, 281, 81, $BS_FLAT) $Progress2 = GUICtrlCreateProgress(24, 136, 265, 17) $Label2 = GUICtrlCreateLabel("Porcentagem De Descompactação", 24, 164, 265, 17, BitOR($SS_CENTER,$WS_BORDER)) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW)
For $Download = 1 To 100 Step 10 GUICtrlSetData($Progress1, $Download) GUICtrlSetData($Label1, "Porcentagem De Download: " & $Download & "%") InetGet($Link_Download, "Atualização.rar", 1) Next GUICtrlSetData($Label1, "Download Concluido Com Sucesso")
For $Descompactacao = 1 To 100 Step 10 GUICtrlSetData($Progress2, $Descompactacao) GUICtrlSetData($Label2, "Porcentagem De Descompactação: " & $Descompactacao & "%")
$hUnRAR_CallBack = DllCallbackRegister("_UnRARProc", "int", "uint;int;int;int")
$comment = _Rar_GetComment("Atualização.rar") ConsoleWrite("!> Archive comment: " & $comment & @LF) $hArchive = _RAR_OpenArchive("Atualização.rar")
_Rar_TestArchive($hArchive) _RAR_CloseArchive($hArchive) $hArchive = _RAR_OpenArchive("Atualização.rar")
_RAR_SetCallback($hArchive, $hUnRAR_CallBack) _Rar_UnpackArchive($hArchive, "")
DllCallbackFree($hUnRAR_CallBack) Next GUICtrlSetData($Label2, "Descompactado Com Sucesso") MsgBox("","","Parabens Atualizado Com Sucesso") Exit
EndFunc ; Fim Do Form 3 Download Da Source: [Tens de ter uma conta e sessão iniciada para poderes visualizar este link]Créditos: Huntresske (Daniel Turina) | |
|