faustf Posted November 7, 2014 Share Posted November 7, 2014 hi gui i try to create i gui for mldonkey i created a gui with menu file , i clik over menu, in option and open a new gui-mask and it go all perfect , but when i try to start a configuration mask with out father gui , directly (because the first time you open must do a configuration) not read nothing how is possible ?? i have windows 8.1 and last version of autoit expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GuiButton.au3> #include <GuiTab.au3> #Include <GuiMenu.au3> #include <GuiConstants.au3> #include <GuiIPAddress.au3> Global $ip_address,$port_address,$mldonkey_client,$tab1,$primo_avvio Opt("GuiOnEventMode", 1) Opt("GUICloseOnESC", 0) ;MsgBox (0, '', @ScriptDir & "\config.ini") $ip_address = IniRead ( @ScriptDir & "\config.ini", "config", "ip","") $port_address = IniRead ( @ScriptDir & "\config.ini", "config", "port","") ;MsgBox (0,'', $ip_address &" "& $port_address) if $ip_address = '' Then $primo_avvio=1 configura() ;configura_exe() Else prog() EndIf Func prog() $mldonkey_client = GUICreate("mldonkey-client",1119,785,-1,-1,-1,-1) menu_file() $tab1 = GUICtrlCreatetab(6,25,1105,737,-1,-1) GuiCtrlSetState(-1,2048) GUICtrlCreateTabItem("Trasferimenti") GUICtrlCreateTabItem("Cerca") GUICtrlCreateTabItem("Server") GUICtrlCreateTabItem("") _GUICtrlTab_SetCurFocus($tab1,-1) GUISwitch($mldonkey_client,_GUICtrlTab_SetCurFocus($tab1,0)&GUICtrlRead ($tab1, 1)) GUICtrlCreatelistview("",16,55,1083,453,-1,512) GUICtrlCreatelistview("",16,517,1083,217,-1,512) _GUICtrlTab_SetCurFocus($tab1,0) GUISetState(@SW_SHOW,$mldonkey_client) GUISetOnEvent($GUI_EVENT_CLOSE, "_Close") EndFunc Func Menu_file() $MenuItem1 = GUICtrlCreateMenu("File") $MenuItem5 = GUICtrlCreateMenuItem("Esci", $MenuItem1) $MenuItem2 = GUICtrlCreateMenu("Option") $MenuItem4 = GUICtrlCreateMenuItem("Configura", $MenuItem2) $MenuItem3 = GUICtrlCreateMenu("Help") GUISetState() ; GUICtrlSetOnEvent($MenuItem9, "_Close") ;GUICtrlSetOnEvent($MenuItem4, "configura_exe") GUICtrlSetOnEvent($MenuItem4, "configura") GUICtrlSetOnEvent($MenuItem5, "_Close") EndFunc Global $Configurazione,$ip_write,$port_write,$salva_esci,$test_con,$ip_read,$port_read #cs Func configura_exe() Local $iPID = Run(@ScriptDir &"\configurazione.exe", "", @SW_SHOWMAXIMIZED) EndFunc #ce Func configura() $Configurazione = GUICreate("Configurazione",345,269,-1,-1,-1,-1) $ip_write=GUICtrlCreateInput("test",158,80,150,20,-1,512) $port_write=GUICtrlCreateInput("4000",158,140,150,20,-1,512) $salva_esci=GUICtrlCreateButton("Salva e Esci",210,210,100,24,-1,-1) GUICtrlCreateLabel("Indirizzo ip del Server",161,63,107,15,-1,-1) GUICtrlSetBkColor(-1,"-2") GUICtrlCreateLabel("Porta telnet server",161,125,139,15,-1,-1) GUICtrlSetBkColor(-1,"-2") $test_con=GUICtrlCreateButton("Test",50,210,86,24,-1,-1) GUICtrlCreateIcon("C:\Users\stefano\Documents\_PROGRAMMAZIONE\ISN AutoIt Studio\Projects\mldonkey-client\Images\Ampeross-Qetto-2-Settings.ico",-1,40,100,48,48,-1,-1) GUICtrlCreateLabel("Parametri di connessione by telnet per mldonkey",80,10,228,16,-1,-1) GUICtrlSetBkColor(-1,"-2") GUISetState(@SW_SHOW,$Configurazione) if $primo_avvio = 1 Then GUISetOnEvent($GUI_EVENT_CLOSE, "_chiudi") GUISetOnEvent($GUI_EVENT_CLOSE, "_Close") Else GUISetOnEvent($GUI_EVENT_CLOSE, "_chiudi") endif GUICtrlSetOnEvent($salva_esci, "_salva_config_esci") GUICtrlSetOnEvent($test_con, "_testa_connessione") $ip_read=GUICtrlRead($ip_write) MsgBox (0,'',$ip_write) EndFunc Func _salva_config_esci() $ip_read=GUICtrlRead($ip_write) $port_read=GUICtrlRead($port_write) ;MsgBox(0,'',$ip_read) IniWrite ( @ScriptDir & "\config.ini", "config", "ip", $ip_read ) IniWrite ( @ScriptDir & "\config.ini", "config", "port", $port_read ) if $primo_avvio = 1 Then _chiudi() prog() $primo_avvio = 0 Else _chiudi() EndIf EndFunc Func _testa_connessione() $ip_read=GUICtrlRead($ip_write) $port_read=GUICtrlRead($port_write) MsgBox (0,'',$ip_read) TCPStartup () $test_ip= TCPNameToIP ($ip_read) $test_connect = TCPConnect($ip_read,$port_read) If @error Then ; The server is probably offline/port is not opened on the server. Local $iError = @error MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Non posso connettermi, Error code: " & $iError) Return False Else MsgBox($MB_SYSTEMMODAL, "", "Test superato") EndIf TCPCloseSocket($test_connect) TCPShutdown() ; Close the TCP service. EndFunc TCPStartup () $Host = TCPNameToIP ( $ip_address ) $Conection = TCPConnect ( $Host, $port_address ) Func _chiudi() GUIDelete() EndFunc ;==>_chiudi ;============= chiusura programma Func _close() Exit EndFunc ;==>_close ;=============================================================== ;Keep the GUI alive ;=============================================================== While 1 Sleep(1000) WEnd Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 7, 2014 Moderators Share Posted November 7, 2014 You're reading the control id number ($ip_write), not the content of the GUICtrlRead ($ip_read)... This: MsgBox(0, '', $ip_write) Should be: MsgBox(0, '', $ip_read) Your code is all over the place, makes it hard to follow your logic. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiButton.au3> #include <GuiTab.au3> #include <GuiMenu.au3> #include <GuiConstants.au3> #include <GuiIPAddress.au3> Global $ip_address, $port_address, $mldonkey_client, $tab1, $primo_avvio Global $Configurazione, $ip_write, $port_write, $salva_esci, $test_con, $ip_read, $port_read Opt("GuiOnEventMode", 1) Opt("GUICloseOnESC", 0) ;MsgBox (0, '', @ScriptDir & "\config.ini") $ip_address = IniRead(@ScriptDir & "\config.ini", "config", "ip", "") $port_address = IniRead(@ScriptDir & "\config.ini", "config", "port", "") ;MsgBox (0,'', $ip_address &" "& $port_address) If $ip_address = '' Then $primo_avvio = 1 configura() ;configura_exe() Else prog() EndIf TCPStartup() $Host = TCPNameToIP($ip_address) $Conection = TCPConnect($Host, $port_address) ;=============================================================== ;Keep the GUI alive ;=============================================================== While 1 Sleep(1000) WEnd Func prog() $mldonkey_client = GUICreate("mldonkey-client", 1119, 785, -1, -1, -1, -1) Menu_file() $tab1 = GUICtrlCreateTab(6, 25, 1105, 737, -1, -1) GUICtrlSetState(-1, 2048) GUICtrlCreateTabItem("Trasferimenti") GUICtrlCreateTabItem("Cerca") GUICtrlCreateTabItem("Server") GUICtrlCreateTabItem("") _GUICtrlTab_SetCurFocus($tab1, -1) GUISwitch($mldonkey_client, _GUICtrlTab_SetCurFocus($tab1, 0) & GUICtrlRead($tab1, 1)) GUICtrlCreateListView("", 16, 55, 1083, 453, -1, 512) GUICtrlCreateListView("", 16, 517, 1083, 217, -1, 512) _GUICtrlTab_SetCurFocus($tab1, 0) GUISetState(@SW_SHOW, $mldonkey_client) GUISetOnEvent($GUI_EVENT_CLOSE, "_Close") EndFunc ;==>prog Func Menu_file() $MenuItem1 = GUICtrlCreateMenu("File") $MenuItem5 = GUICtrlCreateMenuItem("Esci", $MenuItem1) $MenuItem2 = GUICtrlCreateMenu("Option") $MenuItem4 = GUICtrlCreateMenuItem("Configura", $MenuItem2) $MenuItem3 = GUICtrlCreateMenu("Help") GUISetState() ; GUICtrlSetOnEvent($MenuItem9, "_Close") ;GUICtrlSetOnEvent($MenuItem4, "configura_exe") GUICtrlSetOnEvent($MenuItem4, "configura") GUICtrlSetOnEvent($MenuItem5, "_Close") EndFunc ;==>Menu_file #cs Func configura_exe() Local $iPID = Run(@ScriptDir &"\configurazione.exe", "", @SW_SHOWMAXIMIZED) EndFunc #ce Func configura() $Configurazione = GUICreate("Configurazione", 345, 269, -1, -1, -1, -1) $ip_write = GUICtrlCreateInput("test", 158, 80, 150, 20, -1, 512) $port_write = GUICtrlCreateInput("4000", 158, 140, 150, 20, -1, 512) $salva_esci = GUICtrlCreateButton("Salva e Esci", 210, 210, 100, 24, -1, -1) GUICtrlCreateLabel("Indirizzo ip del Server", 161, 63, 107, 15, -1, -1) GUICtrlSetBkColor(-1, "-2") GUICtrlCreateLabel("Porta telnet server", 161, 125, 139, 15, -1, -1) GUICtrlSetBkColor(-1, "-2") $test_con = GUICtrlCreateButton("Test", 50, 210, 86, 24, -1, -1) GUICtrlCreateIcon("C:\Users\stefano\Documents\_PROGRAMMAZIONE\ISN AutoIt Studio\Projects\mldonkey-client\Images\Ampeross-Qetto-2-Settings.ico", -1, 40, 100, 48, 48, -1, -1) GUICtrlCreateLabel("Parametri di connessione by telnet per mldonkey", 80, 10, 228, 16, -1, -1) GUICtrlSetBkColor(-1, "-2") GUISetState(@SW_SHOW, $Configurazione) If $primo_avvio = 1 Then GUISetOnEvent($GUI_EVENT_CLOSE, "_chiudi") GUISetOnEvent($GUI_EVENT_CLOSE, "_Close") Else GUISetOnEvent($GUI_EVENT_CLOSE, "_chiudi") EndIf GUICtrlSetOnEvent($salva_esci, "_salva_config_esci") GUICtrlSetOnEvent($test_con, "_testa_connessione") $ip_read = GUICtrlRead($ip_write) MsgBox(0, '', $ip_read) ;MsgBox(0, '', $ip_write) EndFunc ;==>configura Func _salva_config_esci() $ip_read = GUICtrlRead($ip_write) $port_read = GUICtrlRead($port_write) ;MsgBox(0,'',$ip_read) IniWrite(@ScriptDir & "\config.ini", "config", "ip", $ip_read) IniWrite(@ScriptDir & "\config.ini", "config", "port", $port_read) If $primo_avvio = 1 Then _chiudi() prog() $primo_avvio = 0 Else _chiudi() EndIf EndFunc ;==>_salva_config_esci Func _testa_connessione() $ip_read = GUICtrlRead($ip_write) $port_read = GUICtrlRead($port_write) MsgBox(0, '', $ip_read) TCPStartup() $test_ip = TCPNameToIP($ip_read) $test_connect = TCPConnect($ip_read, $port_read) If @error Then ; The server is probably offline/port is not opened on the server. Local $iError = @error MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Non posso connettermi, Error code: " & $iError) Return False Else MsgBox($MB_SYSTEMMODAL, "", "Test superato") EndIf TCPCloseSocket($test_connect) TCPShutdown() ; Close the TCP service. EndFunc ;==>_testa_connessione Func _chiudi() GUIDelete() EndFunc ;==>_chiudi ;============= chiusura programma Func _close() Exit EndFunc ;==>_close Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
faustf Posted November 7, 2014 Author Share Posted November 7, 2014 the messagbox is only for verify , i do much test probably i dont change variable in messagebox , but , the problem is when you run the program and your ini file is blank the program start with child-gui configuration , if you try imput somthing dont go , and i dont understund where is problem Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 7, 2014 Moderators Share Posted November 7, 2014 What doesn't go? It's very difficult to understand you. I can save the data to the ini file. I can load the data as default into the GUI so each time I run the program it shows the default ip addresses again. Are you suggesting that the TCP connection is not working? Please be much more specific, and maybe point in the code where you think it's failing. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
faustf Posted November 8, 2014 Author Share Posted November 8, 2014 o no sorry go all perfect , thank you so much and sorry for disturb Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now