Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to get a list of all AutoText files in the left pane
#31
sorry i dont understand what your asking the selected autotext  is already open in qm after code insertion
#32
I mean, after executing the code, close the current AutoText file and close the QM window.
#33
Just close the active item and close the qm window?
Your dialog text suggests something different
#34
Maybe my expression is not accurate, I used Google Translate  Big Grin

The result of the current code run is the checkbox

If I don't select it, close the Autotext file for which the phrase has been added, then close QM.

What you understand should be correct  Wink
#35
let's assume that checkbox has been assigned id 8 by the dialog editor
when show dialog returns the variable for that control will be either
"1" if checked, "0" if unchecked
in the example below the variable is c8Ope
Code:
Copy      Help
str controls = "3 4 5 6 8"
str e3 e4 cb5 lb6 c8Ope
e3="text"
e4="description"
cb5=_s
lb6=_s
if(!ShowDialog(dd 0 &controls)) ret
str s1 s2
s1=e3
s2=e4
 

the string variable c8Ope will hold the value of the checkbox

so find
Code:
Copy      Help
SendMessage(h SCI.SCI_PASTE 0 0)

and add below
Code:
Copy      Help
if(c8Ope=0)
,men 33285 _hwndqm ;;Close active item
,men 33013  _hwndqm ;;Close Qm Window

if you post your code i can show you full code example
#36
The code runs successfully, thanks  Heart

I see watching the dialog help,

Using the smart dialog, add a double-click event, can I execute the code directly? No need to click the OK button?  Huh
#37
post your code with smart dialog will be easier to show you how
#38
I saw in the code that there are subfunctions that locate the insertion point.

I think if I position the insertion point to the front of the second line, is it simpler and more stable? Because I want to add the phrase, always at the top, how to modify the code? I tried to modify the code but always got an error  Confused
_________________________________________________________________________________________
My understanding of the smart dialog is not very deep, welcome to release the code of the smart dialog Tongue

By the way, change the insertion point to the second line begin  Smile
#39
change #sub InsertionPoint to this nothing else is needed now
Code:
Copy      Help
#sub InsertionPoint
function ~name int&h
mac+ name
h=GetQmCodeEditor
SendMessage(h SCI.SCI_GOTOLINE 1 0)
#40
The above code works better than the previous code. 

Double-click the AutoText list item to continue executing the code. I think I can only use the event handling of the smart dialog, but I don't know where to add the event. Huh
#41
design your dialog then select listbox in dialog editor
   
then click
   
then click
   

dialog editor will create code like this
Code:
Copy      Help
,case LBN_DBLCLK<<16|3
,_i=LB_SelectedItem(lParam)
#42
Ok, I will try,  Publish the full code later  Wink

I don't know why the text in the edit box has lost focus. I created a new dialog box, added an edit box, and the text is always in focus.  Huh


Attached Files Image(s)
   
#43
post your not smart dialog code with the check box.easy to adapt
#44
I have an idea, I don't know if I can achieve it,

When the dialog is open,

When I press the alt key, the checkbox is selected, press again to deselect Exclamation

Simple dialog code

Macro Add autotext
Trigger CSAa     Help - how to add the trigger to the macro
Code:
Copy      Help
out
str s.getsel
;str s1 ;;string variable. If need numeric, replace str with int or double.
;if(!inp(s1 "Enter AutoText Abbreviation" "" "text")) ret
;str s2 ;;string variable. If need numeric, replace str with int or double.
;if(!inp(s2 "Enter a phrase description" "" "description")) ret

;1.code:Get a list of all AutoText files
QMITEM q; int i
ARRAY(str) atn
ARRAY(int) htvi
rep
,i=qmitem(-i 1|16 &q 1|2|4|8)
,if(i=0) break
,if q.itype=4
,,atn[]=q.name
,,htvi[]=q.htvi
_s=atn


str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 164 234 "Dialog" "4"
;2 Button 0x54030000 0x4 91 202 48 14 "Cancel"
;3 Edit 0x54030080 0x200 26 19 112 12 ""
;4 Edit 0x54030080 0x200 26 42 112 12 ""
;5 ComboBox 0x54230243 0x0 26 64 112 213 ""
;6 ListBox 0x54230101 0x200 26 84 112 94 ""
;8 Button 0x54012003 0x0 45 186 72 8 "Open after adding"
;1 Button 0x54030001 0x4 26 202 48 14 "OK"
;7 Button 0x54020007 0x0 8 4 148 222 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040801 "*" "" "" ""

