Sign in to follow this  
Followers 0
fgthhhh

need help in regedit write

12 posts in this topic

this is my code

func changeip()
    $s=FileReadLine( FileOpen( "sock.txt", 0), $k)
    ;MsgBox( 0, "", $s) just to check if it work or error till here and no error
If $s="" Then
regwrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\","ProxyEnable","REG_DWORD","0")
else
regwrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\","ProxyEnable","REG_DWORD","1")
regwrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\","ProxyServer","REG_SZ","socks="&$s)
DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0)
endif

EndFunc

i run it first time, it work perfectly

but in the second time and after, i can't change ip any more

i check in regedit and it don't do this code line

regwrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\","ProxyServer","REG_SZ","socks="&$s)

it don't write new ip into it

if i close my program and run it and, it just work at the first time

pls help me

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

this is my code

func changeip()
    $s=FileReadLine( FileOpen( "sock.txt", 0), $k)
    ;MsgBox( 0, "", $s) just to check if it work or error till here and no error
If $s="" Then
regwrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\","ProxyEnable","REG_DWORD","0")
else
regwrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\","ProxyEnable","REG_DWORD","1")
regwrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\","ProxyServer","REG_SZ","socks="&$s)
DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0)
endif

EndFunc

i run it first time, it work perfectly

but in the second time and after, i can't change ip any more

i check in regedit and it don't do this code line

regwrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\","ProxyServer","REG_SZ","socks="&$s)

it don't write new ip into it

if i close my program and run it and, it just work at the first time

pls help me

You must close the file you opened before trying to open it again.

$s=FileReadLine( FileOpen( "sock.txt", 0), $k);<--------------will fail second time because you have not closed the file.

$hf = FileOpen( "sock.txt", 0)
$s=FileReadLine($hf, $k)
FileClose($hf)
Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

i just update my code, but it don't work, can u help me try it

#include <GUIConstants.au3>
#include <IE.au3> 
#Include <File.au3>
#include <WindowsConstants.au3>
#include <TreeViewConstants.au3>
#Include <Array.au3>
#Include <GuiTreeView.au3>
$oIE = _IECreateEmbedded ()
GUICreate( "my bot", 1024 , 760)
$GUIActiveX = GUICtrlCreateObj($oIE, 350, 30, 650, 650)

$button_1 = GUICtrlCreateButton ("load sock",  10, 700, 70)
$button_2 = GUICtrlCreateButton ( "EXIT",  810, 700, 70)
$button_4 = GUICtrlCreateButton ("change ip",  90, 700, 70 )
$button_3 = GUICtrlCreateButton ( "ip.xanta.net",  170, 700, 70)
$treeview = GUICtrlCreateTreeView(10, 30, 300, 650, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
GUICtrlCreateTreeViewItem( "", $treeview)
GUISetState ()
;HotKeySet("{F9}", "ShowMe")


While 1
    $msg = GUIGetMsg() ; this checks for a message/input from the GUI.
    Select
        Case $msg = $GUI_EVENT_CLOSE 
            Exit ; this states, on an exit event, exit the loop.
        Case $msg = $button_2
            exit
        case $msg = $button_1
            loadsock()
        case $msg = $button_3
            checkip()
        case $msg = $button_4
            changeip()
    EndSelect
Wend

func checkip()
    _IENavigate ($oIE,"http://ip.xanta.net", 0)
EndFunc

func changeip()
    $s=GUICtrlRead($treeview, 1)
    MsgBox( 0, "", $s)
If $s="" Then
regwrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\","ProxyEnable","REG_DWORD","0")
else
regwrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\","ProxyEnable","REG_DWORD","1")
regwrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\","ProxyServer","REG_SZ","socks="&$s)
DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0)
endif

EndFunc
    
Func loadsock()
$CountLines = _FileCountLines("sock.txt")
If @error = 1 Then
    _GUICtrlTreeView_InsertItem( $treeview, "Unable to open file.")
Else
    for $k = 1 to $CountLines
    Local $subtree[1000]
    $subtree[$k] = GuiCtrlCreateTreeViewItem(FileReadLine ( FileOpen( "sock.txt", 0), $k), $treeview)
    next
EndIf
EndFunc

Share this post


Link to post
Share on other sites

Hi,

