Jump to content

GUI Code Line Clean Up Help


Recommended Posts

@ Edano

Ok so I have hit a wall again ......... Once the combo box have been created how do I distinguish which selection was made ...... I`ve tried this but to no avail ..... :

If $nmsg=$UnitsCombo[$i] Then
    $j = GUICtrlRead($UnitsCombo[$i]&$j)
    Switch $j
    $sfilespec = "FILENAME"
    $file = FileOpen($sfilespec, 0)
    If $file = -1 Then
    MsgBox(0, "Error", "Unable to open data file: '" & $sfilespec & "'")
    Exit
    EndIf

Kind Regards,

CHOVIE

..... To Be The Best You Have To Beat The Best .....

Link to post
Share on other sites
  • Replies 43
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

@ Edano

the code is below for creating the combo box .........

$UnitsCombo[$i]=GUICtrlCreateCombo("UNITS", 14+70*$i, 85, 60, 25)
    GUICtrlSetFont(-1, 8, 400, 0, "Arial")
    For $j=1 To 15+10*($i<3)+25*($i<2)
        GUICtrlSetData(-1,"SVR "&$j)

and I need the function to pick up which selection was made in the combo box, use that selection ...... got to the appropriate file, read from there and do the above function ........

Regards,

CHOVIE

Edited by CHOVIE

..... To Be The Best You Have To Beat The Best .....

Link to post
Share on other sites

@ Edano

I have got this working but it needs to wait for me to puch the button before exicuting the command ....."once I have made the selection it automaticaly goes to the file reads it and starts running" .......

If $nmsg=$UnitsCombo[$i] Then
        $SVR_selection = GUICtrlRead($UnitsCombo[$i]&$j)
            $j = "SVR 1"
            $sfilespec = "FILENAME"
            $file = FileOpen($sfilespec, 0)
            If $file = -1 Then
            MsgBox(0, "Error", "Unable to open data file: '" & $sfilespec & "'")
        Exit
    EndIf
    While 1
          $sline = FileReadLine($file)
          If @error = -1 Then ExitLoop
          $swindowtitle = "Telnet " & $sline
          $result = Run(@ComSpec & " /c telnet " & $sline)
        If $result <> 0 Then
            Sleep(500)
       WinActivate($swindowtitle)
       Sleep(200)
       Send("")









Thank you once again for have a look ....

Kind Regards,

CHOVIE

Edited by CHOVIE

..... To Be The Best You Have To Beat The Best .....

Link to post
Share on other sites

yes, of course it runs as soon as you use the combobox. you coded it that way. now think when you want to read out the combo and if you need an immediate reaction when the selection changes or not ........................

Edited by Edano

[color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font]

Link to post
Share on other sites

@ Edano

I understand the logic on what you mean but do not have a clue where to start and where to look ...... I have tried a few things but to no avail ..... I am sorry for being such a pain in the ass ......... but hopefully one day I`ll get there ....... :ermm:  :D

I know that the code is a bit chaotic but it was my first one I did ...... if there is an easier way to get this to work please show me ....

Kind Regards,

CHOVIE

Edited by CHOVIE

..... To Be The Best You Have To Beat The Best .....

Link to post
Share on other sites

you read out the combobox when the button is pushed. the same you did with the ip-addresses. if button pressed then read combo and then read the script. not: if combo changed, read the script.

when is the button pressed ? when $msg=$button , not when $msg=combo

the helpfile is such a great resource, no other language has such a good help file, believe me.

[color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font]

Link to post
Share on other sites

@ Edano

Thanks the button is now working :dance:  ...... Now to find out which selection was made and the to go to which file  :think: ......... will try this and see how far I get ......... And yes the Help file is brilliant but only if you know what you are looking for .......  ^_^  

Kind Regards,

CHOVIE

..... To Be The Best You Have To Beat The Best .....

Link to post
Share on other sites

@ Edano

 

Heeeeeee Haaaaaaaa ............. reading from the combo box now and waiting for the button to get pressed and going to to allocated file ................