str controls = "3 4 5 6 8"
str e3 e4 cb5 lb6 c8Ope
e3="text"
e4="description"

cb5=_s
lb6=_s
if(!ShowDialog(dd 0 &controls)) ret

str s1 s2
s1=e3
s2=e4
;2.code:Open selected Autotext
;int ii=ListDialog(_s); if(ii=0) ret
;SendMessage id(2202 _hwndqm) TVM_SELECTITEM TVGN_CARET htvi[ii-1];; opens autotext file selected in list dialog
;_s.getl(_s ii-1)

;int ii=val(cb5) ;;use cb5
int ii=val(lb6) ;;use lb6
SendMessage id(2202 _hwndqm) TVM_SELECTITEM TVGN_CARET htvi[ii];; opens autotext file selected in dialog
_s.getl(_s ii)
;3.code:The cursor is positioned
;find insertion point
int h
sub.InsertionPoint(_s h)
;insert autotext
TO_Fav "TO_Text" 0 0
int w=wait(0 WA win("Text" "#32770"))
but id(6 w) ;;check box 'Multiline'
s.setwintext(id(3 w))
but id(1 w);; close to text window and insert code into autotext function
;4.code:Replace the default Abbreviation with the variable s1, Add a description with the variable s2
wait(0 WD win("Text" "#32770"))
int r=sub.GetInsertedTextCaretPosition(1)
int line=SendMessage(h SCI.SCI_LINEFROMPOSITION r 0)
int lpe=SendMessage(h SCI.SCI_GETLINEENDPOSITION line 0)
SendMessage(h SCI.SCI_SETSEL r lpe)
SendMessage(h SCI.SCI_COPY 0 0)
_s.getclip()
_s.findreplace("text" s1)
_s+ F" ;;{s2}"
_s.setclip
SendMessage(h SCI.SCI_PASTE 0 0)
if(c8Ope=0)
,men 33285 _hwndqm ;;Close active item
,men 33013  _hwndqm ;;Close Qm Window

#sub InsertionPoint
function ~name int&h
;int i = qmitem(name)
;_s.getmacro(i)
;str ss
;int ii ln pos lpe
;foreach ss _s
,;if ss.beg("#sub")
,,;ln= ii-1
,,;break
,;ii+1
;mac+ name
;h=GetQmCodeEditor
;if ln>0
,;pos=SendMessage(h SCI.SCI_POSITIONFROMLINE ln 0)
,;lpe=SendMessage(h SCI.SCI_GETLINEENDPOSITION ln 0)
,;SendMessage(h SCI.SCI_GOTOPOS lpe 0)
,;act h
;else
,;pos=SendMessage(h SCI.SCI_POSITIONFROMLINE ii 0)
,;lpe=SendMessage(h SCI.SCI_GETLINEENDPOSITION ii 0)
,;SendMessage(h SCI.SCI_GOTOPOS lpe 0)
,;act h
,;key Y           ;; Enter
,
mac+ name
h=GetQmCodeEditor
SendMessage(h SCI.SCI_GOTOLINE 1 0)

#sub GetInsertedTextCaretPosition
function# [flags] ;;flags: 1 go to that position
int c=GetQmCodeEditor
SendMessage(c SCI.SCI_UNDO 0 0)
int r=SendMessage(c SCI.SCI_GETCURRENTPOS 0 0)
SendMessage(c SCI.SCI_REDO 0 0)
if(flags&1) SendMessage(c SCI.SCI_GOTOPOS r 0)
ret r

Three feature requests:

1. Edit box defaults to focus

2. The first AutoText project defaults to focus

3. Press the alt key to set the checkbox status.

Using the tree directory, I feel it may be more troublesome. I have an idea now, it might be simpler to implement.

by default,
The list box shows all AutoText items.
Combo box displays all AutoText folders

When I select an AutoText folder, the AutoText file in it is displayed in the list box.


Attached Files Image(s)
       
#45
sorry for the delay i fell asleep

here is the dialog
the checkbox is toggle by alt+y change to whatever you like(cannot be just alt)
edit 3 is now focused when dialog opens
double left in the list box launches the autotext code insertion

