- Offizieller Beitrag
Hallo!
Also.. ich hab mir gedacht, programmiere ich mal was, was die Welt aufkeinen fall brauch oder etwas was es schon gibt^^ Dieses Skript macht eigentlich genau das gleiche wie XFire, guckt also welche Spiele installiert sind und wo... Das Skript basiert auf die xfire_games.ini wo so ziemlich alle Spiele drin sind. Also, vorteil gegenüber XFire seh ich eigentlich keinen^^. naja auser halt das es kompakter ist
Also hier nun das Skript, und im Anhang die xfire_games und die Kompilierte exe!
Spoiler anzeigen
#include <GUIConstants.au3>
#include <array.au3>
#include <string.au3>
#include <file.au3>
#include <GuiListView.au3>
#AutoIt3Wrapper_icon = xfire.ico
#AutoIt3Wrapper_outfile = Xfire GameList - By GtaSpider.exe
#AutoIt3Wrapper_compression = 4
FileInstall("xfire_games.ini", @TempDir & "\gamel~.tmp", 1)
[/autoit] [autoit][/autoit] [autoit]Global $FullGameList[1][7], $GameList[1], $nCol = -1, $bSet = 0, $nCurCol = -1, $nSortDir = 1
Global Const $LVM_GETITEM = $LVM_FIRST + 5
Global Const $WM_NOTIFY = 0x004E
Global Const $DebugIt = 1
Global Const $NM_FIRST = 0
Global Const $NM_LAST = (-99)
Global Const $NM_OUTOFMEMORY = ($NM_FIRST - 1)
Global Const $NM_CLICK = ($NM_FIRST - 2)
Global Const $NM_DBLCLK = ($NM_FIRST - 3)
Global Const $XFireGameList = @TempDir & "\gamel~.tmp"
Global Const $IniGames = @WindowsDir & "\installedgames.ini"
If Not FileExists($XFireGameList) Then
If MsgBox(52, "", $XFireGameList & " existiert nicht!" & @CRLF & "Willst du Sie dir nun Downloaden?") = 7 Then Exit
ShellExecute("http://www.autoit.de/thread.php?threadid=2988")
Exit
EndIf
$maingui = GUICreate("Xfire Game List - Script by GtaSpider", 393, 424, 201, 122, -1, $WS_EX_TOOLWINDOW)
GUISetBkColor(0x000000)
$lview1 = GUICtrlCreateListView("Name des Spiels|Pfad", 8, 8, 378, 350, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS))
GUICtrlSendMsg(-1, 0x101E, 0, 170)
GUICtrlSendMsg(-1, 0x101E, 1, 200)
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, 0x010101)
$prog1 = GUICtrlCreateProgress(8, 392, 378, 9)
$butStartGame = GUICtrlCreateButton("Starte &Spiel", 8, 363, 100, 22)
$butStartXfire = GUICtrlCreateButton("Starte X&fire", 112, 363, 100, 22)
$butRefXfGaLi = GUICtrlCreateButton("Liste &neu Einlesen", 216, 363, 172, 22)
$labStat = GUICtrlCreateLabel("Status: Bereit", 8, 403, 378, 15)
GUICtrlSetColor(-1, 0x00FF00)
GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")
GUICtrlRegisterListViewSort($lview1, "LVSort")
GUISetState(@SW_SHOW)
[/autoit] [autoit][/autoit] [autoit]If IniRead($IniGames, "options", "firststart", "0") = '0' Then
IniWrite($IniGames, "options", "firststart", "1")
If MsgBox(4, "", "Möchten Sie dieses Programm in Ihren Autostart kopieren?") = 6 Then FileCreateShortcut(@ScriptFullPath, @StartupCommonDir & "\Xfire GameList - By GtaSpider", @ScriptDir)
EndIf
If Not _ReadFromIni() Then
GUICtrlSetState($butRefXfGaLi, $GUI_DISABLE)
GUICtrlSetState($butStartGame, $GUI_DISABLE)
GUICtrlSetState($butStartXfire, $GUI_DISABLE)
_ReadGameList()
WinSetTitle($maingui, '', "Xfire Game List - Script by GtaSpider - " & _CheckInstalledGames() & " Spiele")
GUICtrlSetState($butRefXfGaLi, $GUI_ENABLE)
GUICtrlSetState($butStartGame, $GUI_ENABLE)
GUICtrlSetState($butStartXfire, $GUI_ENABLE)
EndIf
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $lview1
$bSet = 0
$nCurCol = $nCol
GUICtrlSendMsg($lview1, $LVM_SETSELECTEDCOLUMN, GUICtrlGetState($lview1), 0)
DllCall("user32.dll", "int", "InvalidateRect", "hwnd", GUICtrlGetHandle($lview1), "int", 0, "int", 1)
Case $butStartGame
$aSplit = StringSplit(_GUICtrlListViewGetItemText($lview1, _GUICtrlListViewGetSelectedIndices($lview1)), "|", 1)
If $aSplit[0] < 2 Then
MsgBox(48, "", "Wählen Sie erst ein Spiel aus!")
ContinueLoop
EndIf
If MsgBox(4, "", "Möchten Sie das Spiel " & $aSplit[1] & " Starten?") = 7 Then ContinueLoop
Run($aSplit[2])
Case $butStartXfire
If Not FileExists(RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Xfire", "") & "\Xfire.exe") Then
MsgBox(48, "", "XFire ist auf Ihrem PC nicht installiert!")
ContinueLoop
EndIf
Run(RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Xfire", "") & "\Xfire.exe")
Case $butRefXfGaLi
GUICtrlSetState($butRefXfGaLi, $GUI_DISABLE)
GUICtrlSetState($butStartGame, $GUI_DISABLE)
GUICtrlSetState($butStartXfire, $GUI_DISABLE)
Global $GameList[1], $FullGameList[1][7]
_ReadGameList()
WinSetTitle($maingui, '', "Xfire Game List - Script by GtaSpider - " & _CheckInstalledGames() & " Spiele")
GUICtrlSetState($butRefXfGaLi, $GUI_ENABLE)
GUICtrlSetState($butStartGame, $GUI_ENABLE)
GUICtrlSetState($butStartXfire, $GUI_ENABLE)
GUICtrlSetData($prog1, 100)
EndSwitch
WEnd
Func _ReadGameList()
Local $aReadSectName, $i, $iProz, $iOldProz, $Pr_Handle, $b, $iBuf = 0
$aReadSectName = IniReadSectionNames($XFireGameList)
GUICtrlSetData($labStat, "Status: Lese Xfire GameList ein (0%)")
ReDim $FullGameList[$aReadSectName[0] + 1][7]
For $i = 1 To $aReadSectName[0]
$FullGameList[$i][0] = IniRead($XFireGameList, $aReadSectName[$i], "LongName", "")
$FullGameList[$i][1] = IniRead($XFireGameList, $aReadSectName[$i], "LauncherDirKey", "")
$FullGameList[$i][2] = IniRead($XFireGameList, $aReadSectName[$i], "LauncherExe", "")
$FullGameList[$i][3] = IniRead($XFireGameList, $aReadSectName[$i], "DetectExe", $FullGameList[$i][2])
$FullGameList[$i][4] = IniRead($XFireGameList, $aReadSectName[$i], "LauncherDirTruncAt", "")
$FullGameList[$i][5] = IniRead($XFireGameList, $aReadSectName[$i], "LauncherDirDefault", "")
$FullGameList[$i][6] = IniRead($XFireGameList, $aReadSectName[$i], "LauncherDirAppend", "")
$iProz = Round(100 * $i / $aReadSectName[0])
If $iProz <> $iOldProz Then
$iOldProz = $iProz
GUICtrlSetData($prog1, $iProz)
GUICtrlSetData($labStat, "Status: Lese Xfire GameList ein (" & $iProz & "%)")
EndIf
Next
$Pr_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', @AutoItPID)
DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $Pr_Handle[0])
DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $Pr_Handle[0])
EndFunc ;==>_ReadGameList
Func _CheckInstalledGames()
Local $sGamePath, $Tmp, $sBuf, $i, $b, $a, $c, $aFileList, $iFileEx = 0, $sRegEx, $iCount = 0, $iOldProz
_GUICtrlListViewDeleteAllItems($lview1)
For $i = 1 To UBound($FullGameList, 1) - 1
$iFileEx = 0
;LauncherDirKey --> $sGamePath
$sGamePath = RegRead(StringLeft($FullGameList[$i][1], StringInStr($FullGameList[$i][1], "\", -1, -1)), StringTrimLeft($FullGameList[$i][1], StringInStr($FullGameList[$i][1], "\", -1, -1)))
If @error Then
If $FullGameList[$i][5] <> '' Then $sGamePath = $FullGameList[$i][5]
EndIf
If $FullGameList[$i][4] <> '' Then
$sBuf = ''
$Tmp = StringSplit($sGamePath, $FullGameList[$i][4], 1)
For $b = 1 To $Tmp[0]
$sBuf &= $Tmp[$b]
Next
$sGamePath = $sBuf
EndIf
;Make GamePath free from bugs
$sGamePath = StringReplace(StringReplace($sGamePath, '"', ''), '%1', '')
$sGamePath = StringReplace(StringStripWS($sGamePath, 2), "\\", "\")
If StringRight($sGamePath, 1) <> "\" And $sGamePath <> "" Then $sGamePath &= "\"
If $FullGameList[$i][6] <> '' Then $sGamePath &= $FullGameList[$i][6] & "\"
$sGamePath = StringReplace(StringStripWS($sGamePath, 2), "\\", "\")
;Replace Envoirement Variables
If StringRegExp($sGamePath, "%(.*?)%") Then
$sRegEx = StringRegExp($sGamePath, "%(.*?)%", 3)
For $c = 0 To UBound($sRegEx) - 1
$sGamePath = StringReplace($sGamePath, "%" & $sRegEx[$c] & "%", EnvGet($sRegEx[$c]))
Next
EndIf
;Test -------
;~ If $FullGameList[$i][0] = 'TeamSpeak' Then InputBox("","[user='200010']Oscar[/user]: Bitte kopier dir diesen Pfad und packe ihn ins Forum, und sag mir ob das der Pfad zu der Splinter Cell exe ist.. :)",$sGamePath & $FullGameList[$i][2])
;/Test -------
;Replace \*\ in path
If StringInStr($FullGameList[$i][3], "\*\") And FileExists($sGamePath) Then
$aFileList = _FileListToArray(StringLeft($sGamePath & $FullGameList[$i][3], StringInStr($sGamePath & $FullGameList[$i][3], "\*\")), "*", 2)
For $a = 1 To $aFileList[0]
If FileExists(StringLeft($sGamePath & $FullGameList[$i][3], StringInStr($sGamePath & $FullGameList[$i][3], "\*\")) & $aFileList[$a] & StringTrimLeft($sGamePath & $FullGameList[$i][3], StringInStr($sGamePath & $FullGameList[$i][3], "\*\") + 1)) Then
$iFileEx = 1
EndIf
Next
EndIf
If FileExists($sGamePath & $FullGameList[$i][3]) Or $iFileEx Then
ReDim $GameList[$iCount + 1]
$GameList[$iCount] = GUICtrlCreateListViewItem($FullGameList[$i][0] & "|" & $sGamePath & $FullGameList[$i][2], $lview1)
GUICtrlSetImage(-1, $sGamePath & $FullGameList[$i][2], 0)
$iCount += 1
EndIf
$iProz = Round(100 * $i / UBound($FullGameList, 1) - 1)
If $iProz <> $iOldProz Then
$iOldProz = $iProz
GUICtrlSetData($prog1, $iProz)
GUICtrlSetData($labStat, "Status: Suche nach Installierten Spielen (" & $iProz & "%)")
EndIf
Next
_WriteToIni()
Return $iCount
EndFunc ;==>_CheckInstalledGames
Func _WriteToIni()
Local $i, $Tmp
FileDelete($IniGames)
IniWrite($IniGames, "options", "firststart", "1")
For $i = 0 To UBound($GameList) - 1
IniWrite($IniGames, "Games", $i, GUICtrlRead($GameList[$i]))
Next
GUICtrlSetData($labStat, "Status: Daten wurden in " & $IniGames & " geschrieben!")
AdlibEnable("_AdlibStat", 2000)
EndFunc ;==>_WriteToIni
Func _ReadFromIni()
Local $i, $irs, $Tmp
Global $GameList[1]
If (Not FileExists($IniGames)) Or (Not FileGetSize($IniGames)) Then Return 0
GUICtrlSetData($labStat, "Status: Lese daten von " & $IniGames)
_GUICtrlListViewDeleteAllItems($lview1)
$irs = IniReadSection($IniGames, "Games")
For $i = 1 To $irs[0][0]
ReDim $GameList[$i + 1]
$Tmp = StringSplit($irs[$i][1], "|")
$GameList[$i] = GUICtrlCreateListViewItem($Tmp[1] & "|" & $Tmp[2], $lview1)
GUICtrlSetImage(-1, $Tmp[2], 0)
Next
_AdlibStat()
WinSetTitle($maingui, '', "Xfire Game List - Script by GtaSpider - " & $irs[0][0] & " Spiele")
Return 1
EndFunc ;==>_ReadFromIni
Func _AdlibStat()
GUICtrlSetData($labStat, "Status: Bereit")
AdlibDisable()
EndFunc ;==>_AdlibStat
Func LVSort($hWnd, $nItem1, $nItem2, $nColumn)
Local $nSort
; Switch the sorting direction
If $nColumn = $nCurCol Then
If Not $bSet Then
$nSortDir = $nSortDir * - 1
$bSet = 1
EndIf
Else
$nSortDir = 1
EndIf
$nCol = $nColumn
$val1 = GetSubItemText($lview1, $nItem1, $nColumn)
$val2 = GetSubItemText($lview1, $nItem2, $nColumn)
; If it is the 3rd colum (column starts with 0) then compare the dates
If $nColumn = 2 Then
$val1 = StringRight($val1, 4) & StringMid($val1, 4, 2) & StringLeft($val1, 2)
$val2 = StringRight($val2, 4) & StringMid($val2, 4, 2) & StringLeft($val2, 2)
EndIf
$nResult = 0 ; No change of item1 and item2 positions
If $val1 < $val2 Then
$nResult = -1 ; Put item2 before item1
ElseIf $val1 > $val2 Then
$nResult = 1 ; Put item2 behind item1
EndIf
$nResult = $nResult * $nSortDir
Return $nResult
EndFunc ;==>LVSort
; Retrieve the text of a listview item in a specified column
Func GetSubItemText($nCtrlID, $nItemID, $nColumn)
Local $stLvfi = DllStructCreate("uint;ptr;int;int[2];int")
DllStructSetData($stLvfi, 1, $LVFI_PARAM)
DllStructSetData($stLvfi, 3, $nItemID)
Local $stBuffer = DllStructCreate("char[260]")
$nIndex = GUICtrlSendMsg($nCtrlID, $LVM_FINDITEM, -1, DllStructGetPtr($stLvfi));
Local $stLvi = DllStructCreate("uint;int;int;uint;uint;ptr;int;int;int;int")
DllStructSetData($stLvi, 1, $LVIF_TEXT)
DllStructSetData($stLvi, 2, $nIndex)
DllStructSetData($stLvi, 3, $nColumn)
DllStructSetData($stLvi, 6, DllStructGetPtr($stBuffer))
DllStructSetData($stLvi, 7, 260)
GUICtrlSendMsg($nCtrlID, $LVM_GETITEM, 0, DllStructGetPtr($stLvi));
[/autoit] [autoit][/autoit] [autoit]$sItemText = DllStructGetData($stBuffer, 1)
[/autoit] [autoit][/autoit] [autoit]$stLvi = 0
$stLvfi = 0
$stBuffer = 0
Return $sItemText
EndFunc ;==>GetSubItemText
Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
#forceref $hWndGUI, $MsgID, $wParam
Local $tagNMHDR, $event, $hwndFrom, $code, $aSplit
$tagNMHDR = DllStructCreate("int;int;int", $lParam) ;NMHDR (hwndFrom, idFrom, code)
If @error Then Return
$event = DllStructGetData($tagNMHDR, 3)
Select
Case $wParam = $lview1
Select
Case $event = $NM_DBLCLK
$aSplit = StringSplit(_GUICtrlListViewGetItemText($lview1, _GUICtrlListViewGetSelectedIndices($lview1)), "|", 1)
If $aSplit[0] < 2 Then Return MsgBox(48, "", "Wählen Sie erst ein Spiel aus!")
If MsgBox(4, "", "Möchten Sie das Spiel " & $aSplit[1] & " Starten?") = 7 Then Return $GUI_RUNDEFMSG
Run($aSplit[2])
EndSelect
EndSelect
$tagNMHDR = 0
$event = 0
$lParam = 0
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_Notify_Events
Func OnAutoItExit()
FileDelete($XFireGameList)
EndFunc ;==>OnAutoItExit
Mfg Spider
Edit: Ich würde mich um rückmeldungen freunen Hat es geklappt (wurden alle spiele entdeckt)?