Sign in to follow this  
Followers 0
waardd

RegWrite does not put string in registry <solved>

7 posts in this topic

#1 ·  Posted (edited)

When i run my script it does not write the variables to the registry. Please help.

$igui = GUICreate("Profieleditor", 780, 500, -1, -1, -1)
                                                            
GUISetState(@SW_SHOW)

                                                               Local $RGBfront, $RGBback, $RF, $GF, $BF, $RB, $GB, $BB, $RFlabel, $GFlabel, $BFlabel, $RBlabel, $GBlabel, $BBlabel, $rgbhexfg, $rgbhexbg, $clrlabel1, $colorchoice, $stopbutton
                                                               $RFlabel = GUICtrlCreateInput("0", 10, 15, 50, 20)
                                                               $GFlabel = GUICtrlCreateInput("0", 10, 35, 50, 20)
                                                               $BFlabel = GUICtrlCreateInput("0", 10, 55, 50, 20)
                                                               $RBlabel = GUICtrlCreateInput("255", 70, 15, 50, 20)
                                                               $GBlabel = GUICtrlCreateInput("255", 70, 35, 50, 20)
                                                               $BBlabel = GUICtrlCreateInput("255", 70, 55, 50, 20)
                                                               $RGBlabel = GUICtrlCreateLabel("RGB front    RGB back", 10, 2, 150, 12)
                                                               $clrlabel1 = GUICtrlCreateLabel("Dit is een kleurtest voor de profieleditor", 140, 15, 57, 60)
                                                               _colorbutton()
                                                            
                                                               $colorchoice = GUICtrlCreateButton("kleurkiezen", 10, 105, 74, 20)
                                                            
                                                               Func _colorbutton()
                                                                              $RF = GUICtrlRead ($RFlabel)
                                                                              $GF = GUICtrlRead ($GFlabel)
                                                                              $BF = GUICtrlRead ($BFlabel)
                                                                              Local $RGBfront = $RF&","&$GF&","&$BF
                                                                              $RB = GUICtrlRead ($RBlabel)                                                              
                                                                               $GB = GUICtrlRead ($GBlabel)
                                                                              $BB = GUICtrlRead ($BBlabel)
                                                                              Local $RGBback = $RB&","&$GB&","&$BB      
                                                                              msgbox(0,"",$RGBfront&@CRLF&$RGBback)
                                                                              $rgbhexfg = "0x" & Hex($RF,2) & Hex($GF,2) & Hex($BF,2)
                                                                              $rgbhexbg = "0x" & Hex($RB,2) & Hex($GB,2) & Hex($BB,2)
                                                                              GUICtrlSetColor($clrlabel1, $rgbhexfg)
                                                                              GUICtrlSetBkColor($clrlabel1, $rgbhexbg)
                                                                               RegWrite("HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\TESTPROF", "Colour0", "", $RGBfront)
                                                                          _colorbutton()
                                                            
                                                               $colorchoice = GUICtrlCreateButton("kleurkiezen", 10, 105, 74, 20)
                                                            
                                                               Func _colorbutton()
                                                                              $RF = GUICtrlRead ($RFlabel)
                                                     %2


            
                


    Edited  by waardd
    
    

            
        

        
            
                

    
        
            
        
    


            
        

        
            
                
                
                
            
            
                
            
        
        
    

    
        
            Share this post
            
Link to post
            
            
            

            
                Share on other sites
                

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    

            
        
    


    

                    
                        





(adsbygoogle = window.adsbygoogle || []).push({});




                    
                
                    
                    
                    






    
    
        
MrMitchell   

    
        
    
             15
    
        
    

        
            
                Universalist
            
            

            
                

    
        
    

            
            Active Members
            
            
                

    
        
    
             15
    
        
    

                738 posts
                
                

            
        
    
    
        


    

    
        
            
            
                
            
            
        

        
    #2 · 
            Posted 
            
            
            
        
    

    


            
        
            What the return value of the RegWrite function? Assign the function to a variable and check the result against the help file to see why it's not writing.


            
        

        
            
                

    
        
            
        
    


            
        

        
            
                
                
                
            
            
                
            
        
        
    

    
        
            Share this post
            
