HOW TO USE LOOP INSIDE A Button.add_Click()

this is the code This do the work at one time only . I WANT  TO DO ONE ONE Kindly Help me
$btn.Add_Click({
#########NGM############
If (Test-Connection 192.168.35.9 -Quiet -Count 3)
$btn1.Backcolor="GREEN"
else
{$btn1.Backcolor="RED"} 
###########KPK############
If (Test-Connection 192.168.35.249 -Quiet -Count 1)
$btn2.Backcolor="GREEN"
else
{$btn2.Backcolor="RED"}
#########ANN##########
If (Test-Connection 192.168.35.201 -Quiet -Count 1)
$btn3.Backcolor="GREEN"
else
{$btn3.Backcolor="RED"}
###########ANR#############
If (Test-Connection 192.168.35.241 -Quiet -Count 1)
$btn4.Backcolor="GREEN"
else
{$btn4.Backcolor="RED"}
##############VBM################
If (Test-Connection 192.168.35.242 -Quiet -Count 1)
$btn5.Backcolor="GREEN"
else
{$btn5.Backcolor="RED"}
###############KKN############
If (Test-Connection 192.168.35.243 -Quiet -Count 1)
$btn6.Backcolor="GREEN"
else
{$btn6.Backcolor="RED"}
############POR################
If (Test-Connection 192.168.35.206 -Quiet -Count 1)
$btn7.Backcolor="GREEN"
else
{$btn7.Backcolor="RED"}
#############NGN##############
If (Test-Connection 192.168.35.207 -Quiet -Count 1)
$btn8.Backcolor="GREEN"
else
{$btn8.Backcolor="RED"}
###########VEL################
If (Test-Connection 192.168.35.207 -Quiet -Count 1)
$btn9.Backcolor="GREEN"
else
{$btn9.Backcolor="RED"}
##############ADY#############
If (Test-Connection 192.168.35.176 -Quiet -Count 1)
$btn10.Backcolor="GREEN"
else
{$btn10.Backcolor="RED"}
#########APT#################
If (Test-Connection 192.168.35.218 -Quiet -Count 1)
$btn11.Backcolor="GREEN"
else
{$btn11.Backcolor="RED"}
##########MYL#################
If (Test-Connection 192.168.35.217 -Quiet -Count 1)
$btn12.Backcolor="GREEN"
else
{$btn12.Backcolor="RED"}

Just for clarification, you want to click this button and have this event run continuously rather than just the 1 time it happens? If that is the case, then you can just use a While statement:
While ($True) {
#Do Stuff
If you wanted to stop this action, you would need something else instead to stop the action (not tested but might work):
$btn.Add_Click({
If ([bool]$Script:Run) {
$Script:Run = $False
} Else {
$Script:Run = $True
While ($Script:Run) {
#Do Stuff
The other issue is that this is happening on the UI thread and will probably cause some performance issues (UI lockup) so you may want to look at some sort of multithreading to take the load off of the UI.
Boe Prox
Blog |
Twitter
PoshWSUS |
PoshPAIG | PoshChat |
PoshEventUI
PowerShell Deep Dives Book

Similar Messages

  • How to use loop inside mx:webservice tag

    Hi to all,
    I'm using some webservices. i just want to pass XMLChildren
    to the request element of webservice tag.
    for that,
    <mx:WebService id="WES3" destination="applicantws"
    useProxy="true" fault="Alert.show(event.fault.faultString) ,
    'Error'" >
    <mx:operation name="ZhrFunApplicantCreate"
    result="onResult2(event)" resultFormat="e4x" >
    <mx:request>
    <education>
    { samplexml.children() }
    </education>
    </mx:request>
    </mx:operation>
    </mx:WebService>
    but the problem is samplexml contains many children when i
    embed that samplexml inside websrvice it is taking only the
    firstchild of that samplexml.so i need to loop through the
    samplexml inorder to fetch & bind all the childs of that
    samplexml.
    How do i do that??
    can anyone please please please bring me the solution...
    Thanks in advance..
    regards,
    Thenmalar. v

    Hi,
    You can achieve this by UDF,
    inputs are E1IDB02 BA-FIIKWAER,E1EDKA1 BE-NAME1
    yes then suggest MIDE(E1EDKA1 BE - STRAS,1,35)
    IF E1IDB02 BA-FIIKWAER = CNY
    then MID(E1EDKA1 BE-NAME1,12,11)
    IF E1IDB02 BA-FIIKWAER <> CNY and LEN(E1EDKA1 BE-NAME1)<=35
    then MID(E1EDKA1 BE-STRAS,1,35)
    IF E1IDB02 BA-FIIKWAER <> CNY and LEN(E1EDKA1 BE-NAME1)>35
    then MID(E1EDKA1 BE-NAME1,36,35)
    Regards
    Chilla

  • How to use loop inside table in smart form

    Hi All
    i have to use page break at the end of each pernr. i got table in smart form and print cells on event on sort begin. it is working ok . i have an other itab in  as well .which i want to the same page with respect to the pernr no.
    but the problem is as i loop the 2nd itab. it prints all the record what it has.
    e.g  i have two pernr 54 and 55.
    the records of itab1 prints on page1 and page 2 properly. now i loop at itab2 it also have relevent records of above said pernrs. but i m unable to control those pernrs and loop print all the records on both pages.
    if u get some thing out of it kindly help me
    Regards
    ammad

    hi,
    Place the second loop ie. itab2 inside the first loop of itab1.  And in the conditions tab of looping itab2 give the condition for checking the pernr.
    try to implement this logic.
    loop itab
      at new pernr
        new-page
      endat.
        loop at itab2 where pernr eq itab-pernr.
       endloop.
    endloop.
    revert back for further queries.
    regards
    Rajitha.

  • How to use LOOP(Until) step in a Workflow

    Hi,
    How to use LOOP(Until) step in a Workflow?
    What are the steps involved in using the step LOOP(Until).

    Hmmm... using it is just like using a LOOP UNTIL statement in any programming language. You get at least one loop iteration, as opposed to a WHILE loop which may give you zero iterations.
    You simply insert a node of this type in the workflow, and magically there will be a loop inside which you can insert the steps you want to execute in the loop, and by double-clicking at the end node of the loop you can enter the condition for exiting.
    What exactly is it you are having trouble understanding about the use of it?

  • How to use Checkbox  and radio buttons in BI Reporting

    Hi BW Experts,
       My Client has given a report in ABAP format and the report has to be develop in BI.It contains Check boxes and the radio buttons. I don’t know how to use Checkboxes and radio buttons in Bex.For using this option, do we need to write a code in ABAP.Please help on this issue.
    Thanks,
    Ram

    Hi..
    Catalog item characteristic
    - Data element
    - Characteristic type
    Entry type
    List of catalog characteristics
    Designer
    Format (character)
    Standard characteristic
    Alternative: Master characteristic
    (used for automatic product
    assignment)
    Simple entry field
    Alternatives:
    Dropdown listbox or radio button
    list

  • How to use the cases in button action?

    Hi Experts,
    I want to get a prompt message if the field is empty.I got it but at the same time if the field is filled I want the other action to be performed that is to call a BAPI and give me output.How can I give two events for the same action.
    How to use the cases in button action?
    So, please guide me.Urgent need
    Regards
    Nutan

    Hi Nutan,
    if I understand you, then you have a simple validation. Therefore you can use the validation functionality of VC for your components. An alternative could be by writing a new ABAP RFC function module like:
    BAPI Input parameters as input and BAPI output parameters as output and an additional return code or string for a message:
    IF I_FIELD IS INITIAL.
      E_RETURN_CODE = "THE FIELD IS EMPTY."
    ELSE.
      CALL FUNCTION <YOUR_BAPI>
      <BAPI PARAMETERS>
    ENDIF.
    I hope that helps.
    Best Regards,
    Marcel

  • How To use window.print() into Button Attributes

    hi,
    I want to print a report using an print button.so i am using window.print() function into Button Attributes .But Print pop up screen not pop up . How To use window.print() into Button Attributes      .
    Thanks
    Manoj

    dear hari
    "Set button target as URL and put following js as URL Target
    javascript:window.print();"
    Will this be useful to my another thread raised as follows.
    In case, if i am able to generate report as txt (ascii) file instead of doc / pdf and is it possible to send the txt file using host command. I am uable to try since i do not know where to place host command on click &print.
    yours
    dr.s.raghunathan

  • How to use loop in premiere elements 8?

    Hi,
    Using pre elements 8 and I don`t know how to set or use loop option in premiere elements 8
    Please help
    Vinay

    For an authored DVD, there is no capability to Loop that DVD, created in PrE. There are other authoring programs, like Sony's DVD Architect, and Adobe Encore (available only with PrPro), that allow this to be done easily.
    The way to do similar in PrE is to do an AutoPlay DVD and then this use the Repeat button on the DVD player.
    Good luck,
    Hunt

  • How to use loop

    Hi
    I have one control block in form of Grid and now I want clear my grid when button pressed for new selection.
    So any one let me know how can I use loop for these field
         :ADVANCES_SCHEME.TXT_MONTH := '';
              :ADVANCES_SCHEME.MONTH_VERIFIED := '';
              :ADVANCES_SCHEME.CK_VERIFIED := 'N';
    Thanks in advance...
    Regards

    Thanks every one. I have solve my problem, just put this statement in begin clause
         Clear_Block(No_Validate);
    this statement clear my grid.
    Regards

  • How to use loop controllers...

    hi i'm a new user for jmeter, now i want to test my site which has login details, i don know how to use foreach or other loop controllers to check my site.
    please anyone give me step by step procedure to test my site..
    regards,
    kumar

    Hmmm... using it is just like using a LOOP UNTIL statement in any programming language. You get at least one loop iteration, as opposed to a WHILE loop which may give you zero iterations.
    You simply insert a node of this type in the workflow, and magically there will be a loop inside which you can insert the steps you want to execute in the loop, and by double-clicking at the end node of the loop you can enter the condition for exiting.
    What exactly is it you are having trouble understanding about the use of it?

  • How To Use a Custom Close Button In Window Component

    Hello,
    I have a window component, with the default close button
    turned off, and a new custom close button added to the movie clip
    that is displayed inside the window component. How do I get a click
    on the close button to close the window?
    This is the code I currently have to create the window (and
    the listeners to close the window using the default close button):

    basicalyyou have to use
    myWindow.deletePopUp();
    if my memory serves the content mc is loaded into a mc called
    contentHolder, inside the window component, so
    if you are referencing the window from the scope of your
    loaded mc it will be
    this._parent._parent.deletePopUp();
    or if from the button's scope
    this._parent._parent._parent.deletePopUp();
    try traceing the parantage down til you hit the window.

  • How to use drag n drop button in report display

    hello friends
                             i'm displaying list report . i want one customer one time and with  diff amounts .ok first of all i'm diplaying detail customer details , if i click on one customer i have to display that cust one time and i want to get details . just like drag and drop button how to use this in normal report .
    please help me out .
    thanks & regards.
    lavanya

    Hi,
    Check this link..
    http://www.sapdevelopment.co.uk/reporting/alv/alvtree/alvtree_basic.htm
    And also Check these Examples..
    BCALV_TREE_01
    BCALV_TREE_02
    BCALV_TREE_03
    BCALV_TREE_04
    BCALV_TREE_05
    BCALV_TREE_06
    BCALV_TREE_DEMO
    BCALV_TREE_DND
    BCALV_TREE_DND_MULTIPLE
    BCALV_TREE_EVENT_RECEIVER
    BCALV_TREE_EVENT_RECEIVER01
    BCALV_TREE_ITEMLAYOUT
    BCALV_TREE_MOVE_NODE_TEST
    BCALV_TREE_SIMPLE_DEMO
    BCALV_TREE_VERIFY

  • How to use loop in BPEL Process

    Hi friends
    I have done a bpel process which picks up XMl file using File Adapter and imports the data from the XMl file to oracle db table using DB adapter....
    But here the XMl file which have only one row ..if i want insert the XML file which have two or more rows i want to use loop in my BPEL process how to use the loop in my bpel process ?
    In my BPEL process i have used receive ,transform , and invoke activity where can i use loop in my BPEL process
    Advance Thanks
    AT

    Hi Friend thanks
    Hi Oracler how to make use of transform activity and use a for each in it.?
    iam not getting i try can u please explain some more in brief
    Thanks
    AT

  • How to use the standrad Refresh button in ooalv Grid?

    Hai Experts ,
                              i write editable oo alv program its works fine.  when change the data
    then click save button its saved correctly, but the problem is totals of row  & column not refresh when i am click the
    Refresh button . Please Help how to handle the standard Refresh button in ooalv .
    Thanks
    Adv....

    thank q u for ur reply,
                                            when i edit the data in grid and save the data its saved  successful,
    but the problem is manually i calculating the totals at the end of the Row as well as at end of the columns,
    when i edit the data in Grid that totals are not effected for that im using the Standard Refresh button ,
    Plz help me.

  • How to use loop in smartforms???

    hi experts,
                  I have an internal table with three values .i am passing it into new itab inside smartforms .while displaying it is displaying only the third data .i think i must use loop condition .but i dont know where to use it .pls help me.if i select only one data it is coming .if i select multiple data using select statement .only the final thing is coming .

    On your smartform, you should have a table set up.  Go to transaction SMARTFORMS, enter your form name, and display it.  Now navigate to the table on your form and double-click it.  Go to the Data tab.  Under "LOOP", make sure that you have checked "Internal table".  Next to that should be the name of your internal table, then "Into", then a work area.  The work area needs to be defined under "Global Definitions" (under Global Settings, check the tree for your form).  Your work area should be defined as TYPE, with the associated type being your internal table.  Your internal table should actually be defined as a structure where each component is one item that you want to include in your row.  I hope this helps.
    - April King

Maybe you are looking for