Function Add_AutoText_dialog
Trigger CSAa     Help - how to add the trigger to the macro
Code:
Copy      Help
out
str s.getsel
;1.code:Get a list of all AutoText files
QMITEM q; int i
ARRAY(str) atn
ARRAY(int) htvi
rep
,i=qmitem(-i 1|16 &q 1|2|4|8)
,if(i=0) break
,if q.itype=4
,,atn[]=q.name
,,htvi[]=q.htvi
_s=atn

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 164 234 "Add AutoText" "4"
;3 Edit 0x54030080 0x200 26 19 112 12 ""
;4 Edit 0x54030080 0x200 26 42 112 12 ""
;5 ComboBox 0x54230243 0x0 26 64 112 213 ""
;6 ListBox 0x54230101 0x200 26 84 112 94 ""
;8 Button 0x54012003 0x0 45 186 72 8 "Open after adding"
;1 Button 0x54030001 0x4 26 202 48 14 "OK"
;2 Button 0x54030000 0x4 91 202 48 14 "Cancel"
;7 Button 0x54020007 0x0 8 4 148 222 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040802 "*" "" "" ""

str controls = "3 4 5 6 8"
str e3 e4 cb5 lb6 c8Ope
e3="Text"
e4="Description"
cb5=_s
lb6=_s
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc v
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,DT_SetAccelerators(hDlg "400 Ay");; alt+y change to something else if you dont like (alt cannot be used by itself)
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 400
,but* id(8 hDlg);;toggle checkbox
,case LBN_DBLCLK<<16|6
,str name
,_i=LB_SelectedItem(lParam &name)
,str s1 s2 c8
,DT_GetControl(hDlg 3 s1)
,DT_GetControl(hDlg 4 s2)
;,2.code:Open selected Autotext
,mac+ name
;;;;3.code: find insertion point
,int h
,sub.InsertionPoint(name h)    
;;;;;insert autotext
,TO_Fav "TO_Text" 0 0
,int w=wait(0 WA win("Text" "#32770"))
,but id(6 w) ;;check box 'Multiline'
,s.setwintext(id(3 w))
,but id(1 w);; close text window and insert code into autotext function
;,4.code:Replace the default Abbreviation with the variable s1, Add a description with the variable s2
,wait(0 WD win("Text" "#32770"))
,int r=sub.GetInsertedTextCaretPosition(1)
,int line=SendMessage(h SCI.SCI_LINEFROMPOSITION r 0)
,int lpe=SendMessage(h SCI.SCI_GETLINEENDPOSITION line 0)
,SendMessage(h SCI.SCI_SETSEL r lpe)
,SendMessage(h SCI.SCI_COPY 0 0)
,_s.getclip()
,_s.findreplace("text" s1)
,_s+ F" ;;{s2}"
,_s.setclip
,SendMessage(h SCI.SCI_PASTE 0 0)
,DT_GetControl(hDlg 8 c8)
,if(c8=0)
,,men 33285 _hwndqm ;;Close active item
,,men 33013  _hwndqm ;;Close Qm Window    
ret 1
#sub InsertionPoint
function ~name int&h
mac+ name
h=GetQmCodeEditor
SendMessage(h SCI.SCI_GOTOLINE 1 0)

#sub GetInsertedTextCaretPosition
function# [flags] ;;flags: 1 go to that position
int c=GetQmCodeEditor
SendMessage(c SCI.SCI_UNDO 0 0)
int r=SendMessage(c SCI.SCI_GETCURRENTPOS 0 0)
SendMessage(c SCI.SCI_REDO 0 0)
if(flags&1) SendMessage(c SCI.SCI_GOTOPOS r 0)
ret r
#46
Help when you are convenient, don't want to delay your energy Heart

I just tested the code and When I click the OK button nothing happened.

Can't set two focus points?

Currently, the edit box gets the focus,

I hope that the top AutoText name is also focus

Double-click the item name of the AutoText to successfully add it, but clicking the OK button is a failure.

In addition, I want to double-click the name of the AutoText, the dialog box will automatically close, and then the screen will display a two-second prompt: Acronym: *** has been added successfully,
#47
this should cover everything
Function Add_AutoText_dialog
Trigger CSAa     Help - how to add the trigger to the macro
Code:
Copy      Help
out
str s.getsel
;1.code:Get a list of all AutoText files
QMITEM q; int i
ARRAY(str) atn
ARRAY(int) htvi
rep
,i=qmitem(-i 1|16 &q 1|2|4|8)
,if(i=0) break
,if q.itype=4
,,atn[]=q.name
,,htvi[]=q.htvi
_s=atn

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 164 234 "Add AutoText" "4"
;3 Edit 0x54030080 0x200 26 19 112 12 ""
;4 Edit 0x54030080 0x200 26 42 112 12 ""
;5 ComboBox 0x54230243 0x0 26 64 112 213 ""
;6 ListBox 0x54230101 0x200 26 84 112 94 ""
;8 Button 0x54012003 0x0 45 186 72 8 "Open after adding"
;1 Button 0x54030001 0x4 26 202 48 14 "OK"
;2 Button 0x54030000 0x4 91 202 48 14 "Cancel"
;7 Button 0x54020007 0x0 8 4 148 222 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040802 "*" "" "" ""

