classMemory writeString problem Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
gecko
Posts: 37
Joined: 13 Nov 2017, 23:19

classMemory writeString problem

30 Jan 2019, 02:49

Hi all,

I've been starting to use classMemory to create scripts that read and write values to a flight simulator. I'm pretty new at this but it has been going OK. I am having a problem getting writeString to work. My script is trying to replace the name of a sound file with the name of a different sound file. This works when I do it manually using cheat engine and I can swap between hearing the two sounds. When I wrote my AHK script to do it automatically, I only get silence instead of the new sound. Here is the relevant line:

Code: Select all

sim.writeString(mem.BaseAddress + 0x004A2870, SJ_Spit_CanopyClose.wav, "utf-8", 0x48, 0x30, 0x0, 0x20, 0x60)
Could the fact that I have to include the file extension with the . be the problem and is there a workaround? How about the encoding parameter? I've tried utf-8 (which has worked for reading a value elsewhere in the simulator), utf-16, utf-8-raw, and utf-16-raw. Are there others I should try?

I also tried including

Code: Select all

sim.insertNullTerminator := False
earlier in the script, and tried it with each of the encoding types mentioned above, and in each case the original sound played instead of the silence I got without that line. So I assume this was preventing anything from being written at all whereas when I left the null terminator in it was writing the string to the address, but not in a way the simulator was able to recognize. Any ideas for what I need to change?

Thanks for any help,

Dan
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: classMemory writeString problem  Topic is solved

30 Jan 2019, 07:42

SJ_Spit_CanopyClose.wav need to be in "" because it is text instead of something else: "SJ_Spit_CanopyClose.wav".
You did hear silence because you overwrote the data with an empty string (essentially the same as putting a null terminator right at the start).
When you disabled the null terminator you wrote nothing in your flight simulator and heard the old sounds.
Your flight simulator might be using CP0 as encoding but for most file there is no difference to UTF-8.
You probably need to write a null terminator so keep that option active.
Recommends AHK Studio
RHCP
Posts: 202
Joined: 30 Sep 2013, 10:59

Re: classMemory writeString problem

30 Jan 2019, 07:55

You may have also forgot to change mem.baseaddress to sim.baseaddress.

Code: Select all

sim.writeString(sim.BaseAddress + 0x004A2870, "SJ_Spit_CanopyClose.wav", "utf-8", 0x48, 0x30, 0x0, 0x20, 0x60)
gecko
Posts: 37
Joined: 13 Nov 2017, 23:19

Re: classMemory writeString problem

30 Jan 2019, 09:29

Thanks guys it's working now. A couple of rookie mistakes, I guess that boot still fits pretty well. And maybe I shouldn't be script writing at 3am. Thanks for your help!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Chunjee, peter_ahk and 382 guests