steam id converter function

Post your working scripts, libraries and tools for AHK v1.1 and older
bzmvc
Posts: 1
Joined: 17 Dec 2014, 00:20

steam id converter function

17 Dec 2014, 00:49

i made a steam id converter
it converts steam ids
made it for myself but i may as well post it here

usage:
- idconv(<input steam id to convert from>, <steamid format you want it converted to>)
- idconv("STEAM_0:0:102877480", "steam3ID") --> "[U:1:205754960]"
- idconv("76561198166020688", "accountID") --> "205754960"
- etc
- default output format is steamid64, so idconv("205754960") --> "76561198166020688"
- it's not case-sensitive btw

bug:
- wontfix: idconv(1, "steamid32") returns STEAM_0:1:-1 which isn't a valid id (who would need to convert that anyway)
- doesn't work on ahk v2 but nobody uses that anyway

not a bug:
- it doesn't do error checking of any kind,format and trim the inputted string urself

get it here:

Code: Select all

/* accepted formats are:
| accountID: 205754960
|  steam3ID: [U:1:205754960]
| steamID32: STEAM_0:0:102877480
| steamID64: 76561198166020688
*/
idconv(id, to:="steamID64") {
	(from:=(instr(id,"a")?"steamID32":instr(id,"[")?"steam3ID":strlen(id)=17?"steamID64":"accountID"))
	return (from="accountID"?(to="accountID"?id:to="steam3ID"?"[U:1:" id "]":to="steamID32"?"STEAM_0:"(((id&1)!=0)?1:0)":"round((id)/2-(((id&1)!=0)?1:0)):to="steamID64"?id+76561197960265728:"error"):from="steam3ID"?(to="accountID"?substr(id,6,strlen(id)-6):to="steam3ID"?id:to="steamID32"?"STEAM_0:"(((substr(id,6,strlen(id)-6)&1)!=0)?1:0)":"round(substr(id,6,strlen(id)-6)/2-(((substr(id,6,strlen(id)-6)&1)!=0)?1:0)):to="steamID64"?substr(id,6,strlen(id)-6)+76561197960265728:"error"):from="steamID32"?(to="accountID"?substr(id,11,strlen(id)-10)*2+substr(id,9,1):to="steam3ID"?"[U:1:"substr(id,11,strlen(id)-10)*2+substr(id,9,1)"]":to="steamID32"?id:to="steamID64"?substr(id,11,strlen(id)-10)*2+76561197960265728+substr(id,9,1):"error"):from="steamID64"?(to="accountID"?id-76561197960265728:to="steam3ID"?"[U:1:"id-76561197960265728 "]":to="steamID32"?"STEAM_0:"(((id&1)!=0)?1:0)":"round((id-76561197960265728)/2-(((id&1)!=0)?1:0)):to="steamID64"?id:"error"):"error")
}
looks like a mess because shorter = better, i didn't like scrolling past the old version that was 60 lines
works on AHK_L unicode 64-bit 1.1.16.5, not sure about other versions because i don't use them 8)


yeah
camarade35
Posts: 1
Joined: 30 Jun 2018, 23:37

Re: steam id converter function

30 Sep 2018, 07:01

Code: Select all

SplitPath, Short_Path,,,,SteamGame,
URLDownloadToFile, https://steamdb.info/search/?a=app&q=%SteamGame%&type=-1&category=0, HTML.txt
FileRead, HTML, HTML.txt
Special1 = <tr class="app" data-appid="
Special2 = ">
SearchString = data-appid=
Loop, read, HTML.txt
	If InStr(A_LoopReadLine, SearchString)
	{
		Line := A_LoopReadLine
		StringReplace, SteamID, A_LoopReadLine, %Special1%,
		StringReplace, SteamID, SteamID, %Special2%,
		GuiControl,, Emulator_Exe, steam://rungameid/%SteamID%
		break
	}
I've make this if you interessed (work online only)


SteamGame = Game Name from Database
Emulator_Exe = Launcher Case in Gui

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 138 guests