Jump to content
Sign in to follow this  
blackman12

[Q] Nonfunctional Button

Recommended Posts

blackman12

#NoTrayIcon
#include <GuiConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
WinSetOnTop("Program Kurulumu","",1)
GuiCreate("Tema Seçim", 640, 460,-1, -1,$WS_POPUP)
$yol = @WindowsDir & "\Resources\Themes\"
$yol2 = @WindowsDir & "\Web\Wallpaper\"
$yol3 = @ScriptDir & "\Kaynak\"
$tab = GUICtrlCreateTab(140, 10, 490, 420)
    
$tab1 = GUICtrlCreateTabItem("Tema")

$label = GUICtrlCreateLabel("Lütfen bir tema seçin:",150,45,110,20)
$combo = GUICtrlCreateCombo("Windows XP",257,40,150,10)
GUICtrlSetData(-1, "Inspirat2|LiveBlue|SevenVG|SidCrafty7", "Windows XP")
GUICtrlSetOnEvent(-1, "TemaFonk")
$Grup = GuiCtrlCreateGroup("Windows XP", 150, 70, 470, 350)
$Onizleme = GuiCtrlCreatePic($yol3 & "Windows XP.jpg", 170, 100, 430, 300)

$tab2 = GUICtrlCreateTabItem("Arkaplan")

$label2 = GUICtrlCreateLabel("Lütfen bir arkaplan seçin:",150,45,120,20)
$combo2 = GUICtrlCreateCombo("BlackXP 0",273,40,150,10)
GUICtrlSetData(-1, "BlackXP 1|BlackXP 2|BlackXP 3|BlackXP 4|BlackXP 5|BlackXP 6|BlackXP 7|BlackXP 8|BlackXP 9|BlackXP 10|BlackXP 11|BlackXP 12|BlackXP 13|BlackXP 14|BlackXP 15|BlackXP 16", "BlackXP 0")
GUICtrlSetOnEvent(-1, "ArtFonk")
$Grup2 = GuiCtrlCreateGroup("BlackXP 0", 150, 70, 470, 350)
$Onizleme2 = GuiCtrlCreatePic($yol2 & "\BlackXP 0.jpg", 170, 100, 430, 300)

GUICtrlCreateTabItem("")
$button = GUICtrlCreateButton("Durdur",555,430,75,25)
$YanPanel = GuiCtrlCreatePic($yol3 & "tema.jpg", 0, 0, 130, 460)

GuiSetState(@SW_SHOW)
While 1
    Sleep(10)
WEnd

Func ArtFonk()
    Select
        case $combo2
            $resim = Guictrlread($combo2)
            Guictrlsetimage($Onizleme2,$yol2 & $resim & ".jpg")
            GUICtrlSetData($Grup2,$resim)
    EndSelect
EndFunc

func TemaFonk()
    Select
        case $combo 
            $data = Guictrlread($combo)
            Guictrlsetimage($Onizleme,$yol3 & $data & ".jpg")
            GUICtrlSetData($grup,$data) 
        case $button
            $data = Guictrlread($combo)
            DirMove($yol & $data,$yol & "BlackXP",1)
            FileMove($yol & "BlackXP\" & $data & ".msstyles",$yol & "BlackXP\blackxp.msstyles",1)
            $resim = Guictrlread($combo2)
            RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "Wallpaper", "REG_SZ", $yol2 & $resim & ".jpg")
    EndSelect
EndFunc

My codes are these.But button doesnt work.What is the problem?

#NoTrayIcon
#include <GuiConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
WinSetOnTop("Program Kurulumu","",1)
$reg = RegRead("HKEY_CURRENT_USER\BlackXP", "ProgramDeger")
if $reg = "Hayır" then
    Program()
    RunWait(@ScriptDir & "\inceayar.exe")
    Exit
Else
    RunWait(@ScriptDir & "\inceayar.exe")
    Exit
EndIf

func program()
    GuiCreate("Tema Seçim", 640, 460,-1, -1,$WS_POPUP)
    $yol = @WindowsDir & "\Resources\Themes\"
    $yol2 = @WindowsDir & "\Web\Wallpaper\"
    $yol3 = @ScriptDir & "\Kaynak\"
    $tab = GUICtrlCreateTab(140, 10, 490, 420)
        
    $tab1 = GUICtrlCreateTabItem("Tema")

    $label = GUICtrlCreateLabel("Lütfen bir tema seçin:",150,45,110,20)
    $combo = GUICtrlCreateCombo("Windows XP",257,40,150,10)
    GUICtrlSetData(-1, "Inspirat2|LiveBlue|SevenVG|SidCrafty7", "Windows XP")
    GUICtrlSetOnEvent(-1, "TemaFonk")
    $Grup = GuiCtrlCreateGroup("Windows XP", 150, 70, 470, 350)
    $Onizleme = GuiCtrlCreatePic($yol3 & "Windows XP.jpg", 170, 100, 430, 300)

    $tab2 = GUICtrlCreateTabItem("Arkaplan")

    $label2 = GUICtrlCreateLabel("Lütfen bir arkaplan seçin:",150,45,120,20)
    $combo2 = GUICtrlCreateCombo("BlackXP 0",273,40,150,10)
    GUICtrlSetData(-1, "BlackXP 1|BlackXP 2|BlackXP 3|BlackXP 4|BlackXP 5|BlackXP 6|BlackXP 7|BlackXP 8|BlackXP 9|BlackXP 10|BlackXP 11|BlackXP 12|BlackXP 13|BlackXP 14|BlackXP 15|BlackXP 16", "BlackXP 0")
    GUICtrlSetOnEvent(-1, "ArtFonk")
    $Grup2 = GuiCtrlCreateGroup("BlackXP 0", 150, 70, 470, 350)
    $Onizleme2 = GuiCtrlCreatePic($yol2 & "\BlackXP 0.jpg", 170, 100, 430, 300)

    GUICtrlCreateTabItem("")
    $button = GUICtrlCreateButton("Durdur",555,430,75,25)
    $YanPanel = GuiCtrlCreatePic($yol3 & "tema.jpg", 0, 0, 130, 460)

    GuiSetState(@SW_SHOW)
    While 1
        Sleep(10)
    WEnd
