Jump to content

GUI Code Line Clean Up Help


CHOVIE
 Share

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 comment
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 comment
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 comment
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 comment
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 comment
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 comment
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 comment
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 comment
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 comment
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 comment
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 comment
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 comment
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 comment
Share on other sites

but they do the same as far as i can see. what does SET do and what OK ? and what is your file to read ? this is really confusing

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

Link to comment
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 comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...