you still have had an unclosed FileOpen.

You call FileOpen for every item in the For Loop and declare your array.

Func loadsock()
    $CountLines = _FileCountLines("sock.txt")
    If @error = 1 Then
        _GUICtrlTreeView_InsertItem( $treeview, "Unable to open file.")
    Else
        $file = FileOpen( "sock.txt", 0)
        ;Local $subtree[1000]
        Dim $subtree [$CountLines + 1] ; as suggestion
        for $k = 1 to $CountLines
            $subtree[$k] = GuiCtrlCreateTreeViewItem(FileReadLine ( $file, $k), $treeview)
        next
        FileClose ($file)
    EndIf
EndFunc

;-))

Stefan

Share this post


Link to post
Share on other sites

i did change it as your advise, but it still don't work

the real problem isn't Func loadsock(), it work with or without fileclose, i tried

what i need is func changeip()

it work well at the 1st time, but from second time, it don't write sock to registry

with the MsgBox( 0, "", $s), i can say it can load sock correctly

but as i check the registry, it don't change the registry from 2nd time

help me

#include <GUIConstants.au3>
#include <IE.au3> 
#Include <File.au3>
#include <WindowsConstants.au3>
#include <TreeViewConstants.au3>
#Include <Array.au3>
#Include <GuiTreeView.au3>
$oIE = _IECreateEmbedded ()
GUICreate( "my bot", 1024 , 760)
$GUIActiveX = GUICtrlCreateObj($oIE, 350, 30, 650, 650)

$button_1 = GUICtrlCreateButton ("load sock",  10, 700, 70)
$button_2 = GUICtrlCreateButton ( "EXIT",  810, 700, 70)
$button_4 = GUICtrlCreateButton ("change ip",  90, 700, 70 )
$button_3 = GUICtrlCreateButton ( "ip.xanta.net",  170, 700, 70)
$treeview = GUICtrlCreateTreeView(10, 30, 300, 650, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
GUICtrlCreateTreeViewItem( "", $treeview)
GUISetState ()
;HotKeySet("{F9}", "ShowMe")


While 1
    $msg = GUIGetMsg() ; this checks for a message/input from the GUI.
    Select
        Case $msg = $GUI_EVENT_CLOSE 
            Exit ; this states, on an exit event, exit the loop.
        Case $msg = $button_2
            exit
        case $msg = $button_1
            loadsock()
        case $msg = $button_3
            checkip()
        case $msg = $button_4
            changeip()
    EndSelect
Wend

func checkip()
    _IENavigate ($oIE,"http://ip.xanta.net", 0)
EndFunc

func changeip()
    $s=GUICtrlRead($treeview, 1)
    MsgBox( 0, "", $s)
If $s="" Then
regwrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\","ProxyEnable","REG_DWORD","0")
DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0)
else
regwrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\","ProxyEnable","REG_DWORD","1")
regwrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\","ProxyServer","REG_SZ","socks="&$s)
DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0)
endif

EndFunc
    
Func loadsock()
    $file = FileOpen( "sock.txt", 0)
$CountLines = _FileCountLines("sock.txt")
If @error = 1 Then
    _GUICtrlTreeView_InsertItem( $treeview, "Unable to open file.")
Else
    for $k = 1 to $CountLines
    Dim $subtree [$CountLines + 1]
    $subtree[$k] = GuiCtrlCreateTreeViewItem(FileReadLine ($file, $k), $treeview)
    next
    FileClose ($file)
EndIf

EndFunc

Share this post


Link to post
Share on other sites

i did change it as your advise, but it still don't work

the real problem isn't Func loadsock(), it work with or without fileclose, i tried

what i need is func changeip()

it work well at the 1st time, but from second time, it don't write sock to registry

with the MsgBox( 0, "", $s), i can say it can load sock correctly

but as i check the registry, it don't change the registry from 2nd time

help me

#include <GUIConstants.au3>
#include <IE.au3> 
#Include <File.au3>
#include <WindowsConstants.au3>
#include <TreeViewConstants.au3>
#Include <Array.au3>
#Include <GuiTreeView.au3>
$oIE = _IECreateEmbedded ()
GUICreate( "my bot", 1024 , 760)
$GUIActiveX = GUICtrlCreateObj($oIE, 350, 30, 650, 650)

