Looking for a little help, Swapping in source lines. etc

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
wizshaw
Posts: 14
Joined: 21 Oct 2021, 20:57

Looking for a little help, Swapping in source lines. etc

15 Jun 2023, 09:01

Looking for a little help to clean up this code and get it working. Basically the flow is as follows... It doesnt seem to be working right now. Any insights would be appreciated.

Ive attached the reference files below

Thank you!

Chris

1. Remove "P1DeviceName = "
2. Replace all "&" with "&"
3. Copy lines 3 and 7
4. 3 with ###LIGHTGUN1###
5. 7 with ###LIGHTGUN2###

Code: Select all

filecopy, D:\Arcade\Tools\Demul Shooter\config.ini, D:\Arcade\Tools\Demul Shooter\configBU.ini

Sleep 200

fileread, file1, D:\Arcade\Tools\Demul Shooter\config.ini ; fileread, file1, %path2file1%
newtext := strreplace(file1, "P1DeviceName = ", "")
newtext2 := strreplace(file1, "&", "&")
filedelete, D:\Arcade\Tools\Demul Shooter\config.ini
fileappend, %newtext%, D:\Arcade\Tools\Demul Shooter\configA.ini
fileappend, %newtext2%, D:\Arcade\Tools\Demul Shooter\configA.ini
Sleep 200
fileread, fileA, D:\Arcade\Tools\Demul Shooter\configA.ini ; fileread, fileA, %path2file1%
newtext3 := strreplace(fileA, "P2DeviceName = ", "")
newtext4 := strreplace(fileA, "&", "&")
filedelete, D:\Arcade\Tools\Demul Shooter\configA.ini
fileappend, %newtext3%, D:\Arcade\Tools\Demul Shooter\config.ini
fileappend, %newtext4%, D:\Arcade\Tools\Demul Shooter\config.ini

Sleep 200

sourceline := 3

fileread, file2, D:\Arcade\Tools\Demul Shooter\config.ini ; fileread, file1, %path2file1%
fileread, file3, D:\Arcade\Emulators\TechnoParrot\UserProfiles\UserProfilesRAW\Transformers.xml
newtext5 := strreplace(file3, "###LIGHTGUN1###", "%sourceline%")
fileappend, %newtext5%, D:\Arcade\Emulators\TechnoParrot\UserProfiles\Transformers.xml

Sleep 200

sourceline := 7

fileread, file4, D:\Arcade\Tools\Demul Shooter\config.ini ; fileread, file1, %path2file1%
fileread, file5, D:\Arcade\Emulators\TechnoParrot\UserProfiles\UserProfilesRAW\Transformers.xml
newtext6 := strreplace(file5, "###LIGHTGUN2###", "%sourceline%")
fileappend, %newtext6%, D:\Arcade\Emulators\TechnoParrot\UserProfiles\Transformers.xml

Sleep 200

filedelete, D:\Arcade\Tools\Demul Shooter\config.ini
filecopy, D:\Arcade\Tools\Demul Shooter\configBU.ini, D:\Arcade\Tools\Demul Shooter\config.ini

Sleep 200

filedelete, D:\Arcade\Tools\Demul Shooter\configBU.ini
exitapp
[Mod edit: [code][/code] tags added. Please use them yourself going forward!]
Attachments
Transformers.xml
(37.47 KiB) Downloaded 13 times
config.ini
(3.36 KiB) Downloaded 10 times
wizshaw
Posts: 14
Joined: 21 Oct 2021, 20:57

Re: Looking for a little help, Swapping in source lines. etc

17 Jun 2023, 03:47

Any help would be appreciated... Ill paypal somebody 30 bucks for 5 mins of their time.
User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: Looking for a little help, Swapping in source lines. etc

17 Jun 2023, 06:18

You may need syntax like this.

Code: Select all

StrReplace(file5, "###LIGHTGUN2###", sourceline)
malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: Looking for a little help, Swapping in source lines. etc

17 Jun 2023, 06:58

If Your task is to change xml values with ini values it can be done like this:
Your ini should have section name on first line:
ini:
[settings]
;Player1 Device configuration
P1Mode = RAWINPUT
P1DeviceName = \\?\HID#VID_D209&PID_1602&MI_02#b&35eec36f&0&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd}

;Player2 Device configuration
P2Mode = RAWINPUT
P2DeviceName = \\?\HID#VID_045E&PID_028E&IG_03#3&31042e6&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}

Code: Select all

iniPath := "D:\Temp\config.ini"
xmlPath := "D:\Temp\Transformers.xml"

IniRead, LIGHTGUN1, % iniPath, settings, P1DeviceName
IniRead, LIGHTGUN2, % iniPath, settings, P2DeviceName
xmlDoc := ComObjCreate("MSXML2.DOMDocument.6.0")
xmlDoc.async := false
xmlDoc.load(xmlPath)
docNodes := xmlDoc.selectNodes("//GameProfile/JoystickButtons/JoystickButtons/RawInputButton/DevicePath")
for docNode in docNodes
{
   if (docNode.text = "###LIGHTGUN1###")
      docNode.text := LIGHTGUN1
   else if (docNode.text = "###LIGHTGUN2###")
      docNode.text := LIGHTGUN2
}
xmlDoc.Save(xmlPath)
wizshaw
Posts: 14
Joined: 21 Oct 2021, 20:57

Re: Looking for a little help, Swapping in source lines. etc

20 Jun 2023, 05:54

SOLVED! I figured it out after some testing!

Code: Select all

filecopy, D:\Arcade\Tools\Demul Shooter\config.ini, D:\Arcade\Tools\Demul Shooter\configBU.ini

Sleep 200

fileread, file1, D:\Arcade\Tools\Demul Shooter\configBU.ini ; fileread, file1, %path2file1%
newtext := strreplace(file1, "P1DeviceName = ", "")
fileappend, %newtext%, D:\Arcade\Tools\Demul Shooter\configA.ini

Sleep 200

fileread, file2, D:\Arcade\Tools\Demul Shooter\configA.ini ; fileread, file1, %path2file1%
newtext1 := strreplace(file2, "P2DeviceName = ", "")
fileappend, %newtext1%, D:\Arcade\Tools\Demul Shooter\configB.ini

Sleep 200

fileread, file3, D:\Arcade\Tools\Demul Shooter\configB.ini ; fileread, file1, %path2file1%
newtext2 := strreplace(file3, "&", "&")
fileappend, %newtext2%, D:\Arcade\Tools\Demul Shooter\configC.ini

filedelete, D:\Arcade\Tools\Demul Shooter\configBU.ini
filedelete, D:\Arcade\Tools\Demul Shooter\configA.ini
filedelete, D:\Arcade\Tools\Demul Shooter\configB.ini

Sleep 200

sourceline := 3

fileread, file4, D:\Arcade\Tools\Demul Shooter\configC.ini ; fileread, file1, %path2file4%
fileread, file5, D:\Arcade\Emulators\TechnoParrot\UserProfiles\UserProfilesRAW\Transformers.xml ; fileread, file1, %path2file5%
tmp := strsplit(file4,"`n","`r")[sourceline]    ;reads the third line of file4 into variable tmp

Sleep 200

newtext3 := strreplace(file5, "###LIGHTGUN1###", tmp)

Sleep 200

fileappend, %newtext3%, D:\Arcade\Emulators\TechnoParrot\UserProfiles\Trans
formersTEST.xml

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: adam86shadow, Bing [Bot], Chunjee, JKJadan, TAC109 and 285 guests