Jump to content

Recommended Posts

Posted

I have entered the following command within my script

Local $iPID = RunWait("AXIOMProcess.exe","C:\Program Files\Magnet Forensics\Magnet AXIOM\AXIOM Process",SW_MAXIMIZE)

The program fails to start and the PID value is returned as 0

However if I open a command line and navigate to the required directory, I can manually execute the program.  I have managed to get the script to work using this method, but then have trouble getting the AXIOMProcess window to get focus so I can interact with it, any ideas why the runwait command fails to fire the executable?

  • Developers
Posted (edited)

Try changing the first parameter to contain the path to the exe as well.

Local $iPID = RunWait("C:\Program Files\Magnet Forensics\Magnet AXIOM\AXIOM Process\AXIOMProcess.exe","C:\Program Files\Magnet Forensics\Magnet AXIOM\AXIOM Process",SW_MAXIMIZE)

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted
19 minutes ago, ColinL said:

The program fails to start and the PID value is returned as 0

RunWait doesn't return a PID, it returns the ExitCode of the program. 

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted
3 hours ago, BrewManNH said:

RunWait doesn't return a PID, it returns the ExitCode of the program. 

In which case, check the help file for RunWait...

Quote

Some programs will appear to return immediately even though they are still running; these programs spawn another process - you may be able to use the ProcessWaitClose() function to handle these cases.

(You might need to use a different process name than AXIOMProcess.exe, check and see what processes are running.)

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Posted

So I have changed the command to

Local $iPID = RunWait("C:\Program Files\Magnet Forensics\Magnet AXIOM\AXIOM Process\AXIOMProcess.exe","C:\Program Files\Magnet Forensics\Magnet AXIOM\AXIOM Process",SW_MAXIMIZE)

but the program still fails to start, the script just ends

Posted

So I have tried 64bit, and indeed compiling it as well, but the command still fails.

The following commands do work although I am not sure if this is the right way to do it

Run("cmd.exe")
WinWaitActive("C:\WINDOWS\SYSTEM32\cmd.exe")
Send("cd c:\Program Files\Magnet Forensics\Magnet AXIOM\AXIOM Process^M")
Send("AXIOMProcess.exe^M")

 

If this a way of starting the application, how do I ensure the application has focus, ready to accept other command etc.

  • Developers
Posted

Ok, lets try it this way:

  • Please install the full SciTE4Autoit3 installer before testing the next code to support the directive for x64.
  • open SciTE and copy/pas this code:
  • #AutoIt3Wrapper_UseX64=y
    Local $rc = RunWait("C:\Program Files\Magnet Forensics\Magnet AXIOM\AXIOM Process\AXIOMProcess.exe","C:\Program Files\Magnet Forensics\Magnet AXIOM\AXIOM Process",@SW_MAXIMIZE)
    MsgBox(262144, 'Debug line ~' & @ScriptLineNumber, 'Selection:' & @CRLF & '$rc' & @CRLF & @CRLF & 'Return:' & @CRLF & $rc) ;### Debug MSGBOX
    Local $rc = ShellExecute("C:\Program Files\Magnet Forensics\Magnet AXIOM\AXIOM Process\AXIOMProcess.exe", "", "C:\Program Files\Magnet Forensics\Magnet AXIOM\AXIOM Process")
    MsgBox(262144, 'Debug line ~' & @ScriptLineNumber, 'Selection:' & @CRLF & '$rc' & @CRLF & @CRLF & 'Return:' & @CRLF & $rc) ;### Debug MSGBOX
  • Press F5 to run the code. It will first try the run() command and give you the RC and possible ERROR returned in a MSGBOX.
  • Close the MSGBOX and it will perform a ShellExecute for the same program and show again a result MSGBOX.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

Yes and I have placed it in my main script, please take a pound out of the till,  Will this program automatically have the focus or do I have to switch to it somehow?

  • Developers
Posted (edited)

Nice. 

26 minutes ago, ColinL said:

Will this program automatically have the focus or do I have to switch to it somehow?

I can't tell you and will be a matter of testing it. in case it doesn't you could use something like:

Local $pid = ShellExecute("C:\Program Files\Magnet Forensics\Magnet AXIOM\AXIOM Process\AXIOMProcess.exe", "", "C:\Program Files\Magnet Forensics\Magnet AXIOM\AXIOM Process","",@SW_MAXIMIZE)
; wait for program to start
Winwait("put-in-here-the-exact-title","")
; set focus to program window
WinActivate("put-in-here-the-exact-title","")
; loop as long as program is active
While ProcessExists($pid)
    sleep(10)
WEnd

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

So I added the shell command, and used the WinGetTitle command to ensure I am referencing the correct window, and the program reports it is the active window by using

Local $Test = WinGetTitle("[ACTIVE]")

I then try and send a tab command to move the focus onto a different control within the application, but nothing happens, the application does not respond to the script, but if I manually press tab on the keyboard once it has started, it responds, I am wondering if the script really does not have control of the application, sorry to be pain

Posted

Strangely enough MouseMove command also fails to move the mouse while the program appears to have the focus.  I placed MouseMove in its own script, and it works fine.

Posted

Here is the code

Func AxiomProcess()
      Local $Axiom = ShellExecute("C:\Program Files\Magnet Forensics\Magnet AXIOM\AXIOM Process\AXIOMProcess.exe", "", "C:\Program Files\Magnet Forensics\Magnet AXIOM\AXIOM Process")
      Sleep(60000); Give AXIOM time to startup and check license, also ensure option to disable anti-virus is set as a default and not to reappear
      WinActive("Magnet AXIOM Process 2.10.1.13273- Checking License")
      MouseMove(10,10)
         Send("{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}")
      Local $sText = WinGetTitle("[ACTIVE]")
      MsgBox($MB_SYSTEMMODAL,"Title",$sText)
   EndFunc

 

It doesn't respond to the mouse move or accept the tabs being sent.

Mouse move in its own script works fine.

The msgbox displays the correct name of the current active window.

  • Developers
Posted

So Does the program run with the same level as the script or does it require Admin rights?
Have you tried running the script as Administrator so see if that makes any difference?
Just to ensure we are clear:

  • You wait 1 minute after the program has started before the script continues.
  • The mouseMove() only moves the mousepointer to 10,10  and doesn't select any control that might be there.
  • It is always better to use ControlSend() and have the text send to the appropriate Window/Control. Use au3info.exe to find the details about the field.

Jos


 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

Have compiled the script and ran as administrator, but still doesn't respond to commands

Yes, the mouse just supposed to move top left and not select anything

As I move the mouse around, with au3info.exe running, standard windows controls are updated within the Info window.  Any control I select from the AXIOM application does not update the info window

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
×
×
  • Create New...