str controls = "3 4 5 6 8"
str e3 e4 cb5 lb6 c8Ope
e3="Text"
e4="Description"
cb5=_s
lb6=_s
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
str s1 s2
s1=e3
s2=e4
;2.code:Open selected Autotext
;int ii=val(cb5) ;;use cb5
int ii=val(lb6) ;;use lb6
SendMessage id(2202 _hwndqm) TVM_SELECTITEM TVGN_CARET htvi[ii];; opens autotext file selected in dialog
_s.getl(_s ii)
;3.code: find insertion point
int h
sub.InsertionPoint(_s h)
;insert autotext
TO_Fav "TO_Text" 0 0
int w=wait(0 WA win("Text" "#32770"))
but id(6 w) ;;check box 'Multiline'
s.setwintext(id(3 w))
but id(1 w);; close to text window and insert code into autotext function
;4.code:Replace the default Abbreviation with the variable s1, Add a description with the variable s2
wait(0 WD win("Text" "#32770"))
int r=sub.GetInsertedTextCaretPosition(1)
int line=SendMessage(h SCI.SCI_LINEFROMPOSITION r 0)
int lpe=SendMessage(h SCI.SCI_GETLINEENDPOSITION line 0)
SendMessage(h SCI.SCI_SETSEL r lpe)
SendMessage(h SCI.SCI_COPY 0 0)
_s.getclip()
_s.findreplace("text" s1)
_s+ F" ;;{s2}"
_s.setclip
SendMessage(h SCI.SCI_PASTE 0 0)
if(c8Ope=0)
,men 33285 _hwndqm ;;Close active item
,men 33013  _hwndqm ;;Close Qm Window
OnScreenDisplay F"Acronym: {s1} has been added successfully" 2 

#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,DT_SetAccelerators(hDlg "400 Ay");; alt+y change to something else if you dont like (alt cannot be used by itself)
,SendMessage id(6 hDlg) LB_SETCURSEL 0 0
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 400
,but* id(8 hDlg);;toggle checkbox
,case LBN_DBLCLK<<16|6
,DT_Ok hDlg
ret 1
#sub InsertionPoint
function ~name int&h
mac+ name
h=GetQmCodeEditor
SendMessage(h SCI.SCI_GOTOLINE 1 0)

#sub GetInsertedTextCaretPosition
function# [flags] ;;flags: 1 go to that position
int c=GetQmCodeEditor
SendMessage(c SCI.SCI_UNDO 0 0)
int r=SendMessage(c SCI.SCI_GETCURRENTPOS 0 0)
SendMessage(c SCI.SCI_REDO 0 0)
if(flags&1) SendMessage(c SCI.SCI_GOTOPOS r 0)
ret r
#48
@kevin

Thanks, it’s great Heart

Currently only one function is not implemented.

By default, the list box displays all AutoText, and the combo box displays all the folders (for containing AutoText) When I select one of the folders, the list box can be displayed item inside (If there is no AutoText in the folder, it will be empty)

I will always give feedback on this feature (ctrl+alt+shift+A  add autotext). When it is very stable, I hope more people can use it to facilitate work and study. Smile
#49
Currently, I select the checkbox(open after adding). The cursor's input point is behind the comment.

I need to locate it in the subfunction name and then execute the hotkey F2.  Jump to the definition of the subfunction

Please see the image below.


Attached Files Image(s)
   
#50
@Kevin Hello,

I have a better idea, not using the text dialog, it might be simpler

Step 1: Navigate to the second line begin of the AutoText file and type the following characters

{s1} Confusedub.Sub* ;;{s2}

Step 2: Navigate to the last line of the AutoText file and type the following characters

#sub Sub* m
_s=
F
 {s}
KeyAutoInputDialog(_s)

NOTE:

1. KeyAutoInputDialog is a more powerful function, please open the link address for detailed description:
http://www.quickmacros.com/forum/showthr...1#pid33101

2. The difficulty of the above code is to determine the value of *

3. In the sub-function, the text in the variable s, need to add a space before each line.

