Jump to content

Regwrite/read not working


Skrip
 Share

Recommended Posts

#include <GUIConstants.au3>
$clear = ""
$Form1 = GUICreate("Logon Message", 622, 213, 192, 125)
$Input1 = GUICtrlCreateInput("", 16, 32, 593, 21)
GUICtrlCreateLabel("Please enter the title of the message...", 16, 8, 184, 17)
GUICtrlCreateLabel("Please enter the message...", 16, 64, 135, 17)
$Input2 = GUICtrlCreateInput("", 16, 88, 593, 84)
$Button1 = GUICtrlCreateButton("Remove Message/Reset Fields", 312, 176, 297, 33, 0)
$Button2 = GUICtrlCreateButton("Set Message", 16, 176, 281, 33, 0)
$tit1 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\WinLogon", "LegalNoticeCaption")
$msg1 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\WinLogon", "LegalNoticeText")
GUICtrlSetData($Input1, $tit1)
GUICtrlSetData($Input2, $msg1)
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button1
        _remove()
    Case $msg = $Button2
        _set()
    EndSelect
WEnd
Exit

Func _remove()
    GUICtrlSetData($Input1, $clear)
    GUICtrlSetData($Input2, $clear)
    _Set()
EndFunc

Func _set()
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\WinLogon", "LegalNoticeCaption", "REG_SZ",  $Input1)
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\WinLogon", "LegalNoticeText", "REG_SZ", $Input2)
    MsgBox(0, "Done", "Message now set, to view your message. Please restart your computer...")
EndFunc

Why doesn't this work...?

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Link to comment
Share on other sites

Func _set()
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\WinLogon", "LegalNoticeCaption", "REG_SZ",  GUICtrlRead($Input1))
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\WinLogon", "LegalNoticeText", "REG_SZ", GUICtrlRead($Input2))
    MsgBox(0, "Done", "Message now set, to view your message. Please restart your computer...")
EndFunc

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

True.

But 1 thing I don't know is why it returns numbers instead of letters...Do you know?

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Link to comment
Share on other sites

True.

But 1 thing I don't know is why it returns numbers instead of letters...Do you know?

you were writing the control id's instead of reading the control and getting the value.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

$Input1 is the handle/control identifier for the control

just using $Input1 gives you that number, which is what you did in the RegWrite

GuiCtrlRead($Input1) gives you the value in that control

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Grr this refuses to work correctly...

Any idea why?

#include <GUIConstants.au3>
$clear = ""
$Form1 = GUICreate("Logon Message", 622, 213, 192, 125)
$Input1 = GUICtrlCreateInput("", 16, 32, 593, 21)
GUICtrlCreateLabel("Please enter the title of the message...", 16, 8, 184, 17)
GUICtrlCreateLabel("Please enter the message...", 16, 64, 135, 17)
$Input2 = GUICtrlCreateInput("", 16, 88, 593, 84)
$Button1 = GUICtrlCreateButton("Remove Message/Reset Fields", 312, 176, 297, 33, 0)
$Button2 = GUICtrlCreateButton("Set Message", 16, 176, 281, 33, 0)
$title1 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\WinLogon", "LegalNoticeCaption")
$msg1 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\WinLogon", "LegalNoticeText")
$title_s1 = GUICtrlRead($title1)
$msg_s1 = GUICtrlRead($msg1)
GUICtrlSetData($Input1, $title_s1)
GUICtrlSetData($Input2, $msg_s1)
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button1
        _remove()
    Case $msg = $Button2
        _set()
    EndSelect
WEnd
Exit

Func _remove()
    GUICtrlSetData($Input1, $clear)
    GUICtrlSetData($Input2, $clear)
    _Set()
EndFunc

Func _set()
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\WinLogon", "LegalNoticeCaption", "REG_SZ",  GUICtrlRead($Input1))
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\WinLogon", "LegalNoticeText", "REG_SZ", GUICtrlRead($Input2))
    MsgBox(0, "Done", "Message now set, to view your message. Please restart your computer...")
EndFunc

I've taken into account to what you said above and applied it as far as I know.

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Link to comment
Share on other sites

Going overboard?

What you have:

$title_s1 = GUICtrlRead($title1)
$msg_s1 = GUICtrlRead($msg1)
GUICtrlSetData($Input1, $title_s1)
GUICtrlSetData($Input2, $msg_s1)

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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