Number of occurrences of k consecutive 1's in a binary string of length n (containing only 1's and 0's) Say a sequence $\{X_1, X_2,\ldots ,X_n\}$ is given, where $X_p$ is either one or zero ($0 < p < n$). How can I determine the number of strings, which do contain at least one occurrence of consequent $1$'s of length $k$ ($0 < k < n$). 
For example, a string $\{1, 0, 1, 1, 1, 0\}$ is such a string for $n = 6$ and $k = 3$.
Here I have found an answer for arbitrary $n$ and $k = 2$, ($k = 1$ is trivial), but I need a more general answer for any natural number  $k$ smaller than $n$. 

One systematic way(not very cool to do it by hand tho) to do it is using automatons and the Chomsky-Schûtzenberger theorem in the following way.
Case $k = 2$:
The automata that accepts your language(namely $F = \{x\in \{0,1\}^*:\underbrace{11\cdots 11}_{\text{$k$ times}}\in Sub(x)\}$) is described by the image below($S_0$ is the initial state, $S_2$ is the final state and you can just reach that state if you have read $11$ as substring.). From there, by the C-S theorem you have the following set of equations( the equations relate the transition of the automaton, for example, if you see in $S_1$ there is one arrow going out to $S_0$ and the other one to $S_2$ and $x$ measures the number of letters of the transition) $$S_0 = xS_0+xS_1$$$$S_1 = xS_2+xS_0$$$$S_2 = 1+2xS_2,$$
and you want to recover $S_0$ as a power series. Solving for $S_2,$ we get $S_2=\frac{1}{1-2x},$ so $S_1 = xS_0+\frac{x}{1-2x}$ and finally $S_0 = xS_0+x(xS_0+\frac{x}{1-2x})=xS_0+x^2S_0+\frac{x^2}{1-2x}$ which implies $S_0(1-x-x^2)=\frac{x^2}{1-2x},$ so $S_0 = \frac{x^2}{(1-2x)(1-x-x^2)}.$ To recover the numbers you have can do partial fractions and you will end up with $S_0=\frac{1}{1-2x}-\frac{x+1}{1-x-x^2}$ which agrees with the answer in the post you have linked.


General Case:
In the general case you have $k+1$ states, the initial one, say $S_0 = xS_0+xS_1,$ the intermediate states i.e., $1\leq j<k$ $S_j = xS_{j+1}+xS_0$ and the final state $S_k = 1+2xS_k,$ from this $k+1$ equations, you can deduce, first that $S_k = \frac{1}{1-2x}$ and that $$S_{k-1} =xS_k+xS_0=\frac{x}{1-2x}+xS_0 $$
$$S_{k-2} =xS_{k-1}+xS_0=\frac{x^2}{1-2x}+x^2S_0+xS_0,$$
$$\vdots$$
$$S_{k-j}=\frac{x^j}{1-2x}+S_0\sum _{i=1}^{j}x^i=\frac{x^j}{1-2x}+S_0(\frac{1-x^{j+1}}{1-x}-1),$$
and so $$S_1 = S_{k-(k-1)}=\frac{x^{k-1}}{1-2x}+S_0(\frac{1-x^{k}}{1-x}-1),$$ therefore $$S_0 = xS_0+x(\frac{x^{k-1}}{1-2x}+S_0(\frac{1-x^{k}}{1-x}-1))=xS_0+\frac{x^{k}}{1-2x}+S_0(\frac{x^2-x^{k+1}}{1-x}),$$
concluding $$S_0(1-x-\frac{x^2-x^{k+1}}{1-x})=\frac{x^k}{1-2x},$$
So $$S_0=\frac{x^k}{1-2x}(\frac{(1-2x+x^2-x^2+x^{k+1})}{1-x})^{-1}=\frac{x^k(1-x)}{(1-2x)(1-2x+x^{k+1})}.$$
You can extract the numbers from there by saying that $$\frac{x^k(1-x)}{(1-2x)(1-2x+x^{k+1})}=\sum _{i=0}^{\infty}A_ix^i,$$
where $A_i = |\{x\in \{0,1\}^i:\underbrace{11\cdots 11}_{\text{$k$ times}}\in Sub(x)\}|$