EndFunc

Func ArtFonk()
    Select
        case $combo2
            $resim = Guictrlread($combo2)
            Guictrlsetimage($Onizleme2,$yol2 & $resim & ".jpg")
            GUICtrlSetData($Grup2,$resim)
    EndSelect
EndFunc

func TemaFonk()
    Select
        case $combo 
            $data = Guictrlread($combo)
            Guictrlsetimage($Onizleme,$yol3 & $data & ".jpg")
            GUICtrlSetData($grup,$data) 
        case $button
            $data = Guictrlread($combo)
            DirMove($yol & $data,$yol & "BlackXP",1)
            FileMove($yol & "BlackXP\" & $data & ".msstyles",$yol & "BlackXP\blackxp.msstyles",1)
            $resim = Guictrlread($combo2)
            RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "Wallpaper", "REG_SZ", $yol2 & $resim & ".jpg")
    EndSelect
EndFunc

or what is the problem now?

Share this post


Link to post
Share on other sites
Authenticity

This -> $button = GUICtrlCreateButton("Durdur",555,430,75,25)

and this -> case $button

can't work because you didn't register on event function 'TemaFonk' to the control

Edit: use the @GUI_CtrlId macro instead to distinguish between the control. like 'Case @GUI_CtrlId = $button Then'

Edited by Authenticity

Share this post


Link to post
Share on other sites
FireFox

@BlackMan12

I see that you use GuiOnEventMode, so you cant merge it with guiregistermsg...

after your control, for make it on event, just write this line :

; -1 = up line, can be remplaced with $variable of control
GuiCtrlSetOnEvent(-1, "function")

Cheers, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
blackman12

how i did leave this detail out of account.Very thanks guys.

Share this post


Link to post
Share on other sites
blackman12

Thanks guys but.These codes are correct...

#NoTrayIcon
#include <GuiConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
WinSetOnTop("Program Kurulumu","",1)
GuiCreate("Tema Seçim", 640, 460,-1, -1,$WS_POPUP)
$yol = @WindowsDir & "\Resources\Themes\"
$yol2 = @WindowsDir & "\Web\Wallpaper\"
$yol3 = @ScriptDir & "\Kaynak\"
$tab = GUICtrlCreateTab(140, 10, 490, 420)
    
$tab1 = GUICtrlCreateTabItem("Tema")

$label = GUICtrlCreateLabel("Lütfen bir tema seçin:",150,45,110,20)
$combo = GUICtrlCreateCombo("Windows XP",257,40,150,10)
GUICtrlSetData(-1, "Inspirat2|LiveBlue|SevenVG|SidCrafty7", "Windows XP")
GUICtrlSetOnEvent(-1, "TemaFonk")
$Grup = GuiCtrlCreateGroup("Windows XP", 150, 70, 470, 350)
$Onizleme = GuiCtrlCreatePic($yol3 & "Windows XP.jpg", 170, 100, 430, 300)

$tab2 = GUICtrlCreateTabItem("Arkaplan")

$label2 = GUICtrlCreateLabel("Lütfen bir arkaplan seçin:",150,45,120,20)
$combo2 = GUICtrlCreateCombo("BlackXP 0",273,40,150,10)
GUICtrlSetData(-1, "BlackXP 1|BlackXP 2|BlackXP 3|BlackXP 4|BlackXP 5|BlackXP 6|BlackXP 7|BlackXP 8|BlackXP 9|BlackXP 10|BlackXP 11|BlackXP 12|BlackXP 13|BlackXP 14|BlackXP 15|BlackXP 16", "BlackXP 0")
GUICtrlSetOnEvent(-1, "ArtFonk")
$Grup2 = GuiCtrlCreateGroup("BlackXP 0", 150, 70, 470, 350)
$Onizleme2 = GuiCtrlCreatePic($yol2 & "\BlackXP 0.jpg", 170, 100, 430, 300)

GUICtrlCreateTabItem("")
$button = GUICtrlCreateButton("Durdur",555,430,75,25)
GUICtrlSetOnEvent(-1, "Program")
$YanPanel = GuiCtrlCreatePic($yol3 & "tema.jpg", 0, 0, 130, 460)