If $nmsg=$OK1Button[$i] Then
           $SVR_selection = GUICtrlRead($UnitsCombo[$i],$j)
     If $SVR_selection = "ITEM In COMBOBOX" Then
            $sfilespec = "FILENAME"
            $file = FileOpen($sfilespec, 0)
            If $file = -1 Then
            MsgBox(0, "Error", "Unable to open data file: '" & $sfilespec & "'")
        Exit
    EndIf
    While 1
          $sline = FileReadLine($file)
          If @error = -1 Then ExitLoop
          $swindowtitle = "Telnet " & $sline
          $result = Run(@ComSpec & " /c telnet " & $sline)
        If $result <> 0 Then
            Sleep(500)
       WinActivate($swindowtitle)
       Sleep(200)
       Send("")

That is what I have got ........... is there an easier way of doing this?

 

Kind Regards,

CHOVIE

..... To Be The Best You Have To Beat The Best .....

Link to post
Share on other sites

Is there a way to read from the combo box get the relevant information go to "one" file, take the required information from there and execute the function ....... the reason for this is it is the same function over and over but the Item in the combo box and the required information in the file(one liner) changes ...... 

Example:

combo box  ======>  File              ======>  Function

SVR 1         ======>  Information  ======>  Same Function

Thank you for have a look and any suggestions are welcome ......

Kind Regards,

CHOVIE

..... To Be The Best You Have To Beat The Best .....

Link to post
Share on other sites

Is there a way to read from the combo box get the relevant information go to "one" file, take the required information from there and execute the function ....... the reason for this is it is the same function over and over but the Item in the combo box and the required information in the file(one liner) changes ...... 

Example:

combo box  ======>  File              ======>  Function

SVR 1         ======>  Information  ======>  Same Function

Thank you for have a look and any suggestions are welcome ......

Kind Regards,

CHOVIE

.

yes. that's what you use Func() ..... EndFunc for => helpfile.

[color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font]

Link to post
Share on other sites

@ Edano

I have gone through the help file and wiki on functions ... but this is still way above my pay grade .... : ...... or maybe I am to dumb to understand it ......

Please help .....

Kind Regards,

CHOVIE

..... To Be The Best You Have To Beat The Best .....

Link to post
Share on other sites

OK after a long and intense look at functions, video tutorials and help file reading I came up with the following function that works once .....

_Buttons($SVR_selection)

Func _Buttons($SVR_selection)
    If $SVR_selection = "SVR" & $i Then
    $sfilespec = "FILENAME.txt"
    $file = FileOpen($sfilespec, 0)
    If $file = -1 Then
    MsgBox(0, "Error", "Unable to open data file: '" & $sfilespec & "'")
  Exit
EndIf   
  While 1
$sline = FileReadLine($file)
    If @error = -1 Then ExitLoop
    $swindowtitle = "Telnet " & $sline
    $result = Run(@ComSpec & " /c telnet " & $sline)
    If $result <> 0 Then
    Sleep(500)
    WinActivate($swindowtitle)
    Sleep(400)
    Send("Key")
    Sleep(300)
    Send("Key")
    Sleep(400)
    Send("Key")
    Sleep(300)
    Send("Key")
    Sleep(300)
  Else                  
   MsgBox(0, "Error", "Failed to run Telnet for server '" & $sline & "'!")
  EndIf
   WEnd
  EndIf
EndFunc

 But the now I am stuck ....... How can I get the function to open the same file and read only the required line information

Example;

Meaning that if

If $SVR_selection = "SVR" & $i Then

$i = 1.... then read SVR 1 = "First line"

$i = 2.... then read SVR 2 = "Second line"  and so on

Any help will be appreciated on this matter .....

Kind Regards,

CHOVIE

..... To Be The Best You Have To Beat The Best .....

Link to post
Share on other sites

ok, please give me the entire code, since it is not clear what your variables $i and $svr_selection are. i didn't keep it in mind. i'm going to help you then.

and then, look at FileReadLine() function. you can specify what line to read.

E.

[color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font]

Link to post
Share on other sites

The set button reeds from a file and do all the commands at once "this is all server related" and the the ok button do the same just one by one .....

It reads from a txt file

Example;

10.0.0.1 port "Line 1"

10.0.0.2 port "Line 2"

10.0.0.3 port "Line 3"

Edited by CHOVIE

..... To Be The Best You Have To Beat The Best .....

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...