Jump to content

creating a toggle button..


Recommended Posts

hi, i have a little hill i have to conquer, i make my program now i want to make have settings that it will remember.. i have been experimenting.. and got a little lost

#include <GUIConstants.au3>
GUICreate("Toggle", 200, 200, 302, 218, -1)
$Button100 = GuiCtrlCreateButton("Toggle options", 66, 145, 110, 30)

GUISetState(@SW_SHOW)
GuiSetState()

GuiSetState ()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
        
Case $msg = $button100
GUICreate("Options", 200, 200, 302, 218, -1, $WS_EX_TOPMOST);created new window with options


$treeTwo = GuiCtrlCreateTreeView(66, 60, 103, 80, $TVS_CHECKBOXES); new window with options
GuiCtrlCreateTreeViewItem("Enable On top", $treeTwo)
GuiCtrlSetState(-1, $GUI_CHECKED)
GuiCtrlCreateTreeViewItem("Enable tool tips", $treeTwo)
GuiCtrlCreateTreeViewItem("This window", $treeTwo)
GuiCtrlCreateTreeViewItem("whatever", $treeTwo)
GuiCtrlCreateTreeViewItem("Style", $treeTwo)
$Button56 = GuiCtrlCreateButton("Okay", 66, 145, 110, 30); save options to ini file and remember the settings.
GUISetState(@SW_SHOW)
GuiSetState()

#cs
Case $treeTwo 


;Case $msg = $button56
    IniWrite("filenae","%homedrive%%homepath%\Desktop","....","..")
    Iniread("filenae","%homedrive%%homepath%\Desktop","....","..")
;close this window, save settings, and go back to preview window
;Exit
;$msg = $GUI_EVENT_CLOSE
    #ce

    
    
EndSelect
WEnd
Link to comment
Share on other sites

  • Moderators

Not as lost as we are with your question... care to elaborate in detail your plan of action ... then explain what part of the 'plan' isn't working correctly?

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

Not as lost as we are with your question... care to elaborate in detail your plan of action ... then explain what part of the 'plan' isn't working correctly?

I want to create a toggle to disable or enable a part of a script.. for instance enable/disable "always on top", or whatever else i can think of, and then have it save that settings to an ini file, sorry i dont have much experience with code, otherwise i'd give a better example.. :)

Link to comment
Share on other sites

#include <GUIConstants.au3>
GUICreate("Toggle", 200, 200, 302, 218, -1)
$Button100 = GUICtrlCreateButton("Toggle options", 66, 145, 110, 30)

GUISetState(@SW_SHOW)
GUISetState()

GUISetState()
While 1
 $msg = GUIGetMsg()
 Select
  Case $msg = $GUI_EVENT_CLOSE
   ExitLoop
   
  Case $msg = $Button100
   
   $gui2 = GUICreate("Options", 200, 200, 302, 218, -1, $WS_EX_TOPMOST);created new window with options
   
   
   $treeTwo = GUICtrlCreateTreeView(66, 60, 103, 80, $TVS_CHECKBOXES); new window with options
   $tv_item1 = GUICtrlCreateTreeViewItem("Enable On top", $treeTwo)
   GUICtrlSetState(-1, $GUI_CHECKED)
   $tv_item2 = GUICtrlCreateTreeViewItem("Enable tool tips", $treeTwo)
   $tv_item3 = GUICtrlCreateTreeViewItem("This window", $treeTwo)
   $tv_item4 = GUICtrlCreateTreeViewItem("whatever", $treeTwo)
   $tv_item5 = GUICtrlCreateTreeViewItem("Style", $treeTwo)
   $Button56 = GUICtrlCreateCheckbox("Okay", 66, 145, 110, 30,$BS_AUTOCHECKBOX); save options to ini file and remember the settings.
   GUISetState(@SW_SHOW)
   GUISetState()
   
   While 1
    $msg2 = GUIGetMsg( )
    Select
     Case $msg2 = $tv_item1
      If BitAND(GUICtrlRead($tv_item1),$GUI_CHECKED) Then
       ConsoleWrite("Checked item1" & @LF)
      Else
       ConsoleWrite("Un-Checked item1" & @LF)
      EndIf
     Case $msg2 = $tv_item2
      If BitAND(GUICtrlRead($tv_item2),$GUI_CHECKED) Then
       ConsoleWrite("Checked item2" & @LF)
      Else
       ConsoleWrite("Un-Checked item2" & @LF)
      EndIf
     Case $msg2 = $tv_item3
      If BitAND(GUICtrlRead($tv_item3),$GUI_CHECKED) Then
       ConsoleWrite("Checked item3" & @LF)
      Else
       ConsoleWrite("Un-Checked item3" & @LF)
      EndIf
     Case $msg2 = $tv_item4
      If BitAND(GUICtrlRead($tv_item4),$GUI_CHECKED) Then
       ConsoleWrite("Checked item4" & @LF)
      Else
       ConsoleWrite("Un-Checked item4" & @LF)
      EndIf
     Case $msg2 = $tv_item5
      If BitAND(GUICtrlRead($tv_item5),$GUI_CHECKED) Then
       ConsoleWrite("Checked item5" & @LF)
      Else
       ConsoleWrite("Un-Checked item5" & @LF)
      EndIf
      
     Case $msg2 = $Button56
      If BitAND(GUICtrlRead($Button56), $GUI_CHECKED) Then
       IniWrite("filenae", "%homedrive%%homepath%\Desktop", "....", "..")
       IniRead("filenae", "%homedrive%%homepath%\Desktop", "....", "..")
      EndIf
     ;close this window, save settings, and go back to preview window
      ExitLoop
     Case $msg2 = $GUI_EVENT_CLOSE
      ExitLoop
    EndSelect
   WEnd
   GUIDelete($gui2)
 EndSelect
WEnd

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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