Problem 1
Line 103 in the following code, I would like the bold text (txt2) to be added immediately after the normal text (txt1) from Line 99. I would prefer to NOT use... xp+%txt1len% ... to locate the x position of the bold text because it assumes that each normal text character is 5 pixels wide, which is incorrect. I tried x+0 but that didn't work nor did xp+0 (puts the bold text over the normal text).
Code: Select all
#NoEnv ; best ahk compatibility
SendMode Input ; sendinput
#SingleInstance force ; only 1 instance of script running
SetTitleMatchMode, 2 ; anywhere
data =
(
arrow 2 HEADS|HK|!+
arrow CURVED 2 HEADS|HK|!^+
arrow CURVED|HK|^+
arrow mcr 2 HEADS|DC|!^+2
arrow mcr CURVED 2 HEADS|DC|!^+1
arrow mcr CURVED|DC|+2
arrow mcr STRAIGHT|DC|+.
change ARROW SELECTION|HK|^#a
change ARROW SETTINGS|HK|#a
change DIM SELECTION|HK|^#d
change DIM SETTINGS|HK|#d
change LINE SELECTION|HK|^#l
change LINE SETTINGS|HK|#l
change TEXT SELECTION|HK|^#t
change TEXT SETTINGS|HK|#t
change mcr ARROW SELECTION|DC|^+2
change mcr ARROW SETTINGS|DC|^+1
change mcr DIM SELECTION|DC|!^2
change mcr DIM SETTINGS|DC|!^1
change mcr LINE SELECTION|DC|^2
change mcr LINE SETTINGS|DC|^1
change mcr TEXT SELECTION|DC|!+2
change mcr TEXT SETTINGS|DC|!+1
copy CIRCLE ARRAY|DC|!a
copy CUT TO CB|DC|^x
copy DUPLICATE|DC|c
dim ANGLE BTWN 2 LINES|DC|<
dim ANGLE|DC|!^a
dim Add LEADER to AUTO|HK|f
dim BALLON|DC|^b
dim BEARING|DC|!^b
dim COORDINATE|DC|!^+c
dim DIMENSION|DC|d
dim DISTANCE ONLY|DC|!^+d
dim EXTENDED|DC|d
dim PROGRESSIVE|DC|^d
dim PULLOUT|DC|!
dim RADIUS|DC|!r
dim to AUTO|HK|f
dim mcr TEXT ABOVE|DC|f7
dim mcr TEXT BELOW|DC|f8
dim mcr TEXT CENTER|DC|f9
dim mcr TYPE EXTENDED|DC|f6
draw ARC (CNT,BEGIN,END)|DC|a
draw ARRAY COPY|DC|!c
draw ARROW|DC|6
draw ARROW|DC|>
draw BOX|DC|b
draw CIRCLE|DC|o
draw CURVE|DC|+c
draw ELIPSE|DC|^+e
draw PLANE|DC|!^+9
draw POINTMARK|DC|!^+p
draw POLYGON (EDGE)|DC|+p
draw SKETCH|DC|!^s
draw mcr DETAIL (TITLE,#,SCALE)|DC|^f5
draw mcr ELEV (BOX,DIRECTION)|DC|^f7
)
arr1 := strsplit(data,"`n")
label := [], action := [], task := [], parm := []
loop % arr1.maxindex()
{
txt := arr1[a_index]
arr2 := strsplit(txt,"|")
label[a_index] := arr2[1]
if strlen(label[a_index]) > max_chrs
max_chrs := strlen(label[a_index])
action[a_index] := arr2[2]
task[a_index] := arr2[3]
parm[a_index] := substr(arr2[4],1,-1)
}
clms := 3, rows := ceil(arr1.maxindex()/clms), txt_w := max_chrs*5.37, txt_h := 12, xx := 0, yy := -txt_h
Gui,MA: Color, FFFACE ; gui background color
Gui,MA: Font,s8 bold cBlack,Segoe UI
gui,MA:add,text,section x1 y1 w0 h0
loop,% label.maxindex()
{
if ((a_index-1)/rows = (a_index-1)//rows) and (a_index >1)
{
yy := -txt_h
xx += txt_w
}
yy += txt_h
; Gui,MA:Add,Progress,x%xx% y%yy% w%txt_w% h%txt_h% Disabled BackgroundFFFACE
Gui,MA:Add,Progress,x%xx% y%yy% w%txt_w% h%txt_h% Disabled +border BackgroundFFFACE
gui,MA:Font,normal
spcloc := instr(label[a_index]," ")
txt1 := substr(label[a_index],1,spcloc-1) " "
txt1len:=strlen(txt1)*5
xxx:=a_index
Gui,MA:Add,Text,x%xx% y%yy% wp hp cBlack BackgroundTrans left 0x200 v%a_index% gStart,% txt1
; Gui,MA:Add,Text,x%xx% y%yy% wp hp cBlack BackgroundTrans left 0x200 gStart,% txt1
gui,MA:Font,bold
txt2 := substr(label[a_index],spcloc+2)
Gui,MA:Add,Text,xp+%txt1len% y%yy% wp hp cBlack BackgroundTrans left 0x200 gStart,% txt2
; Gui,MA:Add,Text,xp+%txt1len% y%yy% wp hp cBlack BackgroundTrans left 0x200 v%a_index% gStart,% txt2
}
gui_w := clms*txt_w, gui_h := (rows-2)*txt_h+5
Gui,MA: Show, xcenter ycenter w%gui_w% h%gui_h%, %GuiTitle%.xAs
Gui,MA: -Caption +border +AlwaysOnTop
OnMessage(0x201, "WM_LBUTTONDOWN") ; so gui can be moved by mouse
return
WM_LBUTTONDOWN() ; so gui can be moved on screen by mouse
{
if a_gui = MA ; so Left Mouse Buttom can Drag Window
PostMessage, 0xA1, 2,,, A ; WM_NCLBUTTONDOWN
}
start:
msgbox % a_guicontrol
return
I would like clicking ANYWHERE in any box (see picture of gui below) to set... a_guicontrol ...to the selection's number (a_index). Except for the first column, selecting the left side of a box (the normal text) stores the bold text (txt2) from the same line from the column to the left not the selection number, selecting the right side of the box (the bold text) seems to work.
Even this doesn't seem to be working as I expected, it appears that selecting the right side is doing the same thing as selecting the left side, the a_guicontrol is using the selection immediately to the left and not the selection area clicked, example; column 2 top box, clicking it's left side results in... 2 HEADS ... which was set by line 99 (column 1's bold text), clicking the right side column 2 top box results in... 20 ...which was set by line 103, (column 2's left side normal text).
Any help will be appreciated.
Thank you.