I tried to write the code, it is simulated, Some code won't write,  can you help me improve the code according to the above requirements? thanks a lot  Heart
#51
With the above features, I think QM can completely replace other AutoText software, such as Fastkey, PhraseExpress Big Grin
#52
your idea is indeed not simpler but will make it more complicated. Let qm figure out subfunction numbers it does it automatically already. We can however get rid of the text dialog.

I created a new dialog
looks like this

   

has multiline edit control for autotext statements. can be either normal or multiline autotext or can use it for making a template for keyAutoInput
still can can be launched by ctrl+shift+alt+a
will check if active window has selection and paste it into
multiline edit in dialog
template just needs the template code nothing else no leading space

Dear Mr. $inp_Customer$,

thank you for contacting us. The price is $$inp_Price$. Let's meet next $inp_Day$.

Myfile is here "$inp_Filepath$"

Thanks and best regards,
$set_CaretHere$

pcname is $var_pcname$

$var_ShortDate$

the dialog will add the remaining code needed to create the  autotext for the template


here try this out
Function Add_AutoText_Dialog_New
Trigger CSAa     Help - how to add the trigger to the macro
Code:
Copy      Help
out 
str s.getsel
QMITEM q; int i
ARRAY(str) atn
rep
,i=qmitem(-i 1|16 &q 1)
,if(i=0) break
,if q.itype=4
,,atn[]=q.name
_s=atn
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 360 208 "Add AutoText"
;3 Edit 0x54030080 0x200 64 8 287 16 "text" "• text that you must type to execute statements.[]• Can be used any characters, including spaces, tabs and line breaks.[]• Can be used escapesequences.[]"
;4 Edit 0x54231044 0x200 64 32 287 80 "Statements" "statements - []• Full text[]• any commands that you can use in macros.[]• To separate multiple statements, use semicolons.[]"
;9 Button 0x54012003 0x0 64 120 122 10 "Template for KeyAutoInputDialog" "Check here if statement is a Template for KeyAutoInputDialog"
;13 Button 0x54012003 0x0 252 120 99 10 "Multiline/Singleline Autotext" "Click here if statement is for multiline or singleline Autotext(default)"
;12 Edit 0x54030080 0x200 64 136 287 16 "" "A brief explanantion for a popup list when autotext has multiple items of the same Abbreviation[]or when Autotext confirmation option is set"
;5 ComboBox 0x54230243 0x0 64 160 135 213 ""
;6 Static 0x54000000 0x0 8 160 44 16 "Add to:"
;7 Static 0x54000000 0x4 8 8 44 16 "Abbreviation:"
;8 Static 0x54000000 0x4 8 32 44 16 "Statement:"
;11 Static 0x54000000 0x0 8 136 44 16 "Comment:"
;10 Button 0x54030000 0x4 240 184 48 14 "Add"
;2 Button 0x54030000 0x4 304 184 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040802 "*" "" "" ""

str controls = "3 4 9 13 12 5"
str e3tex e4Sta c9Tem c13Mul e12 cb5
if s.len
,e4Sta=s
c13Mul=1
cb5=_s
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
str cbt
findrx(cb5 "\s[a-zA-Z0-9]{1,100}" 0 1 cbt)
cbt.trim
str Abbreviation=e3tex
str statement=e4Sta
str comment=e12
mac+ cbt
ARRAY(str) atl
if(numlines(statement) >1)
,atl=statement
,for i 0 atl.len
,,atl[i].from(" " atl[i])
,statement=atl
,statement.rtrim
,if(c13Mul=1)    
,,statement- "_s= []"
,,statement+ "[]paste _s"
,else
,,atl=statement
,,for i 0 atl.len
,,,atl[i].from(" " atl[i])
,,statement=atl
,,statement.rtrim
,,statement- "_s= [] _s=[] F[]"
,,statement+ "[] KeyAutoInputDialog(_s)[]paste _s"        
else
,,statement- "''"
,,statement+ "''"
int h=GetQmCodeEditor
SendMessage(h SCI.SCI_GOTOLINE 1 0)
InsertStatement(F"{statement}" comment "" 2)
int r=sub.GetInsertedTextCaretPosition(1)
SendMessage(h SCI.SCI_SETSEL r r+4)
Abbreviation.setclip
SendMessage(h SCI.SCI_PASTE 0 0)
int cp=SendMessage(h SCI.SCI_GETCURRENTPOS 0 0)
cp+7
SendMessage(h SCI.SCI_GOTOPOS cp 0)
#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,SendMessage id(3 hDlg) EM_SETCUEBANNER TRUE @"Enter Text"
,SendMessage id(4 hDlg) EM_SETCUEBANNER TRUE @"Enter Statements"    
,SendMessage id(12 hDlg) EM_SETCUEBANNER TRUE @"Enter Comment"
,SendMessage id(5 hDlg) CB_SETCUEBANNER 0 @"Select Autotext file to add text to"
,;SendMessage id(2202 _hwndqm) TVM_SELECTITEM TVGN_CARET|TVGN_FIRSTVISIBLE q.htvi    
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 10 ;;Add
,DT_Ok hDlg
,case 13 ;;Multiline/Singlelin Autotext
,if but(id(13 hDlg))
,,but- id(9 hDlg) 
,case 9 ;;Template for KeyAutoInputDialog
,if but(id(9 hDlg))
,,but- id(13 hDlg)     
ret 1

