- Offizieller Beitrag
Hallo
Also, ich hab eine nVidia grafikkarte und mich nervt es, immer die Treiber manuell downloaden zu müssen.
Mit diesem Tool was ich geschrieben hab funktioniert dies Automatisch ![]()
Außerdem eignet sich das Skript perfekt für Tutorial zwecke, da sehr viel drin ist (Angefangen von IE.au3 über BMP (ja, BMP nicht GIF
) animationen zu Registry.
Mal gucken ob ich mal die Zeit finde das Script komplett zu Kommentieren ![]()
Spoiler anzeigen
;Script by GtaSpider
;(c) 2008 GtaSpider
;Its freeware, so u can share this script with others. DONT SELL THE PROGRAM!
;Read GNU for more Infos: http://en.wikipedia.org/wiki/General_Public_License
#include<IE.au3>
#include<Constants.au3>
#include<GUIConstantsEx.au3>
#include<WindowsConstants.au3>
Opt("TrayAutoPause", 0)
TraySetClick(8)
Global Const $PROGRAMNAME = "Spider Updater"
Global Const $TEMPDIR = @TempDir & "\" & StringLeft($PROGRAMNAME, 4) & "~"
If Not FileExists($TEMPDIR) Then DirCreate($TEMPDIR)
Global $hProgGra, $iBuffer, $aLoadGuis[3], $aGraphic, $sSaveTo
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]_StartLoadingScreen()
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]$aGraphic = _GetGraphiccardInfos()
If @error = 1 Then Exit MsgBox(47 + _StopLoadingScreen(), $PROGRAMNAME, "Sie haben kein Nvidia Grafikkarte oder Windows hat Sie nicht erkannt!")
$aGraphic = _GetGraphiccardDrivers($aGraphic)
$sSaveTo = $TEMPDIR & "\nvidia_" & $aGraphic[1] & "_driver.exe"
InetGet($aGraphic[4], $sSaveTo, 1, 1)
$hMainGui = GUICreate($PROGRAMNAME & " - " & $aGraphic[0], 480, 109, 193, 125)
[/autoit] [autoit][/autoit] [autoit]GUICtrlCreateGroup("Grafikkarten Informationen", 8, 8, 225, 89)
GUICtrlCreateLabel("Grafikkarte:", 16, 28, 59, 15)
GUICtrlCreateLabel($aGraphic[0], 90, 28, 127, 15)
GUICtrlCreateLabel("Serie:", 16, 42, 31, 15)
GUICtrlCreateLabel($aGraphic[1], 90, 42, 127, 15)
GUICtrlCreateLabel($aGraphic[3], 90, 72, 127, 15)
GUICtrlCreateLabel($aGraphic[2], 90, 58, 127, 15)
GUICtrlCreateLabel("Treiberversion:", 16, 58, 74, 15)
GUICtrlCreateLabel("Sprache:", 16, 72, 47, 15)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("Momentan verfügbare Version", 240, 8, 225, 57)
GUICtrlCreateLabel("Download:", 248, 28, 59, 15)
$hMainGui_labURL = GUICtrlCreateLabel(StringLeft($aGraphic[4], 25) & "...", 323, 28, 137, 15)
GUICtrlSetColor(-1, 0xff)
GUICtrlSetFont(-1, Default, Default, 4)
GUICtrlSetCursor(-1, 0)
GUICtrlCreateLabel("Treiberversion:", 248, 42, 74, 15)
GUICtrlCreateLabel($aGraphic[5], 323, 42, 87, 15)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$hMainGui_butdwnl = GUICtrlCreateButton("Downloaden && Installieren", 240, 72, 227, 25, 0)
GUISetState(@SW_SHOW)
$hPrgui = GUICreate($PROGRAMNAME & " - Download && Installation", 366, 93, 333, 163, -1, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST, $hMainGui)
GUISetBkColor(0)
$hPrgui_prg1 = GUICtrlCreateProgress(8, 24, 318, 15)
GUICtrlSetState(-1, $GUI_DISABLE)
$hPrgui_prg2 = GUICtrlCreateProgress(8, 24 + 17, 318, 15)
$hPrgui_static = GUICtrlCreateLabel("", 8, 8, 318, 15)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$hPrgui_prglb1 = GUICtrlCreateLabel("0%", 328, 24, 30, 15)
GUICtrlSetColor(-1, 0xFFFFFF)
$hPrgui_prglb2 = GUICtrlCreateLabel("0%", 328, 24 + 17, 30, 15)
GUICtrlSetColor(-1, 0xFFFFFF)
$hPrgui_butAbb = GUICtrlCreateButton("A&bbrechen", 8, 63, (318 / 2) - 2, 20)
[/autoit] [autoit][/autoit] [autoit]$hPrgui_butBack = GUICtrlCreateButton("&Hintergrund", 10 + (318 / 2) - 2, 63, (318 / 2), 20)
[/autoit] [autoit][/autoit] [autoit]_StopLoadingScreen()
[/autoit] [autoit][/autoit] [autoit]While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
InetGet("abort")
Exit
Case $hMainGui_butdwnl
If Number($aGraphic[2]) >= Number($aGraphic[5]) Then
If MsgBox(52, $PROGRAMNAME & " - Warnung", "Sie haben die gleiche oder eine neuere Version von dem nVidia Treiber." & @CRLF & "Wollen Sie die Installation wirklich durchführen?") = 6 Then _butnDwnl()
EndIf
Case $hMainGui_labURL
GUISetState(@SW_DISABLE, $hMainGui)
InetGet("abort")
GUISetCursor(1, 1, $hMainGui)
RunWait('"' & @ComSpec & '" /c start ' & $aGraphic[4], '', @SW_HIDE)
GUISetCursor(2, 1, $hMainGui)
GUICtrlSetCursor($hMainGui_labURL, 0)
GUISetState(@SW_ENABLE, $hMainGui)
EndSwitch
WEnd
Func _exit()
Exit
EndFunc ;==>_exit
Func _butnDwnl()
Local $iSize, $iPrg = 0, $iOldPrg = 0, $iBuf = 0, $iSteps
If Not @InetGetActive Then InetGet($aGraphic[4], $sSaveTo, 1, 1)
GUICtrlSetData($hPrgui_prg2, "0")
GUICtrlSetData($hPrgui_prglb2, "0%")
GUICtrlSetData($hPrgui_prg1, "0")
GUICtrlSetData($hPrgui_prglb1, "0%")
GUISetState(@SW_DISABLE, $hMainGui)
GUISetState(@SW_SHOW, $hPrgui)
GUICtrlSetData($hPrgui_static, "Download " & StringLeft(StringTrimLeft($aGraphic[4], StringInStr($aGraphic[4], "/", -1, -1)), 30) & "...")
$iSize = InetGetSize($aGraphic[4])
$iPrg = Round(100 * @InetGetBytesRead / $iSize)
For $i = 0 To $iPrg
GUICtrlSetData($hPrgui_prg2, $i)
GUICtrlSetData($hPrgui_prglb2, $i & "%")
GUICtrlSetData($hPrgui_prg1, $i / 3)
GUICtrlSetData($hPrgui_prglb1, Round($i / 3) & "%")
Sleep(100)
Next
While @InetGetActive
Switch GUIGetMsg()
Case $hPrgui_butAbb, $GUI_EVENT_CLOSE
InetGet("abort")
ExitLoop
Case $hPrgui_butBack
TrayTip($PROGRAMNAME, "Fahren Sie mit der Maus über dieses Icon um den momentanen Status anzusehen.", 2)
GUISetState(@SW_HIDE, $hPrgui)
GUISetState(@SW_HIDE, $hMainGui)
EndSwitch
If TrayGetMsg() = $TRAY_EVENT_PRIMARYDOWN Then
GUISetState(@SW_SHOW, $hMainGui)
GUISetState(@SW_SHOW, $hPrgui)
EndIf
$iPrg = Round(100 * @InetGetBytesRead / $iSize)
If $iPrg <> $iOldPrg Then
GUICtrlSetData($hPrgui_prg2, $iPrg)
GUICtrlSetData($hPrgui_prglb2, $iPrg & "%")
GUICtrlSetData($hPrgui_prg1, $iPrg / 3)
GUICtrlSetData($hPrgui_prglb1, Round($iPrg / 3) & "%")
TraySetToolTip("Gesamt: " & Round($iPrg / 3) & "%" & @CRLF & "Momentan: " & $iPrg & "%")
$iOldPrg = $iPrg
EndIf
WEnd
GUISetState(@SW_ENABLE, $hMainGui)
GUISetState(@SW_HIDE, $hPrgui)
If FileExists($sSaveTo) And FileGetSize($sSaveTo) = $iSize Then
Run($sSaveTo)
_Install()
EndIf
Return 0
EndFunc ;==>_butnDwnl
Func _Install()
Local $hWnd, $hCtrlHwnd
WinWait("NVIDIA Windows ")
$hWnd = WinGetHandle("NVIDIA Windows ")
WinSetState($hWnd, "", @SW_HIDE)
ControlClick($hWnd, "", "Button4")
ControlClick($hWnd, "", "Button5")
While WinExists($hWnd)
$iPrg = Round(_Progress_GetPos(ControlGetHandle($hWnd, '', 'msctls_progress321')) / 2)
If $iPrg > 100 Then $iPrg = 100
GUICtrlSetData($hPrgui_prg2, $iPrg)
GUICtrlSetData($hPrgui_prglb2, $iPrg & "%")
GUICtrlSetData($hPrgui_prg1, (100 / 3) + ($iPrg / 3))
GUICtrlSetData($hPrgui_prglb1, Round((100 / 3) + ($iPrg / 3)) & "%")
TraySetToolTip("Gesamt: " & Round((100 / 3) + ($iPrg / 3)) & "%" & @CRLF & "Momentan: " & $iPrg & "%")
Sleep(20)
WEnd
WinWait("NVIDIA Windows ", "NVIDIA-Setup. ")
ControlClick("NVIDIA Windows ", "NVIDIA-Setup. ", "Button1")
While 1
$iPrg = _Progress_GetPos(ControlGetHandle('NVIDIA Windows ', '', 'msctls_progress321'))
GUICtrlSetData($hPrgui_prg2, $iPrg)
GUICtrlSetData($hPrgui_prglb2, $iPrg & "%")
GUICtrlSetData($hPrgui_prg1, (2 * (100 / 3)) + ($iPrg / 3))
GUICtrlSetData($hPrgui_prglb1, Round((2 * (100 / 3)) + ($iPrg / 3)) & "%")
TraySetToolTip("Gesamt: " & Round((2 * (100 / 3)) + ($iPrg / 3)) & "%" & @CRLF & "Momentan: " & $iPrg & "%")
If $iPrg > 80 Then ExitLoop
Sleep(20)
WEnd
Exit
EndFunc ;==>_Install
Func _Progress_GetPos($hWnd)
Local $ret = DllCall("User32.dll", "int", "SendMessage", "hwnd", $hWnd, "int", 1032, "int", 0, "int", 0)
Return Number(StringReplace($ret[0], ",", "."))
EndFunc ;==>_Progress_GetPos
Func _GetGraphiccardInfos()
Local $sGraka, $sDriververs, $sSeries, $sLang, $aRet[4], $i = 0, $sRegRead
While 1
$sTmp = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E968-E325-11CE-BFC1-08002BE10318}\" & StringTrimLeft("0000", StringLen($i)) & $i, "DriverDesc")
If @error Then ExitLoop
If StringLeft($sTmp, 6) = 'NVIDIA' Then $sRegRead = StringTrimLeft("0000", StringLen($i)) & $i
$i += 1
Sleep(10)
WEnd
If Not StringLen($sRegRead) Then Return SetError(1, 0, 0)
$sGraka = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E968-E325-11CE-BFC1-08002BE10318}\" & $sRegRead, "DriverDesc")
$sDriververs = StringReplace(StringRight(RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E968-E325-11CE-BFC1-08002BE10318}\" & $sRegRead, "DriverVersion"), 6), ".", "")
$sGraka = StringTrimLeft($sGraka, 7)
$sSeries = StringLeft($sGraka, 9) & " Series"
Switch StringRight(@OSLang, 2)
Case "07" ;German
$sLang = "Deutsch"
Case "0c";French
$sLang = "Français"
Case "04";Chinese
$sLang = "Chinese (Simplified)"
Case Else ;English
$sLang = "English (US)"
EndSwitch
$aRet[0] = $sGraka
$aRet[1] = $sSeries
$aRet[2] = $sDriververs
$aRet[3] = $sLang
Return $aRet
EndFunc ;==>_GetGraphiccardInfos
Func _GetGraphiccardDrivers($aGraca)
Local $oIE, $sGraka, $sDriververs, $sLang, $oForm, $oElem, $sSeries, $aRegex, $aRet[6]
$sGraka = $aGraca[0]
$sSeries = $aGraca[1]
$sDriververs = $aGraca[2]
$sLang = $aGraca[3]
$oIE = _IECreate("http://www.nvidia.com/Download/index.aspx?lang=en-us", 0, 0)
Switch StringRight(@OSLang, 2)
Case "07" ;German
$sLang = "Deutsch"
Case "0c"
$sLang = "Français"
Case "04"
$sLang = "Chinese (Simplified)"
Case Else ;English
$sLang = "English (US)"
EndSwitch
$oForm = _IEFormGetObjByName($oIE, "Form1")
$oElem = _IEFormElementGetObjByName($oForm, "selOperatingSystem")
While Number(_IEFormElementGetValue($oElem)) = 0
Sleep(50)
WEnd
$oElem = _IEFormElementGetObjByName($oForm, "ddlLanguage")
_IEFormElementOptionSelect($oElem, $sLang, 1, "byText")
$oElem = _IEFormElementGetObjByName($oForm, "selProductSeries")
_IEFormElementOptionSelect($oElem, $sSeries, 1, "byText")
$oElem = _IEFormElementGetObjByName($oForm, "selOperatingSystem")
While Number(_IEFormElementGetValue($oElem)) = 0
Sleep(50)
WEnd
$oElem = _IEFormElementGetObjByName($oForm, "selProductFamily")
_IEFormElementOptionSelect($oElem, $sGraka, 1, "byText")
_IEFormSubmit($oForm)
_IENavigate($oIE, "javascript: GetDriver();")
$aRegex = StringRegExp(_IEBodyReadHTML($oIE), "http://www.nvidia.de/content/license/confirmation.aspx[?]language=.*?&url=(.*?)'", 3)
If Not IsArray($aRegex) Then Return SetError(1, 0, 0)
_IEQuit($oIE)
$aRet[0] = $sGraka
$aRet[1] = $sSeries
$aRet[2] = $sDriververs
$aRet[3] = $sLang
$aRet[4] = $aRegex[0]
$aRet[5] = StringReplace(StringLeft(StringTrimLeft($aRegex[0], StringInStr($aRegex[0], "/", -1, -1)), 6), ".", "")
Return $aRet
EndFunc ;==>_GetGraphiccardDrivers
#Region Loading Screen
[/autoit] [autoit][/autoit] [autoit]Func _StartLoadingScreen()
Local $hBackgui, $hPicgui, $fBMPFile = $TEMPDIR & "\bmpload.bmp", $hBmpctrl, $fBackBMP = $TEMPDIR & "\bckgr.bmp"
FileInstall("anim2.bmp", $fBMPFile)
FileInstall("bckgr.bmp", $fBackBMP)
$hBackgui = GUICreate("Loading", 200, 100, -1, -1, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TRANSPARENT)
$hBackpicgui = GUICreate("", 175, 58, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_MDICHILD), $hBackgui)
GUICtrlCreatePic($fBackBMP, 0, 0, 175, 58)
$hPicgui = GUICreate("anim", 59, 58, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_MDICHILD), $hBackgui)
$hBmpctrl = GUICtrlCreatePic($fBMPFile, 0, 0, 0, 0)
WinSetTrans($hBackgui, "", 0)
$aLoadGuis[0] = $hBackgui
$aLoadGuis[1] = $hPicgui
$aLoadGuis[2] = $hBackpicgui
For $i = 0 To 2
GUISetState(@SW_SHOW, $aLoadGuis[$i])
Next
$hProgGra = _ProgressInitiateGraphic($hPicgui, $hBmpctrl, $fBMPFile)
AdlibEnable("_Swimg", 100)
EndFunc ;==>_StartLoadingScreen
Func _StopLoadingScreen()
AdlibDisable()
For $i = 0 To 2
GUISetState(@SW_HIDE, $aLoadGuis[$i])
Next
Return 1
EndFunc ;==>_StopLoadingScreen
Func _Swimg()
_ProgressSwimg($iBuffer, $hProgGra, 59, 1062, 58)
EndFunc ;==>_Swimg
#Region Thx to mrRevoked and rush4hire
Func _ProgressSwimg(ByRef $nnn, $dllspecs, $BMPwidth, $BMPwidth2, $BMPhight, $opendll = "gdi32.dll")
Local Const $SRCCOPY = 0xCC0020
$nnn += $BMPwidth
If $nnn > $BMPwidth2 - 1 Then $nnn = 0
DllCall($opendll, "int", "BitBlt", "int", $dllspecs[0], "int", 0, "int", 0, "int", $BMPwidth, "int", $BMPhight, _
"int", $dllspecs[1], "int", $nnn, "int", 0, "int", $SRCCOPY)
EndFunc ;==>_ProgressSwimg
Func _ProgressInitiateGraphic(ByRef $hWin, ByRef $nID, $szFile)
Local Const $GWL_HINSTANCE = -6
Local Const $IMAGE_BITMAP = 0
Local Const $LR_LOADFROMFILE = 0x0010
Local $dllspecs[4], $dll, $hWnd, $opendll, $phWnd, $dc, $dc1, $old
$hWnd = WinGetHandle($hWin)
$opendll = DllOpen("gdi32.dll")
Local $dll = DllOpen("user32.dll")
$hInst = DllCall($dll, "int", "GetWindowLong", "hWnd", $hWnd, "int", $GWL_HINSTANCE)
$hBmp = DllCall($dll, "hwnd", "LoadImage", "hwnd", $hInst[0], "str", $szFile, _
"int", $IMAGE_BITMAP, "int", 0, "int", 0, "int", $LR_LOADFROMFILE)
$phWnd = DllCall($dll, "hwnd", "GetDlgItem", "hwnd", $hWin, "int", $nID)
$dc = DllCall($dll, "int", "GetDC", "hwnd", $phWnd[0])
$dc1 = DllCall($opendll, "int", "CreateCompatibleDC", "int", $dc[0])
$old = DllCall($opendll, "hwnd", "SelectObject", "int", $dc1[0], "hwnd", $hBmp[0])
$dllspecs[0] = $dc[0]
$dllspecs[1] = $dc1[0]
$dllspecs[2] = $hBmp[0]
$dllspecs[3] = $old[0]
DllClose($dll)
Return $dllspecs
EndFunc ;==>_ProgressInitiateGraphic
Func _ProgressDestroyGraphic($dllspecs)
Local $opendll = DllOpen("gdi32.dll")
DllCall($opendll, "hwnd", "SelectObject", "int", $dllspecs[1], "hwnd", $dllspecs[3])
DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "int", $dllspecs[0])
DllCall($opendll, "int", "DeleteDC", "int", $dllspecs[1])
DllCall($opendll, "int", "DeleteObject", "hwnd", $dllspecs[2])
DllClose($opendll)
EndFunc ;==>_ProgressDestroyGraphic
#EndRegion Thx to mrRevoked and rush4hire
Func OnAutoItExit()
FileDelete($TEMPDIR & "\bmpload.bmp")
FileDelete($TEMPDIR & "\bckgr.bmp")
InetGet("abort")
FileDelete($sSaveTo)
DirRemove($TEMPDIR,1)
EndFunc ;==>OnAutoItExit
Würde mich über Kommentare, Anregungen und Bugreport (nagut darüber weniger^^) freuen!
Im Anhang die Kompelierte EXE und ein Icon.
Mfg Spider