Jump to content

[?] GUICTRLREAD how to refresh?


star2
 Share

Recommended Posts

hi ppl it's me again with another question for the experts

this is my GUI

#include <GUIConstants.au3>
GUICreate ("proxy config",350,120)
GUISetFont (10)
GUICtrlCreateLabel ("Proxy ",10,5)
GUICtrlSetFont (-1,12,600)
GUICtrlCreateLabel ("Port ",220,5)
GUICtrlSetFont (-1,12,600)
$inprox = GUICtrlCreateInput ("",10,25,200,25)
$inport = GUICtrlCreateInput ("",220,25,70,25)
$go = GUICtrlCreateButton ("Do",300,25,40,25)
GUICtrlSetFont (-1,12,600)
GUICtrlCreateLabel ("Current Proxy ",10,55)
$current = RegRead ("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings","ProxyServer")
&cur = GUICtrlCreateInput ($current,10,80,330,25,$ES_READONLY)
GUISetState ()
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        If $msg = $go Then
            ;MsgBox (-1,"test",GUICtrlRead ($inprox)&":"&GUICtrlRead ($inport))
            RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings","ProxyServer","REG_SZ",GUICtrlRead ($inprox)&":"&GUICtrlRead ($inport))
        EndIf
WEnd

the problem is that the input control ($cur) does not refresh it self what I mean it should change every time I change the values in the other input controls and press Do

help guys

one more question

if the guictrlread resault is like this [ value1:valu2 ]

and I want to separate value1 from valu2 and use each separately

is it possible?

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

Link to comment
Share on other sites

StringSplit() should help you split the string separated by the full colon. GuiCtrlRead() seems to be working fine in your example so unsure of the issue exactly.

The modification may help you understand better

#include <GUIConstants.au3>
GUICreate ("proxy config",350,120)
GUISetFont (10)
GUICtrlCreateLabel ("Proxy ",10,5)
GUICtrlSetFont (-1,12,600)
GUICtrlCreateLabel ("Port ",220,5)
GUICtrlSetFont (-1,12,600)
$inprox = GUICtrlCreateInput ("",10,25,200,25)
$inport = GUICtrlCreateInput ("",220,25,70,25)
$go = GUICtrlCreateButton ("Do",300,25,40,25)
GUICtrlSetFont (-1,12,600)
GUICtrlCreateLabel ("Current Proxy ",10,55)
$current = RegRead ("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings","ProxyServer")
$cur = GUICtrlCreateInput ($current,10,80,330,25,$ES_READONLY)
GUISetState ()

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $go Then
        ; Read the edit controls
        $edit_control = GUICtrlRead ($inprox) & ":" & GUICtrlRead ($inport)
        ; Send some data back to the read only edit control
        GUICtrlSetData($cur, $edit_control)
        ; Split the string by the full colon
        $answer = StringSplit( $edit_control, ':')
        ; If split in 2 halves the proceed to show Msgbox
        If $answer[0] = 2 Then
            MsgBox (-1, "test", 'Proxy = ' & $answer[1] & @CRLF & 'Port = ' & $answer[2])
        ;RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings","ProxyServer","REG_SZ",GUICtrlRead ($inprox)&":"&GUICtrlRead ($inport))
        EndIf
    EndIf
WEnd

:)

Link to comment
Share on other sites

thank u so much

as for the string split let's say I have the following command

RegRead ("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings","ProxyServer")

the answer will be in this form

someproxy:someport

now I need to copy the string befor the [ : ] and but it as a [ $address = "someproxy" ]

and copy the string after the [ : ] and but it as [ $port ="someport" ]

I know it looks like a dum question

but I need to find an answer

thanks again

Edited by star2

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

Link to comment
Share on other sites

StringSplit() can again help you there.

; Read from registry
$reg_value = RegRead('HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings', 'ProxyServer')
If Not @error Then
    ; Split the value
    $split = StringSplit($reg_value, ':')
    If $split[0] = 2 Then
        $address = $split[1]
        $port = $split[2]
    Else
        MsgBox(0x40030, 'Notice', 'Registry value read was not split')
    EndIf
Else
    MsgBox(0x40030, 'Notice', 'Registry value could not be read')
EndIf

:)

Link to comment
Share on other sites

StringSplit() can again help you there.

this is great

thanks alot I'm gonna read more about [ String ] thank u so much

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

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...