#sub GetInsertedTextCaretPosition
function# [flags] ;;flags: 1 go to that position
int c=GetQmCodeEditor
SendMessage(c SCI.SCI_UNDO 0 0)
int r=SendMessage(c SCI.SCI_GETCURRENTPOS 0 0)
SendMessage(c SCI.SCI_REDO 0 0)
if(flags&1) SendMessage(c SCI.SCI_GOTOPOS r 0)
ret r
#53
very good!!!

Your dialog box is very refined. I just found out that I found the error. Please see Figure 1 below.

In addition:

1. I still want to increase the Open AutoText checkbox, but use the hotkey to achieve, Press ctrl+Enter to perform the addition and open the AutoText

2. By default, the first AutoText file is selected,

3. When no acronym is entered, the default output is Text. When no comment is entered, the default output: Description

4. When Template for keyAutoInputDialog is selected, the +inp name button will appear on the left, click on it to generate a field, for example: $inp_***$

see Figure 2 below.


Function Add_AutoText_Dialog_New
Trigger CSAa     Help - how to add the trigger to the macro
Code:
Copy      Help
out
str s.getsel
QMITEM q; int i
ARRAY(str) atn
rep
,i=qmitem(-i 1|16 &q 1)
,if(i=0) break
,if q.itype=4
,,atn[]=q.name
_s=atn
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 360 208 "Add AutoText"
;3 Edit 0x54030080 0x200 64 8 287 16 "text" "• text that you must type to execute statements.[]• Can be used any characters, including spaces, tabs and line breaks.[]• Can be used escapesequences.[]"
;4 Edit 0x54231044 0x200 64 32 287 80 "Statements" "statements - []• Full text[]• any commands that you can use in macros.[]• To separate multiple statements, use semicolons.[]"
;9 Button 0x54012003 0x0 64 120 122 10 "Template for KeyAutoInputDialog" "Check here if statement is a Template for KeyAutoInputDialog"
;13 Button 0x54012003 0x0 252 120 99 10 "Multiline/Singleline Autotext" "Click here if statement is for multiline or singleline Autotext(default)"
;12 Edit 0x54030080 0x200 64 136 287 16 "" "A brief explanantion for a popup list when autotext has multiple items of the same Abbreviation[]or when Autotext confirmation option is set"
;5 ComboBox 0x54230243 0x0 64 160 135 213 ""
;6 Static 0x54000000 0x0 8 160 44 16 "Add to:"
;7 Static 0x54000000 0x4 8 8 44 16 "Abbreviation:"
;8 Static 0x54000000 0x4 8 32 44 16 "Statement:"
;11 Static 0x54000000 0x0 8 136 44 16 "Comment:"
;10 Button 0x54030000 0x4 240 184 48 14 "Add"
;14 Button 0x54012003 0x4 224 161 106 10 "Open Autotext (Ctrl+Enter)" "After adding, open the AutoText, or press the hotkey directly: Ctrl+Enter"
;15 Button 0x54032000 0x0 6 68 48 14 "+ inp name"
;2 Button 0x54030000 0x4 304 184 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040801 "*" "" "" ""

