PRoblems with iniwrite and combolist

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Yugo
Posts: 24
Joined: 01 Mar 2018, 05:20

PRoblems with iniwrite and combolist

21 Nov 2018, 11:58

Hi, I have problems to update my ini file when i try to delete a item from the combobox! the program writes the inn entry without the "|". I really struggle to get it work propably. So maybe someone can help me.


here is the problem:

Button-:
Gui, Submit, NoHide
if MyComboBox =
return
SUCECCFULLY DELETE THE ITEM IN THE GUI!
GuiControlGet, Item,,MyComboBox
Control, Delete, %Item%, Combobox1

;ini delete entry
IniDelete, %IniFileName%, Settings, CB ;lösche ganzen eintrag

;catch new list
ControlGet, OutputVar, List, Count Col, ComboBox1

;schreibe neunen eintrag ohne die gelöschte auswahl
IniWrite, %OutputVar%, %IniFileName%, Settings, CB

WRITES INIKEY WITHKOUT THE seperator "|"

thank you

Code: Select all

#NoEnv
SendMode Input 
SetWorkingDir %A_ScriptDir%
#SingleInstance force


SplitPath, A_ScriptName,,,, Name
IniFileName := Name ".ini"
 
If FileExist(IniFileName) {                                 
    IniRead, CB_Liste, %IniFileName%, Settings, CB
    IniRead, Auswahl, %IniFileName%, Settings, AW ; letzter Eintrag        
    }                                                          
 
Gui, +AlwaysOnTop +ToolWindow
Gui, Add, ComboBox, w120 vMyComboBox AltSubmit , %CB_Liste% 
GuiControl, ChooseString, MyComboBox, %Auswahl%  ; letzte Eintragung anzeigen
;Gui, Add, Button,xp+130 yp-1 w30, +
Gui, Add, Button,xp+130 yp w30 Default, >
Gui, Add, Button,xp+33 yp w30 Default, -
Gui, Show,, % A_Space
Return
 

Button+:
    GuiControlGet, MyComboBox
    CB_Liste .= ( CB_Liste ? "|" MyComboBox : MyComboBox )
    Sort, CB_Liste, C D| U
    IniWrite, %CB_Liste%, %IniFileName%, Settings, CB
    IniWrite, %MyComboBox%, %IniFileName%, Settings, AW    
    GuiControl,, MyComboBox, |%CB_Liste%
    GuiControl, ChooseString, MyComboBox, %MyComboBox%
    Return

Button>:
gosub, Button+
Gui, Submit, ;NoHide
gosub, pageinput
return

Button-:
Gui, Submit, NoHide

if MyComboBox =
  return

GuiControlGet, Item,,MyComboBox               
Control, Delete, %Item%, Combobox1

;ini delete entry
IniDelete, %IniFileName%, Settings, CB ;lösche ganzen eintrag

;catch new list
ControlGet, OutputVar, List, Count Col, ComboBox1  

;schreibe neunen eintrag ohne die gelöschte auswahl
IniWrite, %OutputVar%, %IniFileName%, Settings, CB

pageinput:
InputBox, UserInput,, Seite:, , 120, 120
if ErrorLevel
    return
if MyComboBox = ; wenn combobox leer (keine ini) > return!
  return
; NUR ZAHLEN ZULASSEN!
;if USerinput leer > return
else
    ; in var/clipboard speichern? > falls doc grad nicht aktiv, damit angabe nicht umsonst!?
    ;MsgBox, (%MyComboBox%: %UserInput%)
    Send, (%MyComboBox%: %UserInput%)
return

GuiClose:
    ExitApp
    Return
just me
Posts: 9482
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: PRoblems with iniwrite and combolist

22 Nov 2018, 07:00

Code: Select all

;schreibe neunen eintrag ohne die gelöschte auswahl
IniWrite, % StrReplace(OutputVar, "`n", "|"), %IniFileName%, Settings, CB
:?:
Yugo
Posts: 24
Joined: 01 Mar 2018, 05:20

Re: PRoblems with iniwrite and combolist

22 Nov 2018, 09:23

thank you for your reply. unfortunately there are "new lines" in the ini! neither spaces it looks like this


