Jump to content

Recommended Posts

Posted (edited)

This is very very annoying I have 3 check box's which correspond or should to regwrite statements when a button is pushed here is what that looks like

Case $nMsg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $nMsg = $Button2
            $varcb1 = GUICtrlRead($Checkbox1)
            $varcb2 = GUICtrlRead($Checkbox2)
            $varcb3 = GUICtrlRead($Checkbox3)
            
            If $varcb1 Then RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management", "PagingFiles", "REG_SZ", "C:\pagefile.sys 0 0")
            If $varcb2 Then RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management", "PagingFiles", "REG_SZ", "D:\pagefile.sys 0 0")
            If $varcb3 Then RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management", "PagingFiles", "REG_SZ", "E:\pagefile.sys 0 0")

Ok it works but whateever check box is checked for some reason it keeps running E or cb3

I had it like this and it did the same thing

If GUICtrlRead($Checkbox1) RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management", "PagingFiles", "REG_SZ", "C:\pagefile.sys 0 0")

that was how all 3 looked with the corresponding input please help

oh with the variable to now i have to hit the button 2 times it seems to get it to go.

Edited by RyanOlson
Posted (edited)

opt("setoneventmode", 1)
;your GUI goes here
Guictrlsetonevent($Button1, "Button1")

func Button1()
        $msg = GuiGetMsg()
        Select
            Case $msg = $radio1 And BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED
                RegWrite(\"HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Memory Management\", \"PagingFiles\", \"REG_SZ\", \"C:\\pagefile.sys 0 0\")
            Case $msg = $radio2 And BitAND(GUICtrlRead($radio2), $GUI_CHECKED) = $GUI_CHECKED
                RegWrite(\"HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Memory Management\", \"PagingFiles\", \"REG_SZ\", \"D:\\pagefile.sys 0 0\")
            Case $msg = $radio3 And BitAND(GUICtrlRead($radio3), $GUI_CHECKED) = $GUI_CHECKED
                RegWrite(\"HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Memory Management\", \"PagingFiles\", \"REG_SZ\", \"E:\\pagefile.sys 0 0\")
        EndSelect
    WEnd
EndFunc

:P

This should work fine

Edit: This was the last edit, it's ok now :)

Edited by Kiti
Posted (edited)

GuiCtrlRead() on a checkbox returns the state, $GUI_CHECKED or $GUI_UNCHECKED, not true/false. To test the status, use this method:

$varcb1 = GUICtrlRead($Checkbox1)
If BitAnd($varcb1, $GUI_CHECKED) Then RegWrite(etc...)

:)

Edit: Modified to mask for result, because Checked/Unchecked is mixed in with Hidden/Visible, Enable/Disable, etc.

P.S. To get just a True/False check of the control, you could use ControlCommand() with "IsChecked".

:P

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Posted

GuiCtrlRead() on a checkbox returns the state, $GUI_CHECKED or $GUI_UNCHECKED, not true/false. To test the status, use this method:

$varcb1 = GUICtrlRead($Checkbox1)
If BitAnd($varcb1, $GUI_CHECKED) Then RegWrite(etc...)

:)

Edit: Modified to mask for result, because Checked/Unchecked is mixed in with Hidden/Visible, Enable/Disable, etc.

P.S. To get just a True/False check of the control, you could use ControlCommand() with "IsChecked".

:P

Salty your the man once again still new at this and from the example I did not see that I need to check if the return was checked but that works thanks.

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
  • Recently Browsing   0 members

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