str controls = "3 4 9 13 12 5 14"
str e3tex e4Sta c9Tem c13Mul e12 cb5 c14Ope
if s.len
,e4Sta=s
c13Mul=1
cb5=_s
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
str cbt
findrx(cb5 "\s[a-zA-Z0-9]{1,100}" 0 1 cbt)
cbt.trim
str Abbreviation=e3tex
str statement=e4Sta
str comment=e12
mac+ cbt
ARRAY(str) atl
if(numlines(statement) >1)
,atl=statement
,for i 0 atl.len
,,atl[i].from(" " atl[i])
,statement=atl
,statement.rtrim
,if(c13Mul=1)
,,statement- "_s= []"
,,statement+ "[]paste _s"
,else
,,atl=statement
,,for i 0 atl.len
,,,atl[i].from(" " atl[i])
,,statement=atl
,,statement.rtrim
,,statement- "_s= [] _s=[] F[]"
,,statement+ "[] KeyAutoInputDialog(_s)[]paste _s"
else
,,statement- "''"
,,statement+ "''"
int h=GetQmCodeEditor
SendMessage(h SCI.SCI_GOTOLINE 1 0)
InsertStatement(F"{statement}" comment "" 2)
int r=sub.GetInsertedTextCaretPosition(1)
SendMessage(h SCI.SCI_SETSEL r r+4)
Abbreviation.setclip
SendMessage(h SCI.SCI_PASTE 0 0)
int cp=SendMessage(h SCI.SCI_GETCURRENTPOS 0 0)
cp+7
SendMessage(h SCI.SCI_GOTOPOS cp 0)
#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,SendMessage id(3 hDlg) EM_SETCUEBANNER TRUE @"Enter Text"
,SendMessage id(4 hDlg) EM_SETCUEBANNER TRUE @"Enter Statements"
,SendMessage id(12 hDlg) EM_SETCUEBANNER TRUE @"Enter Comment"
,SendMessage id(5 hDlg) CB_SETCUEBANNER 0 @"Select Autotext file to add text to"
,;SendMessage id(2202 _hwndqm) TVM_SELECTITEM TVGN_CARET|TVGN_FIRSTVISIBLE q.htvi
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 10 ;;Add
,DT_Ok hDlg
,case 13 ;;Multiline/Singlelin Autotext
,if but(id(13 hDlg))
,,but- id(9 hDlg)
,case 9 ;;Template for KeyAutoInputDialog
,if but(id(9 hDlg))
,,but- id(13 hDlg)
ret 1

#sub GetInsertedTextCaretPosition
function# [flags] ;;flags: 1 go to that position
int c=GetQmCodeEditor
SendMessage(c SCI.SCI_UNDO 0 0)
int r=SendMessage(c SCI.SCI_GETCURRENTPOS 0 0)
SendMessage(c SCI.SCI_REDO 0 0)
if(flags&1) SendMessage(c SCI.SCI_GOTOPOS r 0)
ret r


Attached Files Image(s)
       
#54
Improvement is endless, efficiency can always improve   Smile
#55
@Kevin

Gintaras  has been updated KeyAutoInputDialog code and is now more powerful
http://www.quickmacros.com/forum/showthr...6#pid33116

I want to continue adding three features.

When the check box for Template for KeyAutoInputDialog is selected, three buttons are displayed on the left side.

My English is not very good. Look at the picture below, you will understand immediately. Big Grin


Attached Files Image(s)
   
#56
Removed the checkbox, now it's more concise


Function Add_AutoText_Dialog_New
Trigger CSAa     Help - how to add the trigger to the macro
Code:
Copy      Help
out
str s.getsel
QMITEM q; int i
ARRAY(str) atn
rep
,i=qmitem(-i 1|16 &q 1)
,if(i=0) break
,if q.itype=4
,,atn[]=q.name
_s=atn
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 360 208 "Add AutoText"
;3 Edit 0x54030080 0x200 64 8 287 16 "text" "• text that you must type to execute statements.[]• Can be used any characters, including spaces, tabs and line breaks.[]• Can be used escapesequences.[]"
;4 Edit 0x54231044 0x200 64 32 287 80 "Statements" "statements - []• Full text[]• any commands that you can use in macros.[]• To separate multiple statements, use semicolons.[]"
;9 Button 0x54012003 0x0 64 120 122 10 "Template for KeyAutoInputDialog" "Check here if statement is a Template for KeyAutoInputDialog"
;13 Button 0x54012003 0x0 252 120 99 10 "Multiline/Singleline Autotext" "Click here if statement is for multiline or singleline Autotext(default)"
;12 Edit 0x54030080 0x200 64 136 287 16 "" "A brief explanantion for a popup list when autotext has multiple items of the same Abbreviation[]or when Autotext confirmation option is set"
;5 ComboBox 0x54230243 0x0 64 160 135 213 ""
;6 Static 0x54000000 0x0 8 160 44 16 "Add to:"
;7 Static 0x54000000 0x4 8 8 44 16 "Abbreviation:"
;8 Static 0x54000000 0x4 8 32 44 16 "Statement:"
;11 Static 0x54000000 0x0 8 136 44 16 "Comment:"
;10 Button 0x54030000 0x4 240 184 48 14 "Add"
;15 Button 0x54032000 0x0 6 50 48 14 "+ inp_name"
;16 Button 0x54032000 0x4 6 71 48 14 "+ sel_name"
;17 Button 0x54032000 0x4 6 92 48 14 "+ var_name"
;18 Button 0x54030000 0x4 162 184 61 14 "Add + Open" "After adding open the AutoText, hotkey: Ctrl+Enter"
;2 Button 0x54030000 0x4 304 184 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040801 "*" "" "" ""

