how to create dynamic text label autohotkey - dynamic

I'm trying to create a program that will show me in a text label, the color value of the x,y positions given in Edit fields.
The problem is that it will only work once and after it will not refresh. It is not a problem about the value itself since the value is correctly updated when I use a MsgBox.
See my following code:
#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
Gui, Add, Text,, X ;xpos label
Gui, Add, Edit, vxpos Number ;xpos to be entered by user
Gui, Add, Text,, Y ;ypos label
Gui, Add, Edit, vypos Number ;ypos to be entered by user
Gui, Add, Button, Default, GetColor ;to get the color
Gui, Add, Text,, vmyRGB ;color value that should be displayed
Gui, Show, AutoSize
Return
ButtonGetColor: ;called when pressing the button
Gui, Submit, NoHide ;retrieves values of my edit fields
PixelGetColor, myColor, %xpos%, %ypos% ;pixelcolor in my myColor variable
GuiControl,, vmyRGB, %myColor% ;updates my text field with the variable value, working once
MsgBox, %myColor% ;checks the value of my variable, always working
Return
Need some help on this, thank you :)

Well, after some more research using different keywords, I found out a solution:
replacing
Gui, Add, Text,, vmyRGB ;color value that should be displayed
by
Gui, Add, Text, vmyRGB, %myRGB% ;color value that should be displayed
and replacing
GuiControl,, vmyRGB, %myColor% ;updates my text field with the variable value, working once
by
GuiControl, Text, myRGB, %myColor% ;updates my text field with the variable value

Related

Insert/replace string in existing text form field in Word (VBA)

So I'm trying to create a conditional dropdown in Word. I've used a Legacy Drop-Down Form Field with multiple options.
What I want to happen is when one of the options is selected from the dropdown (and then I guess you have to Tab to enter it...), the Legacy Text Form Field below, that has a simple default text, should populate with a new string from the case statement.
Things that I've already done/got working:
the drop down is working, and on exit it runs a macro
case statement is written out
the result of the case statement is in a variable (string type), let's call it StringVar
can pull the text form field's text (default text) with ActiveDocument.FormFields("TextBox").Result
What I figure out, however, is how to replace the default text in the already existing Text Form Field with the case statement's string variable text.
I've tried
ActiveDocument.FormFields("TextBox").Result = StringVar
but it doesn't change anything inside the text form field. The default text is still there.
So I can answer my own question after pondering and being hit with an "oh, duh" moment.
I had unprotected the document (ActiveDocument.Unprotect Password:="") in order to do this:
ActiveDocument.Content.InsertAfter Text:=("This is my text")
because I was wondering if I was grabbing the right string.
Turns out,
ActiveDocument.FormFields("TextBox").Result = StringVar
DOES work. BUT the file has to be protected (filling in forms) for it to replace the string in the text form field. Otherwise, nothing shows up even though the result had indeed been updated. Fancy that.

combobox properties to allow user to type text in it and let it filter by text entered

I have a combobox where I'll need to allow user to search by text and be able to select that value from the list. So what I'm currently doing is, on CBO_KeyPress, I open the drop down.
Me.cboNames.DroppedDown = True
I set the property of the cbo...
AutoCompleteMode=SuggestAppend
DropDownStyle = DropDown
AutoCompleteSource=ListItems
Everything works beautifully except for one issue. As it stands, i have items in the drop down where the width is significantly wider than the combobox - I have a function that adjusts the DropDownWith to longest string in the list of items. My concern is that while this helps user search for correct item, it's width is only as wide as the combobox. Is there a way to adjust this?
My only other option is to not use AutoCompleteSource=ListItems and instead simply open the dropDown programmatically on KeyPress or something. In this case, it doesn't do as good of a job of filtering the items. AutoCompleteSource does it beautifully but the width issue does not make it look right.
EDIT : Plutonix - here's what I did. I changed AutoCompleteSource=None. On CboName_KeyPress I open dropdown programmatically. Now I type in text, see image below....
It doesn't find text 100% of the time as you can see. AutoCompleteSource narrows it down and only shows you the items that begin with the same text as typed by user but the width is the issue. It actually looks much better with AutoCompleteSource because if they type in text that's not in the list of items then it shows nothing - and user known it's not in the list.
Users tab into the filed and start typing text. They don't open it. That's why they want this to be updated like that. I want them to see the items as they type in.

intellijidea code completion not new variables

I'm using Android Studio and I have code completion enabled as in picture.
I have enabled "Autopopup code completion" and "Insert selected variant by typing dot, space, etc..".
I want to write:
Drawable d = new BitmapDrawable(....);
I write "Dr", appears the popup, I click the space bar, and it writes "Drawable". It's all ok.
Then I write "d", appears the popup with "drawable" suggested, I click the space bar, and it writes "drawable".
But I want to write "d".
Is it possible to change this option applying only to classes and methods and not to new variables?
There is not a way to have code complete only apply to classes and methods and not to new variables. You have three options:
Turn off the Insert selected variant by typing dot, space, etc." options. You will then need to use Enter (to insert) or Tab (To overwrite) when you want to select an item from auto complete. The . (period/dot) key will still work when completing classes if you want to invoke a static member. (This is likely the best of the three choices and is the default behavior.)
After you type d for the variable name, hit Esc to close the auto complete popup before you hit the Space.
Turn off "Autopopup code completion" so that you have to manually activate it each time via Ctrl+Space

Vimperator, How to hit i_i keystroke to enter Insert-mode

Following is the Vimperator help about the insert mode
I have two questions in this regard
How the key combination i_i should be typed? pressing i key once brings me to ignore mode and twice pulls me out and no trace of Insert Mode.
Also I want to know what are the second series of keyboard combinations which are recomended at the end of each line such as i_< C-] for < C-i>. They show up in gray in oppose to the main shortcuts recommended in magenta.
<C-i> is the key combination. i_<C-i> simply means <C-i> while in insert mode. This is shown in the docs to make it easy to find what a particular key combination does in a given mode.
You can only enter insert mode if you are focused on a text area. Normally when you focus on a text area you are immediately put into insert mode. However, if you use :set noinsertmode then when you focus on a text area you will not initially be insert mode. You can then enter insert mode by pressing i.
If you are not focused on a text area then pressing i will take you in and out of ignore mode.
:help buffer
then you will find [count]gi is what you need.
Actually, press C-t to shift from insert mode to textArea mode, or vice versa, press i. as you know, i_i means press i in insert mode. So, textArea mode can be considered as a sub-mode of insert mode.

Find the difference (text)

I need a way to run a sub every time that text is added to a richtextbox. There is a changed event, but I have to know exactly what was added and at what position (even as trivial as a single space). I was going to do 'onKeyUp' but if users press CTRL + V, instead of getting the inserted content, I'll end up with just a 'v'.
Is there a way to do this? I need to be able to get the position that the content was added at and what was added. I'm doing this in VB.net.
I want to basically do something similar to http://typewith.me/
Let me show an example of what I want:
TEXT 1:
This is a message, currently no changes have been performed.
TEXT 2:
This is a message, currently none changes have been performed.
OUTPUT:
'ne' added at index position 31.
Cheers!
This might not be the most elegant solution, but the first thing that springs to mind is to store the contents of the text box in a variable. Every time it's changed, check the new contents of the text box against the stored contents and do whatever you need to, then store it again. This handles typing, pasting, deleting, etc.