• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 15:36
CET 20:36
KST 04:36
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
ByuL: The Forgotten Master of ZvT30Behind the Blue - Team Liquid History Book19Clem wins HomeStory Cup 289HomeStory Cup 28 - Info & Preview13Rongyi Cup S3 - Preview & Info8
Community News
Weekly Cups (March 9-15): herO, Clem, ByuN win02026 KungFu Cup Announcement5BGE Stara Zagora 2026 cancelled12Blizzard Classic Cup - Tastosis announced as captains17Weekly Cups (March 2-8): ByuN overcomes PvT block4
StarCraft 2
General
Potential Updates Coming to the SC2 CN Server Blizzard Classic Cup - Tastosis announced as captains Weekly Cups (March 9-15): herO, Clem, ByuN win GSL CK - New online series BGE Stara Zagora 2026 cancelled
Tourneys
2026 KungFu Cup Announcement [GSL CK] #2: Team Classic vs. Team Solar [GSL CK] #1: Team Maru vs. Team herO RSL Season 4 announced for March-April PIG STY FESTIVAL 7.0! (19 Feb - 1 Mar)
Strategy
Custom Maps
Publishing has been re-enabled! [Feb 24th 2026] Map Editor closed ?
External Content
The PondCast: SC2 News & Results Mutation # 517 Distant Threat Mutation # 516 Specter of Death Mutation # 515 Together Forever
Brood War
General
ASL21 General Discussion BGH Auto Balance -> http://bghmmr.eu/ Gypsy to Korea BSL 22 Map Contest — Submissions OPEN to March 10 Are you ready for ASL 21? Hype VIDEO
Tourneys
ASL Season 21 Qualifiers March 7-8 [Megathread] Daily Proleagues [BSL22] Open Qualifiers & Ladder Tours IPSL Spring 2026 is here!
Strategy
Simple Questions, Simple Answers Soma's 9 hatch build from ASL Game 2 Fighting Spirit mining rates Zealot bombing is no longer popular?
Other Games
General Games
Stormgate/Frost Giant Megathread Dawn of War IV Path of Exile Nintendo Switch Thread PC Games Sales Thread
Dota 2
Official 'what is Dota anymore' discussion The Story of Wings Gaming
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Five o'clock TL Mafia Mafia Game Mode Feedback/Ideas Vanilla Mini Mafia TL Mafia Community Thread
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Mexico's Drug War Russo-Ukrainian War Thread NASA and the Private Sector
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Manga] One Piece Movie Discussion! [Req][Books] Good Fantasy/SciFi books
Sports
2024 - 2026 Football Thread Tokyo Olympics 2021 Thread Formula 1 Discussion General nutrition recommendations Cricket [SPORT]
World Cup 2022
Tech Support
Laptop capable of using Photoshop Lightroom?
TL Community
The Automated Ban List
Blogs
Funny Nicknames
LUCKY_NOOB
Money Laundering In Video Ga…
TrAiDoS
Iranian anarchists: organize…
XenOsky
FS++
Kraekkling
Shocked by a laser…
Spydermine0240
Unintentional protectionism…
Uldridge
ASL S21 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2129 users

An Automatic SC2 Game Start Switcher - Page 2

Forum Index > SC2 General
Post a Reply
Prev 1 2 All
Vallz
Profile Joined March 2011
41 Posts
Last Edited: 2013-02-27 16:32:58
February 27 2013 16:28 GMT
#21
As far as I know Warden does not care if you read the process memory from Sc2 (since already some acknowledged tools uses it), might aswell find the memory address which indicates that you're ingame(fully in the game), that way you can do it much cleaner.


tehemperorer
Profile Blog Joined June 2010
United States2183 Posts
Last Edited: 2013-02-27 16:49:25
February 27 2013 16:44 GMT
#22
Hey Zamiel, cool work... I refactored it a little for you according to my own little professional guidelines I do have a few questions though, if you don't mind!
1. Why the multiple s = reader.readLine();? You have 3, which means I think that only the last readLine() is actually stored. Wasn't sure if you were trying to do a StringBuilder.append kinda thing or not
2. You spawn a lot of threads, not sure if it's necessary... Main is a thread, then you invoke an anonymous Runnable (another thread), which then spawns a new thread every time Runtime.getRuntime().exec(command) is read. Check back over those!
3. There are other ways of course to do things. One of which could be taking a few command line arg into main and using those as the values that drive the program.

Here is the refactored code!
+ Show Spoiler +

