Jump to content

Regwrite, Based On User Selected Radio


Recommended Posts

Im writing an app, that will allow a user to make a change to a registry key, based on one of 4 options. Im using GuiControlCreateRadio, because only 1 change can be made at a time.

#include <GuiConstants.au3>

GuiCreate("Please select the AEC option you require", 310, 150,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

Dim $Sharp, $Smooth, $MaximumSharp, $MaximumSmooth
$Sharp = GuiCtrlCreateRadio("Sharp", 0, 0, 130, 30)
If $Sharp Then RegWrite("HKEY_CURRENT_USER\Software\Ahead\Nero Recode\Preferences", "CompressMode", "REG_DWORD", "00000002")
$MaximumSharp = GuiCtrlCreateRadio("Maximum Sharpness", 0, 30, 160, 40)
If $MaximumSharp then RegWrite("HKEY_CURRENT_USER\Software\Ahead\Nero Recode\Preferences", "CompressMode", "REG_DWORD", "00000003")
$Smooth = GuiCtrlCreateRadio("Smooth", 0, 60, 190, 50)
If $Smooth then RegWrite("HKEY_CURRENT_USER\Software\Ahead\Nero Recode\Preferences", "CompressMode", "REG_DWORD", "00000001")
$MaximumSmooth = GuiCtrlCreateRadio("Maximum Smoothness", 0, 90, 220, 60)
If $MaximumSmooth then RegWrite("HKEY_CURRENT_USER\Software\Ahead\Nero Recode\Preferences", "CompressMode", "REG_DWORD", "00000000")

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
    ;;;
    EndSelect
WEnd
Exit

I have a few questions. :">

How do I get an "OK" button, so I can make the change actually happen?

Will

$MaximumSmooth = GuiCtrlCreateRadio("Maximum Smoothness", 0, 90, 220, 60)
If $MaximumSmooth then RegWrite("HKEY_CURRENT_USER\Software\Ahead\Nero Recode\Preferences", "CompressMode", "REG_DWORD", "00000000")

actually write the variable to the registry? (I can test this pretty easily, when I know how to add the OK button.

Is there anything Im missing, that you guys think would be useful?

Link to comment
Share on other sites

Lookup "GuiCtrlRead" in the helpfile.

And

If $MaximumSmooth then RegWrite("HKEY_CURRENT_USER\Software\Ahead\Nero Recode\Preferences", "CompressMode", "REG_DWORD", "00000000")

should be in your main msgloop ( While 1 $msg = GuiGetMsg()...WEnd) as

If $msg = $MaximumSmooth then RegWrite("HKEY_CURRENT_USER\Software\Ahead\Nero Recode\Preferences", "CompressMode", "REG_DWORD", "00000000")

~cdkid

Edited by cdkid
AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!
Link to comment
Share on other sites

This is what I have now.

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.0
; Author:        A.N.Other <myemail@nowhere.com>
;
; Script Function:
;   Template AutoIt script.
;
; ----------------------------------------------------------------------------

; Script Start - Add your code below here

#include "GUIConstants.au3"

If ProcessExists("recode.exe") then MsgBox(0, "WARNING!!", "Nero Recode is currently running. Please close it, and then click OK to continue.", 5)

;Create Window
GUICreate("Recode AEC changer by Solomon_Broad", 300, 520)
GUICtrlCreateLabel("Please select an AEC setting, and then click apply.", 30, 10)
$okbutton = GUICtrlCreateButton("Apply", 200, 80, 60, 30)
GUICtrlCreateLabel("Commonly used AEC settings", 100, 190, 350, 30)
GUICtrlCreateLabel("90-99.9% - Maximum Sharp", 30, 220, 350, 30)
GUICtrlCreateLabel("80-90% - Sharp", 30, 240, 350, 30)
GUICtrlCreateLabel("65-80% - Smooth", 30, 260, 350, 30)
GUICtrlCreateLabel("< 65% - Maximum Smooth", 30, 280, 350, 30)

;Create CheckBoxes
$MSH = GUICtrlCreateRadio ("Maximum Sharp", 30, 30, 120, 30)
$SH = GUICtrlCreateRadio ("Sharp", 30, 60, 80, 30)
$SM = GUICtrlCreateRadio ("Smooth", 30, 90, 80, 30)
$MSM = GUICtrlCreateRadio ("Maximum Smooth", 30, 120, 120, 30)
$Exit = GUICtrlCreateRadio ("Exit (Make no changes)", 30, 150, 150, 30)
$n1=GUICtrlCreateCheckbox("Open Nero Recode?", 30, 340, 150, 30) 
; Show GUI, and wait for OK to be pressed
GUISetState ()
While GuiGetMsg() <> $okbutton
   Sleep(10)
Wend

$ReadCheck1 = GUICtrlRead($MSH)
$ReadCheck2 = GUICtrlRead($SH)
$ReadCheck3 = GUICtrlRead($SM)
$ReadCheck4 = GUICtrlRead($MSM)
$ReadCheck5 = GUICtrlRead($exit)
GuiDelete();get rid of GUI right away; this is optional

;this actually writes the relevant registry key, depending on which radio button was checked.
If $ReadCheck1 = $GUI_CHECKED THEN RegWrite("HKEY_CURRENT_USER\Software\Ahead\Nero Recode\Preferences", "CompressMode", "REG_DWORD", "00000003")
If $ReadCheck2 = $GUI_CHECKED THEN RegWrite("HKEY_CURRENT_USER\Software\Ahead\Nero Recode\Preferences", "CompressMode", "REG_DWORD", "00000002")
If $ReadCheck3 = $GUI_CHECKED THEN RegWrite("HKEY_CURRENT_USER\Software\Ahead\Nero Recode\Preferences", "CompressMode", "REG_DWORD", "00000001")
If $ReadCheck4 = $GUI_CHECKED Then RegWrite("HKEY_CURRENT_USER\Software\Ahead\Nero Recode\Preferences", "CompressMode", "REG_DWORD", "00000000")    
If $ReadCheck5 = $GUI_CHECKED Then Exit

#include <GUIConstants.au3>

Do
    $msg = GUIGetMsg()
    if $msg = $n1 then
        Run("Notepad.exe")
    endif
Until $msg = $GUI_EVENT_CLOSE 
Exit

The section with the radio boxes works fine, and writes the relevant data to the registry correctly, depending on which radio is checked. However, I want the option to launch Recode, if the user asks for it. I was using this code

Do
    $msg = GUIGetMsg()
    if $msg = $n1 then
        Run("C:\WINNT\system32\Notepad.exe")
    endif
Until $msg = $GUI_EVENT_CLOSE

to check if the button was checked, and then launch notepad, to see if the code was working, but I cant work out how to get it to work. Selecting a radio button and clicking Apply makes the changes to the registry, and the GUI closes, but the system tray icon is still running, and the checkbox does nothing at all.

Link to comment
Share on other sites

  • Moderators

Maybe try this, your kind of all over the place, not quite sure I know why your doing things after the loop, and not within it. I'll show an example of what I'm talking about, but you'll see the issue if your wanting to keep it the same:

#include "GUIConstants.au3"
If ProcessExists("recode.exe") Then MsgBox(0, "WARNING!!", "Nero Recode is currently running. Please close it, and then click OK to continue.", 5)
;Create Window
GUICreate("Recode AEC changer by Solomon_Broad", 300, 520)
GUICtrlCreateLabel("Please select an AEC setting, and then click apply.", 30, 10)
$okbutton = GUICtrlCreateButton("Apply", 200, 80, 60, 30)
GUICtrlCreateLabel("Commonly used AEC settings", 100, 190, 350, 30)
GUICtrlCreateLabel("90-99.9% - Maximum Sharp", 30, 220, 350, 30)
GUICtrlCreateLabel("80-90% - Sharp", 30, 240, 350, 30)
GUICtrlCreateLabel("65-80% - Smooth", 30, 260, 350, 30)
GUICtrlCreateLabel("< 65% - Maximum Smooth", 30, 280, 350, 30)

;Create CheckBoxes
$MSH = GUICtrlCreateRadio ("Maximum Sharp", 30, 30, 120, 30)
$SH = GUICtrlCreateRadio ("Sharp", 30, 60, 80, 30)
$SM = GUICtrlCreateRadio ("Smooth", 30, 90, 80, 30)
$MSM = GUICtrlCreateRadio ("Maximum Smooth", 30, 120, 120, 30)
$Exit = GUICtrlCreateRadio ("Exit (Make no changes)", 30, 150, 150, 30)
$n1 = GUICtrlCreateCheckbox("Open Nero Recode?", 30, 340, 150, 30)
; Show GUI, and wait for OK to be pressed
GUISetState ()
While 1
    $MSG = GUIGetMsg()
    If $MSG = $okbutton Then
        If BitAND(GUICtrlRead($MSH), $GUI_CHECKED) = $GUI_CHECKED Then RegWrite("HKEY_CURRENT_USER\Software\Ahead\Nero Recode\Preferences", "CompressMode", "REG_DWORD", "00000003")
        If BitAND(GUICtrlRead($SH), $GUI_CHECKED) = $GUI_CHECKED Then RegWrite("HKEY_CURRENT_USER\Software\Ahead\Nero Recode\Preferences", "CompressMode", "REG_DWORD", "00000002")
        If BitAND(GUICtrlRead($SM), $GUI_CHECKED) = $GUI_CHECKED Then RegWrite("HKEY_CURRENT_USER\Software\Ahead\Nero Recode\Preferences", "CompressMode", "REG_DWORD", "00000001")
        If BitAND(GUICtrlRead($MSM), $GUI_CHECKED) = $GUI_CHECKED Then RegWrite("HKEY_CURRENT_USER\Software\Ahead\Nero Recode\Preferences", "CompressMode", "REG_DWORD", "00000000")    
        If BitAND(GUICtrlRead($exit), $GUI_CHECKED) = $GUI_CHECKED Then Exit
        If BitAND(GUICtrlRead($n1), $GUI_CHECKED) = $GUI_CHECKED Then
            Run("Notepad.exe")
        Endif
        ExitLoop
    EndIf       
   Sleep(10)
Wend

Edited by SmOke_N

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

Maybe try this, your kind of all over the place, not quite sure I know why your doing things after the loop, and not within it.

Its because I dont know what Im doing. :"> Big big thanks for your help, though. It works perfectly. :think:

Link to comment
Share on other sites

  • Moderators

Its because I dont know what Im doing. :"> Big big thanks for your help, though. It works perfectly. :think:

Actually you were really close... Yours still worked when I used a variable like you have for
$ReadCheck5 = GUICtrlRead($exit)
, I made one called
$Readn1 = GUICtrlRead($n1)
, then in the last loop I took that out and just did:
If $Readn1 = $GUI_CHECKED Then
So you were on target, just missed that last GUICtrlRead().

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

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