Link to post
            
            
            

            
                Share on other sites
                

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    

            
        
    


    

                    
                
                    
                    
                    






    
    
        
JLogan3o13   

    
        
    
             1,018
    
        
    

        
            
                115 and holding
            
            

            
                

    
        
    

            
            Moderators
            
                
            
            
                

    
        
    
             1,018
    
        
    

                8,032 posts
                
                

            
        
    
    
        


    

    
        
            
            
                
            
            
        

        
    #3 · 
            Posted 
            
            
            
        
    

    


            
        
            Hi, Waardd. The RegWrite lines work for me when I add in the type:

RegWrite("HKEY_CURRENT_USERSoftwareSimonTathamPuTTYSessionsTESTPROF", "Colour2", "REG_SZ", $RGBback)

Also, if you want to use the $GUI_EVENT_CLOSE in your Case statement, you need to include GUIConstantsEx.au3


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Your RegWrite command is written wrong. Your 3rd parameter should be the type of key you're writing, it can't be blank as far as I'm aware.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

I've wondered about that as well, BrewManNH. The help file states that it is optional, but I've never gotten it to work without the type.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I think this was brought up before, they're only optional if you don't use any of them, once you use the second parameter you have to use them all or it fails. I can't seem to find the thread or bug trak that mentioned it, but I'll keep looking.

EDIT: Found one started by MvGulik

Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

In some wierd caase it looks like it was happening because is showed the variable first and then tried to use it.

I remoddeled the script a little so it looks like this and it works.

Time to extend the pssibilitys of this script :)

Tnx for al the help!!

#include <GUIConstantsEx.au3>

$igui = GUICreate("Profieleditor", 780, 500, -1, -1, -1)
   
GUISetState(@SW_SHOW)
   ;Building the screen
   
    ;Labels
    Local $RGBfront, $RGBback, $RF, $GF, $BF, $RB, $GB, $BB, $RFlabel, $GFlabel, $BFlabel, $RBlabel, $GBlabel, $BBlabel, $rgbhexfg, $rgbhexbg, $clrlabel1, $colorchoice, $stopbutton
    $RFlabel = GUICtrlCreateInput("0", 10, 15, 50, 20)
    $GFlabel = GUICtrlCreateInput("0", 10, 35, 50, 20)
    $BFlabel = GUICtrlCreateInput("0", 10, 55, 50, 20)
    $RBlabel = GUICtrlCreateInput("255", 70, 15, 50, 20)
    $GBlabel = GUICtrlCreateInput("255", 70, 35, 50, 20)
    $BBlabel = GUICtrlCreateInput("255", 70, 55, 50, 20)
    $RGBlabel = GUICtrlCreateLabel("RGB front    RGB back", 10, 2, 150, 12)
    $clrlabel1 = GUICtrlCreateLabel("Dit is een kleurtest voor de profieleditor", 140, 15, 57, 60)
    _preview()
   
    ;Button creation
    $preview = GUICtrlCreateButton("preview", 10, 105, 74, 20)
    $setprofile = GUICtrlCreateButton("Set profilecolor", 10, 125, 74, 20)
  
   ;End builduing the screen
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
  Exit
Case $preview
  _preview()
Case $setprofile
  _setprofile()
EndSwitch
WEnd
GUISetState()

Func _preview()
_readvalues()
$rgbhexfg = "0x" & Hex($RF,2) & Hex($GF,2) & Hex($BF,2)
$rgbhexbg = "0x" & Hex($RB,2) & Hex($GB,2) & Hex($BB,2)
GUICtrlSetColor($clrlabel1, $rgbhexfg)
GUICtrlSetBkColor($clrlabel1, $rgbhexbg)
EndFunc
Func _setprofile()
_readvalues()
Local $RGBback = $RB&","&$GB&","&$BB
Local $RGBfront = $RF&","&$GF&","&$BF
RegWrite("HKEY_CURRENT_USERSoftwareSimonTathamPuTTYSessionsTESTPROF", "Colour0", "REG_SZ", $RGBfront)
RegWrite("HKEY_CURRENT_USERSoftwareSimonTathamPuTTYSessionsTESTPROF", "Colour2", "REG_SZ", $RGBback)
EndFunc
Func _readvalues()
$RF = GUICtrlRead ($RFlabel)
$GF = GUICtrlRead ($GFlabel)
$BF = GUICtrlRead ($BFlabel)
$RB = GUICtrlRead ($RBlabel)    
$GB = GUICtrlRead ($GBlabel)
$BB = GUICtrlRead ($BBlabel)
Endfunc

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