/* Created by Zamiel on Feb. 26, 2013 */

import javax.swing.*;
import java.io.*;

public class SC2GameStartSwitcher {
private static void createAndShowGUI() {
//Create and set up the window.
JFrame frame = new JFrame("StarCraft II Automatic Game Start Switcher");
JLabel label = new JLabel("Detecting SC2 game starts. Feel free to minimize this window.");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(label);
frame.setSize(500,100);
frame.setVisible(true);
}

public static int getStartModule() { // returns 0 if not in a game, 1 if in a game
String s = getValue("reg query HKCU\\Software\\Razer\\Starcraft2 /v StartModule");
if (s.contains("0x1")){
return 1;
} else if (s.contains("0x0")){
return 0;
} else {
return -1;
}
}

public static int getAPMValue() {
String[] splits = getValue("reg query HKCU\\Software\\Razer\\Starcraft2 /v APMValue").split(" ");
return Integer.parseInt(splits[12]);
}

public static Process execute(String command){
try {
return Runtime.getRuntime().exec(command);
} catch (IOException e) {
e.printStackTrace();
return null;
}
}

public static String getValue(String regValue){
try {
Process p = execute(regValue);
p.waitFor();
java.io.InputStream is = p.getInputStream();
java.io.BufferedReader reader = new java.io.BufferedReader(new InputStreamReader(is));
String s = null;
s = reader.readLine();
s = reader.readLine();
s = reader.readLine();
is.close();
return s;
} catch (Exception e){
return null;
}
}

public static void main(String[] args) {
int gameState = 0;

//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});

while (true) { // run forever
try {
Thread.sleep(10); // pause for 10 milliseconds
}
catch (InterruptedException E) {
Thread.currentThread().interrupt();
}
switch (gameState){
case 0: // not in a game
if (getStartModule() == 1) { // we are now loading the game
gameState = 1;
}
if (getAPMValue() != 1000) { // set the current APM to an arbitrary value so that we can detect a change once the game starts
execute("reg add HKCU\\Software\\Razer\\Starcraft2 /v APMValue /d 1000 /f");
}
case 1:
if (getAPMValue() != 1000) { // the APM has changed which means that loading is done
execute("wscript activateSC2.vbs");
gameState = 2;
}
case 2: // we are playing a game
if (getStartModule() == 0) { // we have left the game
gameState = 0;
}
}
}
}
}


EDIT: aww, all formatting was lost!
Knowing is half the battle... the other half is lasers.
ACrow
Profile Joined October 2011
Germany6583 Posts
February 27 2013 16:53 GMT
#23
I'm confused, the standard behavior of the game is to come to foreground when loading starts?
Is this just to shave off the approx. 10secs of loading screen?
Anyhow, if this helps people, props to you, nice that you're trying to help out!
Get off my lawn, young punks
Dingodile
Profile Joined December 2011
4139 Posts
February 27 2013 16:59 GMT
#24
I dont think we need this in HotS. Everything is silent during the matchmaking and after you found an opponont the loading screen make a loud music like a shock for my ears, is just too loud for me.
Grubby | ToD | Moon | Lyn | Sky
ECA.BruTATroN
Profile Blog Joined August 2010
United States282 Posts
February 27 2013 17:04 GMT
#25
or you can just turn on sounds for sc2 in windows..
http://www.twitch.tv/brutatron
skeldark
Profile Joined April 2010
Germany2223 Posts
Last Edited: 2013-02-27 17:19:35
February 27 2013 17:07 GMT
#26
It does break the TOS!
The TOS dont talk about Ram or registry. It says you are not allowed to collect information about the game.
So it makes no diffrence if you read the ram, read the registry, open the sc2 folder, install the game or play the game.
Its all against the TOS.
TLDR: Blizzard TOS is not worth the bytes it is saved in.

btw you dont have to watch for a change in the apm entry (if you really do that)
there is an "ingame" entry in the reg folder.

Save gaming: kill esport
Godwrath
Profile Joined August 2012
Spain10139 Posts
Last Edited: 2013-02-27 17:10:14
February 27 2013 17:09 GMT
#27
I don't know, the game always had tabbed in automatically when it starts loading. Only reason to use this program is if you actually tab out outside the loading, or for some people it doesn't work the same way it does for me ?
Zamiel
Profile Blog Joined August 2008
United States211 Posts
Last Edited: 2013-02-28 06:31:58
February 27 2013 19:07 GMT
#28
tehemperorer, I appreciate the suggestions, but as you can see from a few posts back, I've already completely rewritten the program in C#, which has subsequently made it a lot cleaner. (I haven't updated the OP yet. I guess I'll do that now.)

