Sims 2: Modding SimPE Files with AutoIT
Modding SimPE files with AutoIT – V1.0: 03/14/2020
***WARNING: HIGHLY EXPERIMENTAL. USE AT YOUR OWN RISK!***
***For use with Windows OS only!***
After the relative success of figuring out how to automate creating Sims 2 files in Body Shop, I set out to try to automate SimPE too. It took me several tries, but through trial and error, I managed to cobble some working codes together. Here’s how it works: AutoIT can send keypresses to a program – for example, it could type some letters in a document without a physical person having to type those letters in the keyboard.
I noticed one day that you can move from panel to panel in SimPE using the tab key, and that the up and down keys could move the selection within the panel. This meant that I could create a script that would open a SimPE file, navigate to the correct panel, and make a change to the file. For example, I could have the script open the BINX resource in a Body Shop file and edit the sort index. I could then have the script do this same task for a large number of files.
The first step to getting started with your own industrial SimPE factory is to download AutoIT. Make sure you find your Au3Info program included with your AutoIT installation. You’ll probably also want to familiarize yourself with the syntax and some example scripts. I've also made a few example scripts for you to look at. Please feel free to copy and paste anything from them into your own code!
Commands you should know:
WinActivate([Window Name]) and WinWaitActive([Window Name]) will either activate the window you specify, or wait until it becomes active. I used the first command to activate SimPE (and make sure my script was only running on that window), while the second was for waiting for an open file window to open.
If/Then commands: Start your statement with If, type your required condition, and then type Then. Go to a new line, indent, and type the results if your condition is met. End the statement on an indented line by typing EndIf.
For loops: Similar to if/then statements, start the line with For $[variable] = [start] To [end]. Indent the commands in the for loop. End the for loop with an unindented line with Next.
Variables: They’re declared by the $ character. For example, $i. To get lists to work with Send commands, you may have to declare the list as a global variable as in Global $list = [1,2,3,…]. Calling out one item in a variable list is done by $list[position #]. For example, the second item in the list above would be called by $list[2].
; will comment out a line. It’s probably a good idea to use this to explain what you’re doing with a particular command. I should probably use it too, but I don’t because I assume I will remember what everything means months down the line and then I am always surprised when I don’t. Don’t be me.
Sleep([# milliseconds]) will make your script wait for that many milliseconds before you move onto the next command. Useful if your computer is a dinosaur and lags a bit.
ControlClick("[Window Name]", "", "[Panel Name]", "[type of click]") will click somewhere on a panel. For the type of click, “left” will cause a left click, and “right” a rick click. The panel name can be found by using Au3Info. I had trouble getting this to work right, so I used it sparingly.
Send([“key #”]) will send a keypress to the program, with # being the number of times to press the key. You can leave out the number if you’re only pressing a key once.
Key list:
{TAB} is tab
{ENTER} is Enter
{DEL} is the delete key (Not the backspace key!!)
{PGUP} is page up
{PGDN} is page down
{UP} and {DOWN} are the up and down arrow keys
+ is shift
^ is control
Examples of usage:
To get the program to save, you’d use the command Send(“^s”). To move to a panel two steps backwards, you’d use the command Send(“+{TAB 2”}).
You can use a declared variable in a Send command too! If you want a key to be pressed a number of times expressed by your variable, you’d use Send("[key]" & $[variable] & "}"). If you want a variable to be typed as is in the program, you’d use Send($[variable],1).
Tips and Tricks:
I had a lot of crashes and files get changed erroneously while trying to automate SimPE. Backup your Sims files before you run any script! Also, something to consider, you might want to add something like an if command/while loop that prevents keys from being pressed if SimPE/the file open windows are not active. I might add this to my stuff in the future.
Before you start a script, open up a file in the directory you need to change things in. Theoretically, you could use your tab commands to move into different directories, but this will get complicated. For simplicity’s sake, place everything you need in one directory.
When you open up your first test file, make sure you load 3IDRs (they take a while) and then click on the very top of the Resource Tree list (above 3IDR). Close your file and you should be good to run a script. When you run a script, assume your selection will start at this top spot. If you write your own scripts, have them end back at this spot, so that the next file can be navigated in properly.
When you add in swatches or image files, make sure they are also in the same directory and are in the same order as the files they correspond to.
In my example scripts, the $i variable refers to the number of SimPE files in the directory that I want to change. $j is a variable for the items within the Resource List panel.
The number of times you have to press tab to get to panels may vary depending on if you have the Resource Actions panel or other items open or not. This also may influence the panel number seen in the ControlClick command. Also note that sometimes tab doesn’t always take you in an order that makes sense. Test out how many tab presses it takes to get to items rather than just using the same numbers I used in my examples.
Having the scripts change more than one type of resource in a file wasn’t something I looked into, I wanted to keep things as simple as possible. Your mileage may vary.
That’s it for now: Go forth and create lots of Sims things! Don’t hesitate to reach out and ask questions if you need to!