Jump to content

Kill an .exe and make sure its not running anymore


Recommended Posts

Hi there,

So I have created an autoit script (noob here, just started using it since yesterday) which grabs the hardware id from the "James Cameron's Avatar The Game" activation wizard, pastes it into the keygen, gets the activation key from the keygen and pastes it back to the activation wizard.

Now the problem is that if you click "Next >" after having pasted the activation key, the Game starts and I want to close it, so that I can start if from a Game Loader.

Here's my code:

Run("D:\Program Files\James Cameron's AVATAR - THE GAME\bin\Avatar.exe") // Run the main executable
WinWait("Activation Wizard", "", 5) // Wait 5 seconds to see if the activation wizard pops up
If WinExists("Activation Wizard") Then // If it does then ...
WinActivate ( "Activation Wizard" ) // ... bring it to the front
ControlClick( "Activation Wizard", "", "[CLASSNN:TTntButton.UnicodeClass4]" ) // Click "Next"
ControlCommand( "Activation Wizard", "Manual", "[CLASS:TTntRadioButton.UnicodeClass; INSTANCE:2]", "Check", "" ) // Check the "Manual" option
ControlClick( "Activation Wizard", "", "[CLASSNN:TTntButton.UnicodeClass4]" ) // Click "Next"
$hardware_id = ControlGetText( "Activation Wizard", "", "[CLASSNN:TTntEdit.UnicodeClass1]" ) // Assign a hardware_id
Run("Z:\game_tools\avatar\keygen.exe") // Run the keygen
WinWait("James Cameron's AVATAR™ Offline Activation Keygen - RELOADED") // Wait until it has loaded
WinActivate("James Cameron's AVATAR™ Offline Activation Keygen - RELOADED") // Bring it to the front
ControlSetText( "James Cameron's AVATAR™ Offline Activation Keygen - RELOADED", "", "[CLASSNN:Edit1]", $hardware_id ) // Paste the hardware_id
ControlClick( "James Cameron's AVATAR™ Offline Activation Keygen - RELOADED", "Generate", "[CLASSNN:Button1]" ) // Click "Generate"
$activation_key = ControlGetText( "James Cameron's AVATAR™ Offline Activation Keygen - RELOADED", "", "[CLASSNN:Edit2]" ) // Get the activation_key
WinClose("James Cameron's AVATAR™ Offline Activation Keygen - RELOADED") // Close the keygen
WinActivate ( "Activation Wizard" ) // Bring the activator to the front
ControlSetText ("Activation Wizard", "", "[CLASSNN:TTntEdit.UnicodeClass3]", $activation_key ) // Paste the activation_key
ControlClick ("Activation Wizard", "Next >", "[CLASSNN:TTntButton.UnicodeClass4]" ) // Click "Next"
// Now from this point on, right after clicking Next, the Game starts loading into D3D mode. 
// What I want is to kill "avatar.exe", be sure that its not running any more, and then End the script.
// I tried the following, but with no luck... :(
WinWait("Activation Wizard") // Also tried without this...
ProcessClose("Avatar.exe")
ProcessWait("Avatar.exe")
EndIf
// I used an If / EndIf statement so that the script does not load, if the Activation Wizard does not popup.
Exit

So... any ideas on how to kill avatar.exe after the script has clicked Next, and be SURE that it's not running anymore, BEFORE the script ends?

Thanks a lot!

Link to comment
Share on other sites

ProcessClose("Avatar.exe")

ProcessWait("Avatar.exe")

Did you really think that through? :mellow:

You should at least do a ProcessWait before :( the ProcessClose, to make sure that Avatar.exe has had time to start.

And what's the point with waiting for a process to exist after you have tried to close it? You want ProcessWaitClose, or as picea showed, a loop with ProcessExists.

ProcessWait("Notepad.exe")
ProcessClose("Notepad.exe")
ProcessWaitClose("Notepad.exe")

Or for fun:

Do
    Sleep(100)
Until ProcessExists("Notepad.exe")

ProcessClose("Notepad.exe")

While ProcessExists("Notepad.exe")  ;Two kinds of loops in the same script? Oh no! :P
    sleep(100)
WEnd
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...