ComboBox include strings with "|" and "||

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
danielo515
Posts: 58
Joined: 18 Feb 2015, 15:06

ComboBox include strings with "|" and "||

29 Apr 2015, 05:48

Hello,

I was wondering if there is a way to include "options" in a combo-box that includes "|" and "||" as part of the string. Any way to escape them or any know workaround?

Regards
Guest

Re: ComboBox include strings with "|" and "||

29 Apr 2015, 05:56

Use http://ahkscript.org/docs/commands/Gui.htm#Options "Delimiter: Specifies that the window should use a field separator other than pipe (|)"
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: ComboBox include strings with "|" and "||

29 Apr 2015, 09:33

does the backtick ` not work as escape char? as in `| ?

danielo515
Posts: 58
Joined: 18 Feb 2015, 15:06

Re: ComboBox include strings with "|" and "||

29 Apr 2015, 13:18

Guest wrote:Use http://ahkscript.org/docs/commands/Gui.htm#Options "Delimiter: Specifies that the window should use a field separator other than pipe (|)"
The problem using that option is that it just moves the same problem to another character. I want to allow the user to set any string to be used into the combobox, so they can end using the "new" Delimiter character at some point.
AndreySibiryakov
Posts: 33
Joined: 09 Jan 2015, 13:19

Re: ComboBox include strings with "|" and "||

30 Apr 2015, 06:53

Hello.

Can't you use the following?

comboBoxList := RegExReplace(list, anySignSeperator, "|")
danielo515
Posts: 58
Joined: 18 Feb 2015, 15:06

Re: ComboBox include strings with "|" and "||

30 Apr 2015, 10:51

AndreySibiryakov wrote:Hello.

Can't you use the following?

comboBoxList := RegExReplace(list, anySignSeperator, "|")
Sorry, I don't understand your point at all.

The problem is that the end user can include any string. So what I have to do is to escape the special characters the user could input, not the other way round.
AndreySibiryakov
Posts: 33
Joined: 09 Jan 2015, 13:19

Re: ComboBox include strings with "|" and "||

30 Apr 2015, 13:23

Ok, I understand it. But will the end user edit the code?
If not, you can use RegExReplace command to find and replace any character that user will use.
For example, "space" is used or "tab".
And the end user can enter this sign in a window from where a variable "anySignCharacter" can obtained.
lexikos
Posts: 9592
Joined: 30 Sep 2013, 04:07
Contact:

Re: ComboBox include strings with "|" and "||

30 Apr 2015, 20:10

You can use a character that the user is unlikely (or unable) to enter, such as an ASCII control character. If you're specifically targetting Unicode versions of AutoHotkey, you can use a non-character code point such as Chr(0xFFFF).

Alternatively, you can send ComboBox messages to the control instead of using the Gui commands.
danielo515
Posts: 58
Joined: 18 Feb 2015, 15:06

Re: ComboBox include strings with "|" and "||

01 May 2015, 04:25

lexikos wrote:You can use a character that the user is unlikely (or unable) to enter, such as an ASCII control character. If you're specifically targetting Unicode versions of AutoHotkey, you can use a non-character code point such as Chr(0xFFFF).

Alternatively, you can send ComboBox messages to the control instead of using the Gui commands.
Hello Lexikos. I like your idea of using an ASCII control character, but I'm failing implementing it. Here is how I did it:

Code: Select all

Delim:=Chr(0xFFFF)
gui, mainGui:+Delimiter%Delim%
[.....]
Gui, Add, ComboBox , vTemplate w%templatewidth%, % functionthatjoinsteverything(Delim)
Everything is appearing in the same line.
just me
Posts: 9458
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: ComboBox include strings with "|" and "||

01 May 2015, 04:46

You might want to use CB_AddItem().
danielo515
Posts: 58
Joined: 18 Feb 2015, 15:06

Re: ComboBox include strings with "|" and "||

01 May 2015, 05:36

Hello Lexikos. I end using `a as a separator. It is working for now, but I'm facing a small problem: I'm not able to set a selected item. This is done using "||" normally. What I tried is to use the delimiter twice, but it does not work. Any idea why?

Code: Select all

delim=`a
list:= "hello" . delim . delim . "dude" . delim . "How are you"
danielo515
Posts: 58
Joined: 18 Feb 2015, 15:06

Re: ComboBox include strings with "|" and "||

01 May 2015, 05:39

just me wrote:You might want to use CB_AddItem().
Hello Just me. I thought about using it, but as I have read it has some delay after each addition. It also makes things a bit, more complicated because currently the items are stored on an object, and I just call the join method of that object with the correct delimiter. Anyway, if I use the CB_Additem approach, how do you set a default selected item?
just me
Posts: 9458
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: ComboBox include strings with "|" and "||

01 May 2015, 10:31

danielo515 wrote:... ,but as I have read it has some delay after each addition.
Where did you read it?
danielo515 wrote:... , and I just call the join method of that object with the correct delimiter.
Instead of joining them into a string you could add them directly.
danielo515 wrote: ... ,how do you set a default selected item?
CB_SelectItem()
lexikos
Posts: 9592
Joined: 30 Sep 2013, 04:07
Contact:

Re: ComboBox include strings with "|" and "||

01 May 2015, 20:48

CB_AddItem just sends a CB_ADDSTRING message. If that has a delay, then so must the GUI commands, because they do exactly the same thing.
danielo515 wrote:I like your idea of using an ASCII control character, but I'm failing implementing it.
Funny. Chr(0xFFFF) is not ASCII, but Unicode.
Everything is appearing in the same line.
There are a few possibilities:
  1. You've applied +Delimiter to the wrong GUI.
  2. Your function is using the wrong delimiter.
  3. You're using an ANSI version of AutoHotkey, where Chr(0xFFFF) returns "".
I end using `a as a separator. It is working for now, but I'm facing a small problem: I'm not able to set a selected item.
It works just fine for me, just as you wrote it.

Code: Select all

delim=`a
list:= "hello" . delim . delim . "dude" . delim . "How are you"

Gui +Delimiter%delim%
Gui Add, ComboBox, , %list%
Gui Show

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: filipemb, Ineedhelplz, mapcarter, peter_ahk, Rohwedder and 307 guests