GuiSetState(@SW_SHOW)
While 1
    Sleep(10)
WEnd

Func ArtFonk()
    Select
        case $combo2
            $resim = Guictrlread($combo2)
            Guictrlsetimage($Onizleme2,$yol2 & $resim & ".jpg")
            GUICtrlSetData($Grup2,$resim)
    EndSelect
EndFunc

func TemaFonk()
    Select
        case $combo 
            $data = Guictrlread($combo)
            Guictrlsetimage($Onizleme,$yol3 & $data & ".jpg")
            GUICtrlSetData($grup,$data) 
    EndSelect
EndFunc

Func Program()
    Select
        case $button
            $data = Guictrlread($combo)
            DirMove($yol & $data,$yol & "BlackXP",1)
            FileMove($yol & "BlackXP\" & $data & ".msstyles",$yol & "BlackXP\blackxp.msstyles",1)
            $resim = Guictrlread($combo2)
            RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "Wallpaper", "REG_SZ", $yol2 & $resim & ".jpg")
    EndSelect
EndFunc

But these codes are incorrect.

#NoTrayIcon
#include <GuiConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
WinSetOnTop("Program Kurulumu","",1)
GuiCreate("Tema Seçim", 640, 460,-1, -1,$WS_POPUP)
$yol = @WindowsDir & "\Resources\Themes\"
$yol2 = @WindowsDir & "\Web\Wallpaper\"
$yol3 = @ScriptDir & "\Kaynak\"

$var = RegRead("HKEY_CURRENT_USER\BlackXP","TemaDeger")
if $var = "Hayır" Then
    Program()
Else
    Exit
EndIf

Func Program()
    $tab = GUICtrlCreateTab(140, 10, 490, 420)
    $tab1 = GUICtrlCreateTabItem("Tema")

    $label = GUICtrlCreateLabel("Lütfen bir tema seçin:",150,45,110,20)
    $combo = GUICtrlCreateCombo("Windows XP",257,40,150,10)
    GUICtrlSetData(-1, "Inspirat2|LiveBlue|SevenVG|SidCrafty7", "Windows XP")
    GUICtrlSetOnEvent(-1, "TemaFonk")
    $Grup = GuiCtrlCreateGroup("Windows XP", 150, 70, 470, 350)
    $Onizleme = GuiCtrlCreatePic($yol3 & "Windows XP.jpg", 170, 100, 430, 300)

    $tab2 = GUICtrlCreateTabItem("Arkaplan")

    $label2 = GUICtrlCreateLabel("Lütfen bir arkaplan seçin:",150,45,120,20)
    $combo2 = GUICtrlCreateCombo("BlackXP 0",273,40,150,10)
    GUICtrlSetData(-1, "BlackXP 1|BlackXP 2|BlackXP 3|BlackXP 4|BlackXP 5|BlackXP 6|BlackXP 7|BlackXP 8|BlackXP 9|BlackXP 10|BlackXP 11|BlackXP 12|BlackXP 13|BlackXP 14|BlackXP 15|BlackXP 16", "BlackXP 0")
    GUICtrlSetOnEvent(-1, "ArtFonk")
    $Grup2 = GuiCtrlCreateGroup("BlackXP 0", 150, 70, 470, 350)
    $Onizleme2 = GuiCtrlCreatePic($yol2 & "\BlackXP 0.jpg", 170, 100, 430, 300)

    GUICtrlCreateTabItem("")
    $button = GUICtrlCreateButton("Durdur",555,430,75,25)
    GUICtrlSetOnEvent(-1, "Uygula")
    $YanPanel = GuiCtrlCreatePic($yol3 & "tema.jpg", 0, 0, 130, 460)
EndFunc

GuiSetState(@SW_SHOW)
While 1
    Sleep(10)
WEnd

Func ArtFonk()
    Select
        case $combo2
            $resim = Guictrlread($combo2)
            Guictrlsetimage($Onizleme2,$yol2 & $resim & ".jpg")
            GUICtrlSetData($Grup2,$resim)
    EndSelect
EndFunc

func TemaFonk()
    Select
        case $combo 
            $data = Guictrlread($combo)
            Guictrlsetimage($Onizleme,$yol3 & $data & ".jpg")
            GUICtrlSetData($grup,$data) 
    EndSelect
EndFunc

Func Uygula()
    Select
        case $button
            $data = Guictrlread($combo)
            DirMove($yol & $data,$yol & "BlackXP",1)
            FileMove($yol & "BlackXP\" & $data & ".msstyles",$yol & "BlackXP\blackxp.msstyles",1)
            $resim = Guictrlread($combo2)
            RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop", "Wallpaper", "REG_SZ", $yol2 & $resim & ".jpg")
    EndSelect
EndFunc

What is the problem?Autoit says:

Variable used without being declared for "case $combo2" => "case ^"

Edited by blackman12

Share this post


Link to post
Share on other sites
Authenticity

It's that the function Program is creating this control with local scope so it's not exist outside it, declare it as global in the header for easy solution.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.