Sign in to follow this  
Followers 0
AcidCorps

Change variable from within function

7 posts in this topic

I have a script that creates a gui using xskin, I have manually inserted a help, minimize, and close button on the title bar, what I'm trying to do is make it so that when the help button is pressed it acts like windows help buttons due meaning when the user clicks the help button and then clicks another part of the gui it will give a description of that part of the gui. so here's the script

#include <XSkin.au3>
#include <Array.au3> ;Testing purposes only
#include <GuiConstants.au3>

Global $GuiHelpMode = 0

XSkinGUICreate('', 400, 500, @ScriptDir & '\Skin')

;Title Bar
GuiCtrlCreateLabel('LacWare Archiver', 20, 7, 90, 15)
GuiCtrlSetBKColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GuiCtrlSetColor(-1, IniRead($Skin_Folder & "\Skin.dat", "color", "background", 0xD9F6FF))
XSkinButton('X', 365, 8, 12, 12, '_Exit')
Guictrlsetfont(-1, 8.5, 575)
XSkinButton('-- ', 353, 8, 12, 12, '_Minimize')
GUiCtrlSetFont(-1, 16, 400, 4)
XSkinButton('?', 341, 8, 12, 12, '_Help')
GuiCtrlSetFont(-1, 8.5, 575)

XSkinButton('Test Button', 50, 50, 50, 50, '_TestButton')

GUISetState()
While 1
   
    MouseOver()
   
    Sleep(10)
WEnd

Func _Exit()
    Exit
EndFunc
 
Func _Minimize()
    GuiSetState(@SW_Minimize)
EndFunc

Func _Help()
    If $GuiHelpMode = 0 Then Global $GuiHelpMode = 1
    If $GuiHelpMode = 1 Then Global $GuiHelpMode = 0
EndFunc

Func _TestButton()
    If $GuiHelpMode = 0 Then MsgBox(0,'','Action')
    If $GuiHelpMode = 1 Then Msgbox(0,'','Help')
EndFunc

as you can see the way I was trying to do this is to create a variable $GuiHelpMode that is set to 0 in the beginning of the script and when the button is pressed it runs _Help() which should change it from 0 to 1 and 1 to 0 and then using _TestButton it will do an action if the help mode is 0 and show a description if help mode is 1.

anyone know why this isn't working, or if anyone has an easier way to do this I would be intested in seeing how it would be done.

Share this post


Link to post
Share on other sites



Func _Help()
    $GuiHelpMode = 1
EndFunc
Func _TestButton()
    If $GuiHelpMode Then
        $GuiHelpMode = 0
        Msgbox(0,'','Help')
    Else
        MsgBox(0,'','Action')
    EndIf
EndFunc


"be smart, drink your wine"

Share this post


Link to post
Share on other sites

I need Func _Help() to be the one that changes the mode, I tried yours and it still didn't change the mode even when _TestButton was run

Share this post


Link to post
Share on other sites

Func _Help()
    If $GuiHelpMode = 0 Then
      $GuiHelpMode = 1
    Else
      $GuiHelpMode = 0
    EndIf
EndFunc

This worked for me but I wasn't using XSkin either.

You should really test this by putting a MsgBox at the top of this function to make sure it's being called

MsgBox(0, "Test", "The function was called") will do it


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

............ Like This!!!

#include <XSkin.au3>
#include <Array.au3> ;Testing purposes only
#include <GuiConstants.au3>

Global $GuiHelpMode = 0

XSkinGUICreate('', 400, 500, @ScriptDir & '\Skins\Valor')

;Title Bar
GuiCtrlCreateLabel('LacWare Archiver', 20, 7, 90, 15)
GuiCtrlSetBKColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GuiCtrlSetColor(-1, IniRead($Skin_Folder & "\Skin.dat", "color", "background", 0xD9F6FF))
XSkinButton('X', 365, 8, 12, 12, '_Exit')
Guictrlsetfont(-1, 8.5, 575)
XSkinButton('-- ', 353, 8, 12, 12, '_Minimize')
GUiCtrlSetFont(-1, 16, 400, 4)
XSkinButton('?', 341, 8, 12, 12, '_Help')
GuiCtrlSetFont(-1, 8.5, 575)

XSkinButton('Test Button', 50, 50, 150, 50, '_TestButton')

GUISetState()
While 1
   
    MouseOver()
   
    Sleep(10)
WEnd

Func _Exit()
    Exit
EndFunc
 
Func _Minimize()
    GuiSetState(@SW_Minimize)
EndFunc

Func _Help()
    $GuiHelpMode = Not $GuiHelpMode
    If $GuiHelpMode Then
        ToolTip("Please select the control", 20, 20, "Help Mode", 1)
    Else
        ToolTip("")
    EndIf
EndFunc

Func _TestButton()
    If $GuiHelpMode Then
        Msgbox(0,'','Help')
    Else
        MsgBox(0,'','Action')
    EndIf
EndFunc

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

Listen to the man that knows XSkin and ignore the rest of us. We were just killing time waiting for him to show up anyway. :)


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Listen to the man that knows XSkin and ignore the rest of us. We were just killing time waiting for him to show up anyway. :)

;) ... LMAO

8)


NEWHeader1.png

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