Sign in to follow this  
Followers 0
c4mpi

Func sequence

10 posts in this topic

Is it anyway I can make a sequence for a code

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
        If GuiCTRLRead ($Checkbox1) = $GUI_CHECKED Then Run("Notepad.exe")
        If GuiCTRLRead ($Checkbox2) = $GUI_CHECKED Then Run("Notepad.exe")
        If GuiCTRLRead ($Checkbox3) = $GUI_CHECKED Then Run("Notepad.exe")
        If GuiCTRLRead ($Checkbox4) = $GUI_CHECKED Then Run("Notepad.exe")
        GUIDelete()
WEnd

without stopping the script using sleep ex?

I need it to execute notepad.exe

then wait till its done and move on to the next notepad.exe

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

To clarify: you want to:

1: Run Notepad

2: Have the user do something or do something by script

3: Have the user/script close notepad

4: Run the next instance of notepad

Do I have that right?

Edit: You don't want to use sleep to wait until steps 1-4 are done, right?

Edited by Fulano

#fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Okey

1. The user checks the checkboxes

2. The script picks out the ($CheckboxX) = $GUI_CHECKED Then Run("thiscanbeeverything.exe")(may be more then one) that the user has choosed.

3. It loops it in order or in a sequence, WITHOUT using sleep because in the Run("thiscanbeeverything.exe") it may be big bunshes of codes

Like this if I checked checkbox 1 and 2 I want it to do run notepad and make an ie in this order

1. notepad

send("randomtext")

2. _IEcreate

_IEnavigate("randomsite")

Do("randomstuffs")

Edited by c4mpi

Share this post


Link to post
Share on other sites

To clarify:

thiscanbeeverything.exe, etc are external programs, not AutoIt functions.

Does it matter if one step is going on in the background while another starts?


#fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!

Share this post


Link to post
Share on other sites

To clarify:

thiscanbeeverything.exe, etc are external programs, not AutoIt functions.

Does it matter if one step is going on in the background while another starts?

Thiscanbeeverything.exe can be all scripts in the world, doesnt matter at all...

Yes it matters because it runs on the same _IEcreateembedd

Share this post


Link to post
Share on other sites

Ok, so this is how I understand it:

GUI <- This has an IE Object Imbedded in it, and 4 checkboxes

Each checkbox calls an external program, which automates the IE Object Imbedded in the GUI.

Total programs: 5, all of which interact with the IE Object embedded in the GUI

Is this correct?


#fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!

Share this post


Link to post
Share on other sites

Ok, so this is how I understand it:

GUI <- This has an IE Object Imbedded in it, and 4 checkboxes

Each checkbox calls an external program, which automates the IE Object Imbedded in the GUI.

Total programs: 5, all of which interact with the IE Object embedded in the GUI

Is this correct?

It doesnt have to be a external program, but in this case yes

Share this post


Link to post
Share on other sites

Ok, so for an external program you're going to need to look at the Process* functions, particularly ProcessWaitClose().

It'll probably look something like this:

WARNING: RAW, UNDEBUGGED CODE: PROBABLY WILL NOT COMPILE


Local $pid = Run ("Notepad.exe") ;Call process


If not $ProcessWait($pid, 120) Then <do failure handling for Notepad not opening> ;Make sure it opens


$ProcessWaitClose ($pid) ;Wait, possibly forever, for it to no longer exist
In the case where scripts are called, I'd personally use #include <scriptName> and call the functions directly, which sidesteps the need for any sort of wait.

#fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!

Share this post


Link to post
Share on other sites

You could do something like this if I understood your request correctly.

Global $Apps[4] = ["Notepad.exe","Notepad.exe", "Notepad.exe","Notepad.exe"]; or whatever the apps are

Global $iPID = 0, $NumApps = 4, $sequence = 0, $runlist

Global $chkBox[$NumApps]
For $n = 0 To $NumApps - 1
    $chkBox[$n] = GUICtrlCreateCheckbox("app1", 20, 50 + $n * 30);position as required
Next

AdlibRegister("nextRun", 2000)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
            if $iPID = 0 or Not ProcessExists($iPID) then
    $list = ''
    For $n = 0 To $NumApps - 1
    If GUICtrlRead($chkBox[$n]) = $GUI_CHECKED Then $list &= $App[$n] & '|'
    Next
    $runlist = StringSplit(StringTrimRight($runlist, 1))
    $sequence = 1; start with th efirst app
        Else
            msgbox(262144,"ERROR", "Cannot start the sequence until" & @CRLF & " the last sequence has finished")
        EndIf
        
    EndSwitch


WEnd

GUIDelete()


Func NextRun()
    If $sequence = 0 Then Return
    If $iPID <> 0 Then
    If ProcessExists($iPID) Then Return
    EndIf
    $iPID = Run($runlist[$sequence])
    $sequence += 1
    If $sequence > $NumApps Then $sequence = 0

EndFunc ;==>NextRun

Not tested, just a suggestion.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Most functions have a return value after they are complete (not all)

This can also work for any function you create yourself

If I understand you correctly, you just need to create functions for each different application, and have it return something when its operations are complete.

Having your main code check the return in order to continue.


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

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  
Followers 0