Madza91 Posted November 16, 2007 Share Posted November 16, 2007 Hi .. i have 1 question: How to make to on click on item to uncheck all and check only that clicked item??? expandcollapse popup#include<guiconstants.au3> $inifile = "test.ini" Global $FileMenuItem[23]; "1" more than the items used $file = "test.ini" GUICreate("My Menu") $FileMenu1 = GUICtrlCreateMenu ("&File"); for testing $View2 = GuiCtrlCreateMenu("", $FileMenu1) GUICtrlSetState(-1,@SW_HIDE) $View3 = GUICtrlCreateMenuItem("", $View2) _IniGetSectionNames() GuiSetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $View3 EndSelect WEnd Func _IniGetSectionNames() $varx = IniReadSectionNames($file) If @error Then TrayTip("n3 Adresar", "Nije pronadjen ni jedan jezik! Program je ", 5, 1) Else For $x = 1 To $varx[0] ;MsgBox(4096, "", $varx[$x]) _IniReadInfo($varx[$x]) Next EndIf EndFunc Func _IniReadInfo($sSection) Dim $sValue $var = IniReadSection($file, $sSection) If @error Then MsgBox(4096, "", "Error occured, probably no INI file.") Else $View2 = GuiCtrlCreateMenu($sSection, $FileMenu1) For $i = 1 To $var[0][0] $View3 = GUICtrlCreateMenuItem($var[$i][0], $View2) $sValue = StringSplit($var[$i][1], '') For $x = 1 To $sValue[0] if $sValue[$x] <> '0' Then GUICtrlSetState(-1,$GUI_CHECKED) ElseIf $sValue[$x] <> '1' Then GUICtrlSetState(-1,$GUI_UNCHECKED) EndIf Next Next EndIf EndFunc Test.ini [languages] Srpski=1 English=0 Spanish=1 Japanish=1 [quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :) Link to comment Share on other sites More sharing options...
MrCreatoR Posted November 16, 2007 Share Posted November 16, 2007 uncheck all and check only that clicked item?You mean like radio? Replace this in your script: $View3 = GUICtrlCreateMenuItem($var[$i][0], $View2) With this: $View3 = GUICtrlCreateMenuItem($var[$i][0], $View2, -1, 1) Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
Madza91 Posted November 16, 2007 Author Share Posted November 16, 2007 Yes man, that is what i want thx [quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :) Link to comment Share on other sites More sharing options...
Madza91 Posted November 16, 2007 Author Share Posted November 16, 2007 One more thing, i want to write to ini for all item 0 and to selected 1, how to do that? [quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :) Link to comment Share on other sites More sharing options...
MrCreatoR Posted November 16, 2007 Share Posted November 16, 2007 (edited) write to ini for all item 0 and to selected 1You just check the state of these items: If GuiCtrlRead($Item) = 65 Then ;Item checked Else ;Not Checked EndIf Edited November 16, 2007 by MsCreatoR Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
pacman1176 Posted November 16, 2007 Share Posted November 16, 2007 One more thing, i want to write to ini for all item 0 and to selected 1, how to do that?This should do it. #include <GUIConstants.au3> If GUICtrlRead($View3) = $GUI_CHECKED Then IniWrite($file,"SECTION","KEY","1");1 = checked ElseIf GUICtrlRead($View3) = $GUI_UNCHECKED Then IniWrite($file,"SECTION","KEY","0");1 = checked Endif The ElseIf statement is not necessary, but it serves for an example that $GUI_UNCHECKED also works. Link to comment Share on other sites More sharing options...
MrCreatoR Posted November 16, 2007 Share Posted November 16, 2007 This should do it.Nope... GuiCtrlRead() on menu item return a little different values then other controls, this example shows this: #include <GuiConstants.au3> $Gui = GuiCreate("Test") $Menu = GUICtrlCreateMenu("Test") $MenuItem = GUICtrlCreateMenuItem("Item", $Menu, -1, 1) GUISetState() While 1 $Msg = GUIGetMsg() Switch $Msg Case -3 Exit Case $MenuItem If GUICtrlRead($MenuItem) = $GUI_CHECKED Then MsgBox(0, "", "OK, Item is checked") Else MsgBox(0, "", "Item is Unchecked") EndIf ;Uncomment this and you see the correct results ;~ If GUICtrlRead($MenuItem) = 65 Then ;~ MsgBox(0, "", "OK, Item is checked") ;~ Else ;~ MsgBox(0, "", "Item is Unchecked") ;~ EndIf EndSwitch WEnd Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
Valuater Posted November 16, 2007 Share Posted November 16, 2007 here is how to check checkboxes expandcollapse popupFunc _IsChecked($control) Return BitAND(GUICtrlRead($control), $GUI_CHECKED) = $GUI_CHECKED EndFunc ;==>_IsCheckedoÝ÷ ØLZ^jëh×6#include <GUIConstants.au3> Global $Checkbox[8] ; == GUI generated with Koda == $Miner1 = GUICreate("Conquer Online Auto Miner - Soemaal ~ Elitepvpers.de ©2007 ", 492, 366, 225, 176) GUISetIcon("C:\Program Files\Conquer 2.0\tqzf.ico") GUISetCursor(3) GUISetFont(12, 400, 0, "Times New Roman") GUISetBkColor(0x9DB9EB) $Checkbox[1] = GUICtrlCreateCheckbox("Refine Gem", 24, 64, 153, 33) GUICtrlSetFont(-1, 12, 400, 0, "Times New Roman") GUICtrlSetBkColor(-1, 0x9DB9EB) $Checkbox[2] = GUICtrlCreateCheckbox("Normal Gem", 24, 24, 145, 41) GUICtrlSetFont(-1, 12, 400, 0, "Times New Roman") GUICtrlSetBkColor(-1, 0x9DB9EB) $Checkbox[3] = GUICtrlCreateCheckbox("Super Gem", 24, 96, 169, 33) GUICtrlSetFont(-1, 12, 400, 0, "Times New Roman") GUICtrlSetBkColor(-1, 0x9DB9EB) $Group1 = GUICtrlCreateGroup("Disconnect at", 16, 8, 185, 145) GUICtrlSetFont(-1, 12, 400, 0, "Times New Roman") GUICtrlSetBkColor(-1, 0x9DB9EB) GUICtrlCreateGroup("", -99, -99, 1, 1) $Checkbox[4] = GUICtrlCreateCheckbox("All ores", 264, 24, 145, 33) GUICtrlSetFont(-1, 12, 400, 0, "Times New Roman") GUICtrlSetBkColor(-1, 0x9DB9EB) $Checkbox[5] = GUICtrlCreateCheckbox("Iron/Copper ore", 264, 56, 145, 33) GUICtrlSetFont(-1, 12, 400, 0, "Times New Roman") GUICtrlSetBkColor(-1, 0x9DB9EB) $Checkbox[6] = GUICtrlCreateCheckbox("Iron/Silver ore", 264, 88, 153, 33) GUICtrlSetFont(-1, 12, 400, 0, "Times New Roman") GUICtrlSetBkColor(-1, 0x9DB9EB) $Checkbox[7] = GUICtrlCreateCheckbox("Gold ore", 264, 112, 161, 33) GUICtrlSetFont(-1, 12, 400, 0, "Times New Roman") GUICtrlSetBkColor(-1, 0x9DB9EB) $Group2 = GUICtrlCreateGroup("Ores to Drop", 248, 8, 177, 145) GUICtrlSetFont(-1, 12, 400, 0, "Times New Roman") GUICtrlSetBkColor(-1, 0x9DB9EB) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateLabel("Soemaal's autominer V1.0 Basic oredropper.", 16, 160, 185, 187) GUICtrlSetFont(-1, 12, 400, 0, "Times New Roman") GUICtrlSetBkColor(-1, 0x9DB9EB) $Button = GUICtrlCreateButton("Clear", 300, 230, 100, 50) $Button1 = GUICtrlCreateButton("Done", 300, 300, 100, 50) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button For $x = 1 To UBound($Checkbox) - 1 GUICtrlSetState($Checkbox[$x], $GUI_UNCHECKED) Next Case $msg = $Button1 For $x = 1 To UBound($Checkbox) - 1 If _IsChecked($Checkbox[$x]) Then ; do what you wqant MsgBox(0x0, "Checked", GUICtrlRead($Checkbox[$x], 1) & " was checked", 2) EndIf Next Case Else ;;;;;;; EndSelect WEnd Exit Func _IsChecked($control) Return BitAND(GUICtrlRead($control), $GUI_CHECKED) = $GUI_CHECKED EndFunc ;==>_IsChecked 8) Link to comment Share on other sites More sharing options...
Valuater Posted November 16, 2007 Share Posted November 16, 2007 ini Wrute expandcollapse popup#include <GUIConstants.au3> Global $start Global $way1x, $way1y $showGUI = 0 ; setting the GUI condition HotKeySet("{F6}", "show") ; using hotkey to show menu Read() GUICreate("Testscript", 300, 420) $savebotbutt = GUICtrlCreateButton("Save", 160, 390, 60, 30) ; show the Save button $exitbotbutt = GUICtrlCreateButton("Exit", 220, 390, 80, 30) ; show the Exit button GUICtrlCreateTab(0, 0, 300, 390) $tab2 = GUICtrlCreateTabItem("WayPoints") GUICtrlCreateLabel("Training Ground Location", 10, 30, 200, 20) $checkCN = GUICtrlCreateCheckbox("", 20, 50, 20, 20) ; 1st checkbox location GUICtrlCreateLabel("X : ", 60, 50, 15, 20) ;~ $way1x = Int(IniRead(".\testscript.ini","Waypoints","1x","-1")) $input_x = GUICtrlCreateInput($way1x, 80, 50, 50, 20) GUICtrlCreateLabel("Y : ", 150, 50, 15, 20) ;~ $way1y = Int(IniRead(".\testscript.ini","Waypoints","1y","-1")) $input_y = GUICtrlCreateInput($way1y, 170, 50, 50, 20) GUISetState(@SW_HIDE) While 1 ; main body of program, loop till condition met $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ; when the top right cancel button is pressed Exit Case $msg = $savebotbutt ; pressing the Save button Write() MsgBox(64, "Test Box", "You clicked on Save!") Case $msg = $exitbotbutt ; pressing the Exit button Exit EndSelect WEnd ;;-------------------------------------- Functions -------------------------------- Func show() If $showGUI = 0 Then Read() GUISetState(@SW_SHOW) ; show the menu when hotkey pressed $showGUI = 1 Else GUISetState(@SW_HIDE) ; hide the menu when hotkey pressed $showGUI = 0 EndIf EndFunc ;==>show Func Write() IniWrite(".\testscript.ini", "Waypoints", "1x", GUICtrlRead($input_x)) IniWrite(".\testscript.ini", "Waypoints", "1y", GUICtrlRead($input_y)) EndFunc ;==>Write Func Read() $way1x = Int(IniRead(".\testscript.ini", "Waypoints", "1x", "-1")) $way1y = Int(IniRead(".\testscript.ini", "Waypoints", "1y", "-1")) EndFunc ;==>Rea 8) Link to comment Share on other sites More sharing options...
Madza91 Posted November 16, 2007 Author Share Posted November 16, 2007 Nothing is working :/ I think that's not possible :| ...never mind :/ [quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :) Link to comment Share on other sites More sharing options...
dani Posted November 19, 2007 Share Posted November 19, 2007 Nothing is working :/I think that's not possible :|...never mind :/Seems like you're giving up way too fast, hm? Valuator gives the correct way to read the "checked" status off of a menu item (using BitAND()), so what exactly is the problem ... ? Link to comment Share on other sites More sharing options...
Bowmore Posted November 19, 2007 Share Posted November 19, 2007 (edited) Nothing is working :/ I think that's not possible :| ...never mind :/ Have a look at this. It shows how you can build a menu from an ini file and save the selected menu item to use as the default next time. It could be improved but it does show what is possible. expandcollapse popup#include<guiconstantsEx.au3> $g_sCurrentLanguage = '' $g_IniFile = @ScriptDir & "\test.ini" GUICreate("My Menu") $Gui_FileMenu1 = GUICtrlCreateMenu("&File"); for testing $Gui_LanguageMenu = GUICtrlCreateMenu("&Language", $Gui_FileMenu1) GUICtrlSetState(-1, @SW_HIDE) Global $g_aMenuArray = _InitialiseMenuArray($g_IniFile) ReDim $g_aMenuArray[UBound($g_aMenuArray)][4] $g_aMenuArray[_GetSavedSettings($g_IniFile)][3] = $GUI_CHECKED For $i = 1 To UBound($g_aMenuArray) - 1 $g_aMenuArray[$i][2] = GUICtrlCreateMenuItem("&" & $i & " " & $g_aMenuArray[$i][1], $Gui_LanguageMenu, $i, 1) If $g_aMenuArray[$i][3] Then GUICtrlSetState($g_aMenuArray[$i][2], $GUI_CHECKED) Else GUICtrlSetState($g_aMenuArray[$i][2], $GUI_UNCHECKED) EndIf Next GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else For $i = 1 To UBound($g_aMenuArray) - 1 If $msg = $g_aMenuArray[$i][2] Then For $j = 1 To UBound($g_aMenuArray) - 1 $g_aMenuArray[$j][3] = 0 Next $g_sCurrentLanguage = $g_aMenuArray[$i][1] $g_aMenuArray[$i][3] = 1 MsgBox(0, "Language", "The current selection is " & $g_sCurrentLanguage) EndIf Next EndSelect WEnd _SaveSettings($g_IniFile, $g_aMenuArray) Exit Func _GetSavedSettings($sIniFile) Return IniRead($sIniFile, "SAVED", "language", "2") EndFunc ;==>_GetSavedSettings Func _InitialiseMenuArray($sIniFile) Local $aTemp = IniReadSection($sIniFile, "languages") Return $aTemp EndFunc ;==>_InitialiseMenuArray Func _SaveSettings($sIniFile, ByRef $aMenuArray) For $i = 1 To UBound($aMenuArray) - 1 If $aMenuArray[$i][3] Then $ret = IniWrite($sIniFile, "SAVED", "language", String($i)) EndIf Next EndFunc ;==>_SaveSettings Test.ini [languages] 1=Srpski 2=English 3=Spanish 4=Japanish 5=Klingon [SAVED] language=2 Edit: Fixed typo Edited November 20, 2007 by Bowmore "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
Madza91 Posted November 20, 2007 Author Share Posted November 20, 2007 Tnx man, that is what i want to make.. one more time thank you Bowmore [quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now