All of the other posts contain criticisms or questions that are already addressed earlier in the thread.
"Mech is at the store buying groceries and you attack him at home. You burn his house down. And then he comes home and puts out the fire, and then you burn down the grocery store so he can't buy more groceries."
tehemperorer
Profile Blog Joined June 2010
United States2183 Posts
February 27 2013 19:37 GMT
#29
On February 28 2013 04:07 Zamiel wrote:
tehemperorer, I appreciate the suggestions, but as you can see from a few posts back, I've already completely rewritten the program in C#, which has subsequently made it a lot cleaner. (I haven't updated the OP yet. I guess I'll do that now.

All of the other posts contain criticisms or questions that are already addressed earlier in the thread.

Cool man!
Knowing is half the battle... the other half is lasers.
Zamiel
Profile Blog Joined August 2008
United States211 Posts
February 28 2013 06:29 GMT
#30
Ok, I updated the OP with the C# code and uploaded a new executable to mega.

I didn't bother to make a GUI for it, since its not really necessary, and well, I don't know how. =p

Enjoy!
"Mech is at the store buying groceries and you attack him at home. You burn his house down. And then he comes home and puts out the fire, and then you burn down the grocery store so he can't buy more groceries."
Snoodles
Profile Joined March 2012
401 Posts
February 28 2013 06:52 GMT
#31
This used to bug the hell out of me. My problems were solved when I got a 2nd and 3rd monitor. I have one dedicated to sc2 and browse between games or play streams or open build order guides on the other two.
Prev 1 2 All
Please log in or register to reply.
Live Events Refresh
Monday Night Weeklies
17:00
#44
SteadfastSC432
TKL 340
IndyStarCraft 206
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
mouzHeroMarine 439
SteadfastSC 432
TKL 340
IndyStarCraft 206
elazer 191
UpATreeSC 110
Livibee 80
JuggernautJason79
StarCraft: Brood War
sorry 67
NotJumperer 52
Rock 27
Dota 2
qojqva4518
monkeys_forever235
canceldota102
League of Legends
JimRising 431
Counter-Strike
tarik_tv4283
pashabiceps2260
fl0m1568
Heroes of the Storm
MindelVK15
Other Games
Grubby2605
Beastyqt695
ceh9512
ToD206
ArmadaUGS176
C9.Mang0110
Trikslyr49
Mew2King40
QueenE33
Organizations
Dota 2
PGL Dota 2 - Main Stream552
Other Games
BasetradeTV173
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 18 non-featured ]
StarCraft 2
• kabyraGe 186
• Reevou 2
• Kozan
• IndyKCrew
• sooper7s
• Migwel
• AfreecaTV YouTube
• LaughNgamezSOOP
• intothetv
StarCraft: Brood War
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
League of Legends
• Doublelift3204
• Jankos2296
• Scarra443
• TFBlade434
Other Games
• imaqtpie1142
• Shiphtur166
Upcoming Events
WardiTV Team League
16h 24m
PiGosaur Cup
1d 4h
Kung Fu Cup
1d 15h
OSC
2 days
The PondCast
2 days
KCM Race Survival
2 days
WardiTV Team League
2 days
Replay Cast
3 days
KCM Race Survival
3 days
WardiTV Team League
3 days
[ Show More ]
Korean StarCraft League
4 days
RSL Revival
4 days
Maru vs Zoun
Cure vs ByuN
uThermal 2v2 Circuit
4 days
BSL
5 days
RSL Revival
5 days
herO vs MaxPax
Rogue vs TriGGeR
BSL
6 days
Replay Cast
6 days
Replay Cast
6 days
Afreeca Starleague
6 days
Sharp vs Scan
Rain vs Mong
Wardi Open
6 days
Monday Night Weeklies
6 days
Liquipedia Results

Completed

Proleague 2026-03-15
WardiTV Winter 2026
Underdog Cup #3

Ongoing

KCM Race Survival 2026 Season 1
Jeongseon Sooper Cup
BSL Season 22
CSL Elite League 2026
RSL Revival: Season 4
Nations Cup 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual

Upcoming

ASL Season 21
Acropolis #4 - TS6
2026 Changsha Offline CUP
Acropolis #4
IPSL Spring 2026
BSL 22 Non-Korean Championship
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
NationLESS Cup
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.