$button_1 = GUICtrlCreateButton ("load sock", 10, 700, 70)
$button_2 = GUICtrlCreateButton ( "EXIT", 810, 700, 70)
$button_4 = GUICtrlCreateButton ("change ip", 90, 700, 70 )
$button_3 = GUICtrlCreateButton ( "ip.xanta.net", 170, 700, 70)
$treeview = GUICtrlCreateTreeView(10, 30, 300, 650, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
GUICtrlCreateTreeViewItem( "", $treeview)
GUISetState ()
;HotKeySet("{F9}", "ShowMe")


While 1
    $msg = GUIGetMsg() ; this checks for a message/input from the GUI.
    Select
        Case $msg = $GUI_EVENT_CLOSE 
            Exit ; this states, on an exit event, exit the loop.
        Case $msg = $button_2
            exit
        case $msg = $button_1
            loadsock()
        case $msg = $button_3
            checkip()
        case $msg = $button_4
            changeip()
    EndSelect
Wend

func checkip()
    _IENavigate ($oIE,"http://ip.xanta.net", 0)
EndFunc

func changeip()
    $s=GUICtrlRead($treeview, 1)
    MsgBox( 0, "", $s)
If $s="" Then
regwrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\","ProxyEnable","REG_DWORD","0")
DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0)
else
regwrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\","ProxyEnable","REG_DWORD","1")
regwrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\","ProxyServer","REG_SZ","socks="&$s)
DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0)
endif

EndFunc
    
Func loadsock()
    $file = FileOpen( "sock.txt", 0)
$CountLines = _FileCountLines("sock.txt")
If @error = 1 Then
    _GUICtrlTreeView_InsertItem( $treeview, "Unable to open file.")
Else
    for $k = 1 to $CountLines
    Dim $subtree [$CountLines + 1]
    $subtree[$k] = GuiCtrlCreateTreeViewItem(FileReadLine ($file, $k), $treeview)
    next
    FileClose ($file)
EndIf

EndFunc

After your regwrite line add these 2 lines

$result = regread("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\", "ProxyServer")
ConsoleWrite("wrote >" & $s & "<, read >" & $result & "<" & @CRLF)

and tell us what you get.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

i really confused because the console say code don't wrong but the result is wrong

after 3 times change

the consolo say it workwell

but i check by web check ip and in the regedit, it stay at the first proxy

i check registry, it stay same too

i wonder how the consolo read that

Posted Image

Share this post


Link to post
Share on other sites

Regedit doesn't update its display when registry changes are made. To see the current values you must View|Refresh (F5).


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

i know :D, i refreshed and it don't change, webcheck ip show that too

can u try to run it and see what is my error?

Edited by fgthhhh

Share this post


Link to post
Share on other sites

i know :D, i refreshed and it don't change, webcheck ip show that too

can u try to run it and see what is my error?

If the registry reads what you wrote but that value is not displayed in regedit then the value must have been changed again. Add another ConsoleWrite line somewhere like this maybe.

Case $msg = $button_2
 ;exit
 $result = regread("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\", "ProxyServer")
 ConsoleWrite(" read >" & $result & "<" & @CRLF)

so that you can check if the value changes or not by clicking a button.

If you run your script without running IE does it make any difference? Or if you comment out the DLLCalls for InternetSetOption?


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

yeah, u are right, my console show that

wrote >12.135.52.126:51899<, read >socks=12.135.52.126:51899<
 read >socks=12.135.52.126:51899<
wrote >129.93.192.21:3385<, read >socks=129.93.192.21:3385<
 read >socks=12.135.52.126:51899<
wrote >162.83.95.16:22777<, read >socks=162.83.95.16:22777<
 read >socks=12.135.52.126:51899<

DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0)

i think this code make it change it again but i don't know how (i copy this func from someone in our forum :D )

i checked and i just know that

INTERNET_OPTION_SETTINGS_CHANGED

39

Notifies the system that the registry settings have been changed so that it verifies the settings on the next call to InternetConnect. This is used by InternetSetOption.

do u have anyidea to help me

thanks u much

ps:even i delete this code line, it don't change ip :huggles:

Edited by fgthhhh

Share this post


Link to post
Share on other sites

oh. help me pls

Share this post


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
Sign in to follow this  
Followers 0