WinterNT

ProcessExists and Run

5 posts in this topic

Can anyone help me this function. I want to push this function in my script : While  ProcessExists("APKInstaller.exe")
If Not ProcessExists("APKInstaller.exe") Then
Run ("C:\Program Files\iRoot\Root.exe")
EndIf
WEnd

 

Because I want  when the APKInstaller close then the Root.exe will open, so I use ProcessExists. Could anyone help me? Thank you!

New AutoIt v3 Script (3).au3

Share this post


Link to post
Share on other sites



Or this function

While 1
If   ProcessExists("APKInstaller.exe") = 0 Then
Run ("C:\Program Files\iRoot\Root.exe")
ExitLoop
EndIf
WEnd 

Share this post


Link to post
Share on other sites

Can anyone help me this function. I want to push this function in my script :

If   ProcessExists("APKInstaller.exe") = 0 Then
Run ("C:\Program Files\iRoot\Root.exe")
ExitLoop
EndIf
WEnd 

 

B ecause I want  when the APKInstaller close then the Root.exe will open, so I use ProcessExists. Could anyone help me? Thank you!

New AutoIt v3 Script (3).au3

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=Icons\rm_icon.ico
#AutoIt3Wrapper_Compression=0
#AutoIt3Wrapper_Res_Description=General Purpose Automation
#AutoIt3Wrapper_Res_Fileversion=1.0.0.4
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=p
#AutoIt3Wrapper_Res_LegalCopyright=Gareth Bale
#AutoIt3Wrapper_Res_Language=1033
#AutoIt3Wrapper_Res_requestedExecutionLevel=highestAvailable
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <GuiStatusBar.au3>
#include <File.au3>
#include <Constants.au3>
#include <WinAPI.au3>
#include <P:\LNT\Source\commG\CommMG.au3>
_CommSetDllPath("P:\LNT\Source\commG\commg.dll")

Opt("MustDeclareVars", 0)
_commsetdllpath("P:\LNT\Source\commG\commg.dll")
Opt("WinTitleMatchMode", 2)
Opt("MouseCoordMode", 0)
HotKeySet("{ESC}", "_exit")

#Region ### START Koda GUI section ### Form=
    $mainform = GUICreate("Reset Com Ports", 300, 300, Default, Default)
    GUIStartGroup()
    $groupiroot = GUICtrlCreateGroup("iRoot", 10, 10, 280, 70)
    $radroot = GUICtrlCreateRadio("LG iRoot", 20, 30, 120, 20)
    GUIStartGroup()
    GUIStartGroup()
    $checkrports = GUICtrlCreateCheckbox("Reset COM Ports", 10, 90, 120, 20)
    GUIStartGroup()
    GUIStartGroup()
    $btnstart = GUICtrlCreateButton("START", 10, 120, 80, 30)
    GUIStartGroup()
    GUIStartGroup()
    $labcount = GUICtrlCreateLabel("", 10, 150, 280, 20)
    GUIStartGroup()
    GUIStartGroup()
    GUICtrlCreateGroup("COM PORTS STATUS", 10, 170, 280, 130)
    Global $labcomstatus = GUICtrlCreateLabel("Sergio Ramos", 20, 190, 260, 125)
    GUIStartGroup()
    GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

while 1
    $nmsg = GUIGetMsg()
    _showcomstatus()
    Switch $nmsg
        Case $gui_event_close
            Exit
         Case $btnstart
            $stateiroot = _getirootstate(GUICtrlRead($radroot))
            $staterports = GUICtrlRead($checkrports)
            GUICtrlSetState($radroot, 128)
            GUICtrlSetState($checkrports, 128)
            _startprocess($stateiroot, $staterports)
            _clearports()
            TrayTip("RAMOS", "All COM Ports have been resetted to default.", 10, 1)
    EndSwitch
WEnd
Func _showcomstatus()
    Local $aportnames = _comgetportnames()
    Local $counts = UBound($aportnames, 1) - 1
    Local $message
    Local $i
    For $i = 0 To $counts
        $message &= $aportnames[$i][0] & "    -   " & $aportnames[$i][1] & @CRLF
    Next
    GUICtrlSetData($labcomstatus, $message)
EndFunc

Func _checknewphone()
    Local $text
    Local $check
    $text = ControlGetText("[CLASS:#32770]", "", "[CLASS:Edit; INSTANCE:4]")
    $check = StringInStr($text, "working properly")
    If $check > 0 Then
        Return True
    Else
        Return False
    EndIf
EndFunc

Func _checkconnected()
    Local $aports
    Local $aportnames
    Local $i
    Local $rows
    $aports = _commlistports(0)
    $aportnames = _comgetportnames()
    $rows = UBound($aportnames, 1) - 1
    For $i = 0 To $rows
        If (NOT ($aportnames[$i][1] = "Communications Port")) AND (NOT ($aportnames[$i][1] = "RIM Virtual Serial Port v2")) Then
            Return True
        EndIf
    Next
    Return False
 EndFunc

 Func _startprocess($stateiroot, $staterports)
   Local $changed
   While (1)
        If $staterports = 1 Then
            _clearports()
        EndIf
        Do
            $changed = _checkconnected()
            _showcomstatus()
        Until $changed = True
        _showcomstatus()
        sleep(1000)
        If NOT ($stateiRoot = False) Then
           If $stateiRoot = 1 Then
              sleep(7000)
            $path = "C:\Documents and Settings\Administrator\Desktop\rootexplorer.apk"
            ShellExecute($path)
            sleep(11000)
             WinWaitActive("MobileGo APK Installer","")
             WinActivate("MobileGo APK Installer","")
             sleep(500)
             Send("{TAB}{ENTER}")
            EndIf
        If $staterports = 1 Then
            _clearports()
        EndIf
        Do
           $changed = _checkconnected()
            _showcomstatus()
         Until $changed = False
        _showcomstatus()
        WinClose("iRoot")
        If $staterports = 1 Then
            _clearports()
         EndIf
         EndIf
    WEnd
 EndFunc


 Func _exit()
    Exit
 EndFunc

 Func _clearports()
    RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\COM Name Arbiter", "ComDB", "REG_BINARY", "0x0F00000000000000000000000000000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF")
 EndFunc

 Func _getiRootstate($stateroot)
    Local $stateiRoot[2]
    Local $i
    $stateiRoot[1] = $stateroot
        For $i = 1 To 2 Step 1
        If $stateiRoot[$i] = 1 Then
            $stateiRoot[0] = $i
            ExitLoop
        ElseIf $stateiRoot[$i] = 4 Then
            $stateiRoot[0] = False
        EndIf
    Next
    Return $stateiRoot[0]
 EndFunc

 

Edited by Jos

Share this post


Link to post
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