Jump to content

Recommended Posts

Posted

@mentosan

Hi

I want to setup a condition in my au3 script based on a running Windows process (which i see it in Task Manager).

Any ideas ?

Thx

I dont understand your question, can you post some examples ?

Cheers, FireFox.

Posted (edited)

I'm making a script which sends keys to a command prompt window. I want to insert a condition: the keys will be send only when cmd.exe is present in Task Manager.

Edited by mentosan
Posted

@mentosan

Opt("WinTitleMatchMode", 2)

While 1
    If ProcessExists("cmd.exe") Then
        If WinActive("cmd.exe") Then
            ; do stuff
            Send("test / ")
            TrayTip("WinActive", "cmd.exe process is running !", 0, 1)
        Else
            TrayTip("WinUnactive", "cmd.exe process is running !", 0, 1)
            WinActivate("cmd.exe")
        EndIf
    Else
        TrayTip("test", "cmd.exe process isnt running !", 0, 1)
    EndIf
    Sleep(20)
WEnd

Cheers, FireFox.

Posted

Hello! I'm back again with one more wish.

Here is a part of my code:

CODE

If ProcessExists("cmd.exe") Then

WinActivate("cmd")

WinWaitActive("cmd")

While 1

Send("{ESC}")

ControlSend ("cmd","","",$callnumber[1] & "{Enter}")

Sleep ($timer[1])

WEnd

Else

TrayTip("Command prompt inactive", "Please launch the application", 0, 1)

EndIf

Sleep(7000)

The problem is ,because $timer (which will read from a txt file) is a very high value (like 30 minutes=1800000miliseconds) I must wait all this period until loop will start again. If in the meantime the process "cmd.exe" is started, the script will still wait for this counter. I want to keep the $timer counter and to modify somehow the code that if process "cmd.exe" is started (let's say manually) the script will start to loop from beginning.

I hope I'm clear in my state above, sorry because I'm not native english.

Posted

If ProcessExists("cmd.exe") Then

WinActivate("cmd")

WinWaitActive("cmd")

While 1

If ProcessExists("cmd.exe") Then Exitloop

Send("{ESC}")

ControlSend ("cmd","","",$callnumber[1] & "{Enter}")

Sleep ($timer[1])

WEnd

Else

TrayTip("Command prompt inactive", "Please launch the application", 0, 1)

EndIf

Sleep(7000)

Giggity

Posted (edited)

If ProcessExists("cmd.exe") Then

WinActivate("cmd")

WinWaitActive("cmd")

While 1

If ProcessExists("cmd.exe") Then Exitloop

Send("{ESC}")

ControlSend ("cmd","","",$callnumber[1] & "{Enter}")

Sleep ($timer[1])

WEnd

Else

TrayTip("Command prompt inactive", "Please launch the application", 0, 1)

EndIf

Sleep(7000)

Hi !

It's is not ok. It is OK if this command would exist :

CODE

If ProcessExists("cmd.exe") Then

WinActivate("cmd")

WinWaitActive("cmd")

While 1

If ProcessExists("cmd.exe") Then Exitloop

Send("{ESC}")

ControlSend ("cmd","","",$callnumber[1] & "{Enter}")

If ProcessNOTExists("cmd.exe") Then Exitloop

Sleep ($timer[1])

WEnd

Else

TrayTip("Command prompt inactive", "Please launch the application", 0, 1)

EndIf

Sleep(7000)

Edited by mentosan
Posted (edited)

Ah it was a miss wording in your phrasing

If ProcessExists("cmd.exe") Then
WinActivate("cmd")
WinWaitActive("cmd")

While 1
Send("{ESC}")
ControlSend ("cmd","","",$callnumber[1] & "{Enter}")
If not ProcessExists("cmd.exe") Then Exitloop
Sleep ($timer[1])
WEnd

Else
TrayTip("Command prompt inactive", "Please launch the application", 0, 1)
EndIf
Sleep(7000)

and to give you a "why didn't I think of that?" moment

If ProcessExists("cmd.exe") Then 
else
Exitloop
endif
Edited by youknowwho4eva

Giggity

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...