str controls = "3 4 9 13 12 5"
str e3tex e4Sta c9Tem c13Mul e12 cb5
if s.len
,e4Sta=s
c13Mul=1
cb5=_s
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
str cbt
findrx(cb5 "\s[a-zA-Z0-9]{1,100}" 0 1 cbt)
cbt.trim
str Abbreviation=e3tex
str statement=e4Sta
str comment=e12
mac+ cbt
ARRAY(str) atl
if(numlines(statement) >1)
,atl=statement
,for i 0 atl.len
,,atl[i].from(" " atl[i])
,statement=atl
,statement.rtrim
,if(c13Mul=1)
,,statement- "_s= []"
,,statement+ "[]paste _s"
,else
,,atl=statement
,,for i 0 atl.len
,,,atl[i].from(" " atl[i])
,,statement=atl
,,statement.rtrim
,,statement- "_s= [] _s=[] F[]"
,,statement+ "[] KeyAutoInputDialog(_s)[]paste _s"
else
,,statement- "''"
,,statement+ "''"
int h=GetQmCodeEditor
SendMessage(h SCI.SCI_GOTOLINE 1 0)
InsertStatement(F"{statement}" comment "" 2)
int r=sub.GetInsertedTextCaretPosition(1)
SendMessage(h SCI.SCI_SETSEL r r+4)
Abbreviation.setclip
SendMessage(h SCI.SCI_PASTE 0 0)
int cp=SendMessage(h SCI.SCI_GETCURRENTPOS 0 0)
cp+7
SendMessage(h SCI.SCI_GOTOPOS cp 0)
#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,SendMessage id(3 hDlg) EM_SETCUEBANNER TRUE @"Enter Text"
,SendMessage id(4 hDlg) EM_SETCUEBANNER TRUE @"Enter Statements"
,SendMessage id(12 hDlg) EM_SETCUEBANNER TRUE @"Enter Comment"
,SendMessage id(5 hDlg) CB_SETCUEBANNER 0 @"Select Autotext file to add text to"
,;SendMessage id(2202 _hwndqm) TVM_SELECTITEM TVGN_CARET|TVGN_FIRSTVISIBLE q.htvi
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 10 ;;Add
,DT_Ok hDlg
,case 13 ;;Multiline/Singlelin Autotext
,if but(id(13 hDlg))
,,but- id(9 hDlg)
,case 9 ;;Template for KeyAutoInputDialog
,if but(id(9 hDlg))
,,but- id(13 hDlg)
ret 1

#sub GetInsertedTextCaretPosition
function# [flags] ;;flags: 1 go to that position
int c=GetQmCodeEditor
SendMessage(c SCI.SCI_UNDO 0 0)
int r=SendMessage(c SCI.SCI_GETCURRENTPOS 0 0)
SendMessage(c SCI.SCI_REDO 0 0)
if(flags&1) SendMessage(c SCI.SCI_GOTOPOS r 0)
ret r

I have an idea, the default comment, shows the first three words of the statement  Exclamation


Attached Files Image(s)
       
#57
"I just found out that I found the error. Please see Figure 1 below."

is not an error its by design
was intended to make autotext template for pasting into other functions not to run KeyAutoInputDialog from auto text

"I have an idea, the default comment, shows the first three words of the statement"
 not a good idea what if first line is blank or /b/i/c/m or  /  or any other number of things. Just making more work trying to parse text when don't need to.
#58
Regarding question 1, I still think there is a problem, I tested it many times, not the result I want. Huh
#59
it is as i designed it . just because it's not the result you had in mind does not mean it is a problem. does what i intended it to do.
#60
Again please read and understand  what i said. The code was not designed to do what your trying to do. Its is not a bug or an error. Your simply trying to do something that the code was not designed to do and expecting different results.

no time to redo the code right now sorry. Maybe in about 12 hours.


Forum Jump:


Users browsing this thread: 8 Guest(s)