Complete a Set of Keystrokes Until I Find a Shiny Pokemon

Hello all! I am very new to all of this, so please let me know if I am doing anything wrong, and please excuse my ignorance. I am looking to make a script that will help me automatically shiny hunt in Pokemon Platinum. I currently play it on an emulator called OpenEmu, but I have had no success in getting Keyboard Maestro to activate keystrokes that affect gameplay, and thus tried DeSmuME, which I was able to write a macro that successfully controlled the game.

Basically, what I am looking to do is have the macro hold down the speed-up button (which I assigned to W in OpenEmu and DeSmuME), hold the rapid-fire A button (in OpenEmu this needs to hold the space bar down, in DeSmuME it needs to hold the A key) until the screen shows the Pokemon I am hunting for (a shiny Turtwig, since I am hunting it as a starter Pokemon) and then reset and load a quick save file if it is not shiny, (by pressing either the L key in OpenEmu or the 1 key in DeSmuME) and repeat this loop until it is shiny, then pause the emulation (the 4 key in OpenEmu and the P key in DeSmuME) and stop the macro. I attempted to do this first in OpenEmu. OpenEmu runs the emulation at a constant speed when using the fast forward, so it was always around 11 seconds after loading the quick save that the Turtwig was sent out and I could see if it was shiny or not. Thus, I made the macro script look like this:

However... This script never worked in OpenEmu, I think it could be because OpenEmu does not allow for keyboard inputs from outside software. That being said, I tried the macro and it worked in other windows (which got annoying because I couldn't figure out how to stop it...) however, when I got the screen to show the shiny Turtwig (using cheats just to test and see if the script would work) it said that the pixel condition was currently false, even though it should have been true. I tried bringing OpenEmu to the front window, and it still did not work. I tried putting that color on a Photoshop canvas and it still came back false even though it should have been true. When I tried to use the "get" button to see if I picked a wrong color or something, the color came back a completely different color, one which was certainly not the one being displayed on my screen. I tried this in DeSmuME as well, though with a different set of commands due to the differences in the way the emulators work, and this issue still happened, although I was able to get the keystrokes to control the game in the DeSmuME emulator. Here is the script I made for DeSmuME:

The command cannot use a delay for 11 seconds because the emulator speed fluctuates and is quite a bit slower than 11 seconds, so instead I made it repeat until the Turtwig was sent out, and if it was the normal color, it would repeat, and if it was not the normal color, it would check to see if it was the shiny color, and if it was, it would pause the emulation and cancel the macro.

I am mainly just confused on why the pixel command is giving me such blatantly wrong pixel colors. Does anyone have a solution to this or know why? I also would be very grateful if anyone had any knowledge on why it does not work in OpenEmu, and if/how I can make it work in OpenEmu, because it is just so much smoother than DeSmuME. I'd also be grateful if anyone could help me correct any errors I made in my scripts, because, as I mentioned earlier, I am very new to all of this.

Thanks!

I just came across this topic and since it looks like you didn’t get a response I'll take a stab at it.

I'm not familiar with that game but I do use OpenEmu (I love me some Legend of Zelda game boy games), and it does allow outside keystrokes in the macros I've built for it.

A couple of observations:

  1. Your keystroke commands in your OpenEmu macro aren't being sent directly to it like your DeSmuME macro... did you try configuring them that way to see if OpenEmu would respond to them?

  2. your pixel coordinates are absolute coordinates, which means the app window must be positioned in the exact same spot every single time. Even a slight movement of that window would likely cause the pixel condition to return false. So you might double check that your emulator window size and position stays the same BEFORE running that part of the macro, perhaps by using a manipulate a window action to ensure the following action looks in the right spot.

Just spitballing here...maybe you've already figured it out already since this was quite a few months ago.

-Chris