key = item1item2item3item4 and it should be key = item1|Item2|.... because this are combobox/dropdown entries.
Yugo
Posts: 24
Joined: 01 Mar 2018, 05:20

Re: PRoblems with iniwrite and combolist

22 Nov 2018, 09:44

okay just tried out! it works fine! thank you so much. Although the inifile did nit "allow" newlines to write in the main "function" the variable is retrieved with new lines by nature. Thank you!
Yugo
Posts: 24
Joined: 01 Mar 2018, 05:20

Re: PRoblems with iniwrite and combolist

22 Nov 2018, 13:55

so finally i have this script!

when i press es it saves the clipboard content to a docfile with aditional text i cansetup in the combo and inputbox (harvard referencing)

but now because the gui is in a "esc routine" the iniwrite andiniread do not work propably. Maybe you can help me, because i do not get it!

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#SingleInstance force


;todo
; letzte seitenanzahl merken, genausowie mit dem autornamen




;    Name der Ini-Datei festlegen
SplitPath, A_ScriptName,,,, Name
IniFileName := Name ".ini"
 
;   Bisgerige Liste für die ComboBox aus der INI lesen
If FileExist(IniFileName) {                                 
    IniRead, CB_Liste, %IniFileName%, Settings, CB
    IniRead, Auswahl, %IniFileName%, Settings, AW ; letzter Eintrag        
    }                                                          
 
;   Gui erzeugen und anzeigen
Gui, +AlwaysOnTop +ToolWindow
Gui, Add, ComboBox, w120 vMyComboBox AltSubmit , %CB_Liste% ;AltSubmit
GuiControl, ChooseString, MyComboBox, %Auswahl%  ; letzte Eintragung anzeigen
;Gui, Add, Button,xp+130 yp-1 w30, +
Gui, Add, Button,xp+130 yp w30 Default, >
Gui, Add, Button,xp+33 yp w30, -
;Gui, Show,, % A_Space
Return


ESC::

clipboard = ; Empty the clipboard
Send, ^c
ClipWait, 2
if ErrorLevel
{
    MsgBox, The attempt to copy text onto the clipboard failed.
    return
}
line := Clipboard
Gui, Show,, % A_Space
return


/*
;clipboard := ""
;Send, ^c
;line := Clipboard
;Gui, Show,, % A_Space
;FileAppend, %line% (a: b).`n, temp.doc
;clipboard := ""

return
*/


Button+:
    GuiControlGet, MyComboBox
    CB_Liste .= ( CB_Liste ? "|" MyComboBox : MyComboBox )
    Sort, CB_Liste, C D| U
    IniWrite, %CB_Liste%, %IniFileName%, Settings, CB
    IniWrite, %MyComboBox%, %IniFileName%, Settings, AW    
    GuiControl,, MyComboBox, |%CB_Liste%
    GuiControl, ChooseString, MyComboBox, %MyComboBox%
    Return

Button>:
gosub, Button+
Gui, Submit, ;NoHide
gosub, pageinput
return



Button-:
Gui, Submit, NoHide

if MyComboBox =
  return

;löschen des items in der CB
GuiControlGet, Item,,MyComboBox               
Control, Delete, %Item%, Combobox1


;catch new list
ControlGet, OutputVar, List, Count Col, ComboBox1  
IniWrite, % StrReplace(OutputVar, "`n", "|"), %IniFileName%, Settings, CB
return


pageinput:
InputBox, UserInput,, Seite:, , 120, 120
if ErrorLevel
    return
if MyComboBox = ; wenn combobox leer (keine ini) > return!
  return
; NUR ZAHLEN ZULASSEN!
;if USerinput leer > return
else
    ; in var/clipboard speichern? > falls doc grad nicht aktiv, damit angabe nicht umsonst!?
    ;MsgBox, (%MyComboBox%: %UserInput%)
    ;Send, %line% (%MyComboBox%: %UserInput%)
    FileAppend, `n%line% (%MyComboBox%: %UserInput%).`n, temp.doc
return






 

;GuiClose:
;ExitApp
;Return






Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Aqualest, Bing [Bot], jdfnnl, KaayGee and 333 guests