Jump to content
Sign in to follow this  
gil900

Help with if else if

Recommended Posts

gil900

Hello.

I tried to create this:

Local $var, $start
$p1 = IniRead(@WorkingDir & "\settings.ini", "proseseswait", "p1", "x.exe")
$p2 = IniRead(@WorkingDir & "\settings.ini", "proseseswait", "p2", "x.exe")
$p3 = IniRead(@WorkingDir & "\settings.ini", "proseseswait", "p3", "x.exe")
$p4 = IniRead(@WorkingDir & "\settings.ini", "proseseswait", "p4", "x.exe")
$p5 = IniRead(@WorkingDir & "\settings.ini", "proseseswait", "p5", "x.exe")
$p6 = IniRead(@WorkingDir & "\settings.ini", "proseseswait", "p6", "x.exe")
$p7 = IniRead(@WorkingDir & "\settings.ini", "proseseswait", "p7", "x.exe")
$p8 = IniRead(@WorkingDir & "\settings.ini", "proseseswait", "p8", "x.exe")
$p9 = IniRead(@WorkingDir & "\settings.ini", "proseseswait", "p9", "x.exe")
$p10 = IniRead(@WorkingDir & "\settings.ini", "proseseswait", "p10", "x.exe")
HotKeySet("{F7}", "test1")
HotKeySet("{F8}", "test2")
HotKeySet("{F9}", "test3")
$SP1 = ProcessWait($p1)
$SP2 = ProcessWait($p2)
$SP3 = ProcessWait($p3)
$begin = TimerInit()
If ProcessWait($p1) Then
    MsgBox(4096,"", "Value is positive.")
ElseIf  ProcessWait($p2) Then
    MsgBox(4096,"", "Value is negative.")
EndIf

But the problem is that the script responds only to the "if" and not to "ElseIf".

I need all the "if"/"ElseIf" will work ..

Thanks.

Edited by gil900

Share this post


Link to post
Share on other sites
JohnOne

your elseif will never be true

1) you have this

$SP1 = ProcessWait($p1) ; It waits for it to exist

then you have this

If ProcessWait($p1) Then ; This exists or your script would not get this far

MsgBox(4096,"", "Value is positive.")

ElseIf ProcessWait($p2) Then ;So this will never be true.

MsgBox(4096,"", "Value is negative.")

EndIf

I think you best explain what it is you are trying to accomplish


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
Melba23

gil900,

Your code makes no sense. :mellow:

ProcessWait will pause the script until the specified process is running, so you will never get to your If structure until all 3 processes exist. And so there is no chance of the If failing as the process had to exist in order to get that far! :)

Can you explain what you are trying to do? Perhaps then we can offer some advice on how to structure your code. :)

M23

Edit: Evening JohnOne - I am off to dinner, it is all yours! :)

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
bogQ

i think hes trying this but im not shure

Do
    Sleep(10)
Until ProcessExists($p1) Or ProcessExists($p2) Or ProcessExists($p3) Or ...

and if he need aditional data he can do it like this

Do
    Sleep(10)
    $1 = ProcessExists($p1)
    $2 = ProcessExists($p2)
    $3 = ProcessExists($p3)
Until $1 Or $2 Or $3 Or ...
Select
    Case $1
        MsgBox(4096,"1", "Value is positive.")

    Case $2
        MsgBox(4096,"2", "Value is positive.")

    Case $3
        MsgBox(4096,"3", "Value is positive.")

    Case ...

EndSelect

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites
gil900

Part of the code:

There is a INI file which has a number of processes.

* I need that script will count how many seconds it takes to process (found in the INI) fully loaded. The same applied to other processes in the INI file.

Ultimately need the code will write another part of the INI file the number of seconds(ms) related to any process.

For example:

[example]

flashget.exe=5000

vlc.exe=1000

firefox.exe=10000

Edited by gil900

Share this post


Link to post
Share on other sites
JohnOne

Not tested this, but in my head it would look similar to this.

$aSection = IniReadSection("my.ini","example")
If @error Then Exit
For $i = 1 To $aSection[0][0];process name
    $Timer = TimerInit();set timer
    $Pid = Run($aSection[$i][0]);run process
    ProcessWait($Pid);wait for process 
    $Timerdiff = TimerDiff($Timer);Get time
    IniWrite("my.ini","example",$aSection[$i][1],$Timerdiff);write time to ini
    ProcessClose($Pid);close process
Next

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
gil900

Thank you.

I changed to this:

$aSection = IniReadSection("settings.ini","proseseswait")
If @error Then Exit
For $i = 1 To $aSection[0][0];process name
    $Timer = TimerInit();set timer
    $Pid = IniRead("settings.ini", "proseseswait", $aSection[$i][0], "x.exe")
    ProcessWait($Pid);wait for process 
    $Timerdiff = TimerDiff($Timer);Get time
    IniWrite("my.ini","example",$aSection[$i][1],$Timerdiff);write time to ini
Next

It's going to be part of something

Edited by gil900

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
Sign in to follow this  

×