Sign in to follow this  
Followers 0
Chimaera

Hidden Button on Gui

6 posts in this topic

Im trying to make a button that is hidden on a gui unless its my copy so i can check on work done by the other lads etc (and yes im in a position where i need to do that to keep an eye on stuff).

Anyway i set the button up like this

If FileExists( @ScriptDir & "\xtrabutton.dll") Then
    Local $ViewFolButton = GUICtrlCreateButton(" View Tech Edits ", 142, 475, 130, 30)
EndIf

So it has a hidden file on my pendrive that only i have  which has to exist for the button to show

All good so far, until i started adding a Case for the button

Case $ViewFolButton
            ShellExecute(@AppDataDir & "\SaveFolder")

Now the gui just flashes and dissapers when i have the Case in the script 

I cant find a way to allow the case statement when the button doesnt exist at the times when the hidden file doesnt exist

Any suggestions?

Share this post


Link to post
Share on other sites



before everything begins, declare $ViewFolButton and assign to it any meaningless value, like 9999 (or Dummy control i think will work also). then create it as you already do, but omit the Local keyword.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Something similar to what the others said.

I often do this when I have a MORE / LESS button on a GUI, for all controls that are on the expanded MORE GUI.

so

If FileExists( @ScriptDir & "\xtrabutton.dll") Then
     Local $ViewFolButton = GUICtrlCreateButton(" View Tech Edits ", 142, 475, 130, 30)
     $exist = 1
Else
     $exist = 2
EndIf

and then

Case $ViewFolButton And $exist = 1
            ShellExecute(@AppDataDir & "\SaveFolder"

'

'

P.S. What is happening with your current setup, is that that Case argument always runs (i.e. Case = "").

Edited by TheSaint

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

Or just create the button in all cases, but hide it if the file does not exist.

#include <GUIConstantsEx.au3>


$gui = GUICreate("GUI")
$Shownbutton = GUICtrlCreateButton("Shown", 10, 10)
$Hiddenbutton = GUICtrlCreateButton("Shown", 10, 40)

If FileExists(@ScriptDir & "\file.ext") Then
    GUICtrlSetState(-1, $GUI_SHOW)
Else
    GUICtrlSetState(-1, $GUI_HIDE)
EndIf

GUISetState()
Do
Until GUIGetMsg() = -3

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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