HOUSTON -- Several hours before the Astros hit the field Tuesday night to face the Royals, struggling stars and took early batting practice on the field, desperate to break out of their prolonged offensive downturns.

The Astros’ offense hasn’t been the same since Peña and Alvarez began slumping in early August, but the early work Tuesday appeared to pay off.

Peña homered in his first two at-bats and Alvarez added a two-run homer in the fifth -- his 39th of the season -- to send the Astros to a 4-2 win over the Royals at Daikin Park, snapping Houston’s three-game losing streak.

Since Aug. 3, Alvarez was slashing .242/.380/.383 with three homers prior to the Royals series, and Peña was slashing .170/.220/.298 with four home runs. They combined Tuesday for all four of the Astros’ hits and drove in all four runs.

"I think they're both trying to find rhythm, tempo in their swing, trying to get good pitches to hit,” Astros manager Joe Espada said prior to the game. “They were hitting off of the machine, just trying to play around with some barrel accuracy, trying to be more consistent with that, trying to get good pitches to hit.

"It’s something that we’ve been touching here the last couple of weeks," Espada added. "Nice to get [to] see those guys try to really focus on that and keep things simple.”

Astros starter Hunter Brown struck out 10 batters in five innings, allowing one run, two hits and three walks. Houston’s bullpen took it from there, retiring 12 of the 13 batters it faced. The only Royals batter to reach was Vinnie Pasquantino with a homer off Bennett Sousa in the sixth.

Peña crushed Royals starter Michael Wacha’s first pitch of the game over the left-field wall and hit a second homer to left field in the third to make it 2-0. Peña singled in the fifth inning and scored when Alvarez slammed a two-run homer to right field for a 4-1 lead.