AutoHotkey: Duplicate starter menu entry: Difference between revisions
Jump to navigation
Jump to search
(Added category AutoHotkey scripts) |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
<pre> | <pre> | ||
; //////////////////////////////////////////////////////////////////////////// | ; //////////////////////////////////////////////////////////////////////////// | ||
; // TC_StartMenu_DuplicateEntry.ahk | ; // TC_StartMenu_DuplicateEntry.ahk V2.1 | ||
; // (W) StatusQuo 2008 | ; // (W) StatusQuo 2008-2023 (tested in TC 7.04a .. TC 10.52) | ||
; // | ; // | ||
; // Duplicates an entry in TC Start Menu or Directory Hotlist | ; // Duplicates an entry in TC Start Menu or Directory Hotlist | ||
; //////////////////////////////////////////////////////////////////////////// | ; //////////////////////////////////////////////////////////////////////////// | ||
#SingleInstance, Force | |||
; *** set window class names | ; *** set window class names | ||
Line 14: | Line 16: | ||
WinWait , ahk_class %sClassMainWin%, | WinWait , ahk_class %sClassMainWin%, | ||
IfWinNotActive, ahk_class %sClassMainWin%,, WinActivate, ahk_class %sClassMainWin%, | IfWinNotActive, ahk_class %sClassMainWin%,, WinActivate, ahk_class %sClassMainWin%, | ||
WinWaitActive , ahk_class %sClassMainWin%, ; main " | WinWaitActive , ahk_class %sClassMainWin%, | ||
DetectButtonNames() ; get current button names | |||
ControlGetText, AltEdit4, TAltEdit4, ahk_class %sClassMainWin% ; TC 10.52: 3/2/1 => 4/3/2 | |||
ControlGetText, AltEdit3, TAltEdit3, ahk_class %sClassMainWin% | |||
ControlGetText, AltEdit2, TAltEdit2, ahk_class %sClassMainWin% | |||
ControlGetText, AltEdit1, TAltEdit1, ahk_class %sClassMainWin% | |||
ControlGetText, Edit3, TEdit3, ahk_class %sClassMainWin% ; old TC 7.04a | |||
ControlGetText, Edit2, TEdit2, ahk_class %sClassMainWin% ; old TC 7.04a | |||
ControlGetText, Edit1, TEdit1, ahk_class %sClassMainWin% ; old TC 7.04a | |||
ControlGetText, V6Edit3, Edit1, ahk_class %sClassMainWin% ; old TC 6.56, replaces TAltEdit3; does not work properly! | |||
ControlGet, CheckBox3, Checked,, TCheckBox3, ahk_class %sClassMainWin%, ; main window | |||
ControlGet, CheckBox2, Checked,, TCheckBox2, ahk_class %sClassMainWin%, ; main window, "as symbol" TC 9.xx | |||
ControlGet, CheckBox1, Checked,, TCheckBox1, ahk_class %sClassMainWin%, ; main window, "fullscreen" TC 9.xx | |||
ControlGet, MyCheckBox3, Checked,, TMyCheckBox3, ahk_class %sClassMainWin%, ; main window, "as symbol" TC 10.52 | |||
ControlGet, MyCheckBox2, Checked,, TMyCheckBox2, ahk_class %sClassMainWin%, ; main window, "fullscreen" TC 10.52 | |||
ControlGet, MyCheckBox1, Checked,, TMyCheckBox1, ahk_class %sClassMainWin%, ; main window | |||
;TMyComboBox1 ; Shortcut key | |||
;TComboBox1 ; Shortcut key ; old TC 7.04a | |||
if (AltEdit4 . AltEdit3 . AltEdit2 . AltEdit1 <> "") | |||
if ( | |||
{ | { | ||
sText1 := AltEdit1 | |||
sText2 := AltEdit2 | |||
sText3 := AltEdit3 | |||
if ("" != AltEdit4) ; and ("?" != AltEdit1) ; *** TC 10.52 | |||
{ | |||
sText1 := AltEdit2 | |||
sText2 := AltEdit3 | |||
sText3 := AltEdit4 | |||
} | |||
} else { | } else { | ||
sText1 := Edit1 | |||
sText2 := Edit2 | |||
sText3 := Edit3 | |||
if (Edit3 = "") | |||
sText3 := V6Edit3 | |||
} | } | ||
; *** get entry title | ; *** get title of entry + *** Auto-detect name of Edit control | ||
if ( | ControlSend, %varButTit%, {Space}, ahk_class %sClassMainWin% ; Button "Change Title" | ||
WinWaitActive, ahk_class %sClassDialog% ; dialog "Change Title" | |||
ControlGetText, sMenuTitle, TAltEdit1, ahk_class %sClassDialog% ; get old title | |||
if (sMenuTitle = "") | |||
{ | { | ||
ControlGetText, sMenuTitle, TEdit1, ahk_class %sClassDialog% ; get old title | |||
sEditName0 := "TEdit1" ; TC 7.04a 0=add control | |||
sEditName1 := "TEdit1" ; TC 7.04a | |||
sEditName2 := "TEdit2" ; TC 7.04a | |||
sEditName3 := "TEdit3" ; TC 7.04a | |||
if (Edit3 . AltEdit3 = "") | |||
sEditName3 := "Edit1" ; TC 6.51 | |||
} else { | } else { | ||
sEditName0 := "TAltEdit1" ; TC 9.xx 0=add control | |||
sEditName1 := "TAltEdit1" | |||
sEditName2 := "TAltEdit2" | |||
sEditName3 := "TAltEdit3" | |||
if ("" != AltEdit4) ; and ("?" != AltEdit1) ; *** TC 10.52 | |||
{ | |||
sEditName0 := "TAltEdit1" ; TC 10.52 0=add control | |||
sEditName1 := "TAltEdit2" | |||
sEditName2 := "TAltEdit3" | |||
sEditName3 := "TAltEdit4" | |||
} | |||
} | } | ||
DetectTitleOkButton() | |||
ControlSend, %sOkButName%, {Space}, ahk_class %sClassDialog% ; Button OK, close "Title" dialog | |||
WinWaitActive, ahk_class %sClassMainWin% ; main hotlist editor window | |||
WinWaitActive, | |||
; *** sending {Space} to "Change title" button changes button names in Dir Hotlist (#1 gets "&>>" instead of "Help") | |||
; *** ControlClick instead of {Space} leaves button names unchanged | |||
; *** => redetect button names here | |||
DetectButtonNames() ; get current button names | |||
; *** add new entry | ; *** add new entry | ||
ControlSend, %varButAdd%, {Space}, ahk_class %sClassMainWin% ; Button "Add Menu Entry" | |||
WinWaitActive, ahk_class %sClassDialog% ; dialog "Change Title" | |||
ControlSetText, %sEditName0%, %sMenuTitle% [copy], ahk_class %sClassDialog% ; Title (TC7.04a:TEdit1, TC7.50a:TAltEdit1) | |||
} | DetectTitleOkButton() | ||
ControlSend, %sOkButName%, {Space}, ahk_class %sClassDialog% ; Button OK, close "Title" dialog | |||
WinWaitActive, ahk_class %sClassMainWin% ; main window | |||
WinWaitActive, | |||
ControlSetText, | ; *** sending {Space} to "OK" button changes button names in Dir Hotlist (#1 gets "&>>" instead of "Help") | ||
; *** ControlClick does the same here | |||
WinWaitActive, | ; *** => redetect button names! | ||
DetectButtonNames() ; get current button names | |||
; *** fill stored values from source entry | ; *** fill stored values from source entry | ||
if (sDialogType = "start") | ; if (sDialogType = "start") ; TC 7.04a uses just TEdit1+2 for dir hotlist | ||
; { | |||
ControlSetText, %sEditName3%, %sText3%, ahk_class %sClassMainWin% ; main window ; TAltEdit3 / TEdit3 | |||
; } | |||
ControlSetText, %sEditName2%, %sText2%, ahk_class %sClassMainWin% ; main window | |||
ControlSetText, %sEditName1%, %sText1%, ahk_class %sClassMainWin% ; main window | |||
; if (sDialogType = "start") | |||
; { | |||
if CheckBox3 ; *** My3/2 in TC 10.52, 2/1 in TC 9.xx | |||
Control, Check,, TCheckBox3, ahk_class %sClassMainWin% ; main window | |||
else | |||
Control, UnCheck,, TCheckBox3, ahk_class %sClassMainWin% ; main window | |||
if CheckBox2 | |||
Control, Check,, TCheckBox2, ahk_class %sClassMainWin% ; main window | |||
else | |||
Control, UnCheck,, TCheckBox2, ahk_class %sClassMainWin% ; main window | |||
if CheckBox1 | |||
Control, Check,, TCheckBox1, ahk_class %sClassMainWin% ; main window | |||
else | |||
Control, UnCheck,, TCheckBox1, ahk_class %sClassMainWin% ; main window | |||
; | |||
if MyCheckBox3 ; *** My3/2 in TC 10.52, 2/1 in TC 9.xx | |||
Control, Check,, TMyCheckBox3, ahk_class %sClassMainWin% ; main window | |||
else | |||
Control, UnCheck,, TMyCheckBox3, ahk_class %sClassMainWin% ; main window | |||
if MyCheckBox2 | |||
Control, Check,, TMyCheckBox2, ahk_class %sClassMainWin% ; main window | |||
else | |||
Control, UnCheck,, TMyCheckBox2, ahk_class %sClassMainWin% ; main window | |||
if MyCheckBox1 | |||
Control, Check,, TMyCheckBox1, ahk_class %sClassMainWin% ; main window | |||
else | |||
Control, UnCheck,, TMyCheckBox1, ahk_class %sClassMainWin% ; main window | |||
; *** set cursor to command value | |||
ControlFocus, %sEditName3%, ahk_class %sClassMainWin% ; main window ; TAltEdit3 | |||
ControlSend, %sEditName3%, {HOME} | |||
; } | |||
Return | |||
; ***************************************************************************************************** | |||
DetectButtonNames() | |||
{ | { | ||
global | |||
ControlGetTExt, sButNam1, TButton1 | |||
if (sButNam1="&>>") | |||
{ | |||
; *** Starter menu (and Dir Hotlist after "Change Title" in TC 7.50a/7.55, using ControlClick or sending {Space}) | |||
varButAdd := "TButton8" ;;* 8=&Add Item... | |||
varButSub := "TButton7" ;;* 7=Add s&ubmenu... | |||
varButDel := "TButton6" ;;* 6=&Delete Item | |||
varButTit := "TButton5" ;;* 5=Change &Title | |||
varButOK := "TButton4" ;;* 4=OK | |||
varButCan := "TButton3" ;;* 3=Cancel | |||
;;* 2=Help | |||
;;* 1=&>> | |||
} else { | |||
; *** Dir Hotlist | |||
varButAdd := "TButton7" ;;* 7=&Add Item... | |||
varButSub := "TButton6" ;;* 6=Add s&ubmenu... | |||
varButDel := "TButton5" ;;* 5=&Delete Item | |||
varButTit := "TButton4" ;;* 4=Change &Title | |||
varButOK := "TButton3" ;;* 3=OK | |||
varButCan := "TButton2" ;;* 2=Cancel | |||
;;* 1=Help | |||
} | |||
} | } | ||
DetectTitleOkButton() | |||
{ | { | ||
; *** Autodetect name of OK-button in dialog "Add Item"; | |||
global | |||
Loop, 3 | |||
{ | |||
ControlGetText, sTmp, TButton%a_index% | |||
if (sTmp="OK") | |||
{ | |||
sOkButName=TButton%a_index% | |||
Break | |||
} | |||
} | |||
if (sOkButName="") | |||
{ | |||
MsgBox, Error: Version/Language autodetect failed (adding title), stopping script. | |||
ExitApp | |||
} | |||
} | } | ||
</pre> | </pre> |
Latest revision as of 03:35, 3 April 2023
; //////////////////////////////////////////////////////////////////////////// ; // TC_StartMenu_DuplicateEntry.ahk V2.1 ; // (W) StatusQuo 2008-2023 (tested in TC 7.04a .. TC 10.52) ; // ; // Duplicates an entry in TC Start Menu or Directory Hotlist ; //////////////////////////////////////////////////////////////////////////// #SingleInstance, Force ; *** set window class names sClassMainWin := "TUSERMENUCHANGE" sClassDialog := "TSTDTREEDLG" ; *** wait for & activate window WinWait , ahk_class %sClassMainWin%, IfWinNotActive, ahk_class %sClassMainWin%,, WinActivate, ahk_class %sClassMainWin%, WinWaitActive , ahk_class %sClassMainWin%, DetectButtonNames() ; get current button names ControlGetText, AltEdit4, TAltEdit4, ahk_class %sClassMainWin% ; TC 10.52: 3/2/1 => 4/3/2 ControlGetText, AltEdit3, TAltEdit3, ahk_class %sClassMainWin% ControlGetText, AltEdit2, TAltEdit2, ahk_class %sClassMainWin% ControlGetText, AltEdit1, TAltEdit1, ahk_class %sClassMainWin% ControlGetText, Edit3, TEdit3, ahk_class %sClassMainWin% ; old TC 7.04a ControlGetText, Edit2, TEdit2, ahk_class %sClassMainWin% ; old TC 7.04a ControlGetText, Edit1, TEdit1, ahk_class %sClassMainWin% ; old TC 7.04a ControlGetText, V6Edit3, Edit1, ahk_class %sClassMainWin% ; old TC 6.56, replaces TAltEdit3; does not work properly! ControlGet, CheckBox3, Checked,, TCheckBox3, ahk_class %sClassMainWin%, ; main window ControlGet, CheckBox2, Checked,, TCheckBox2, ahk_class %sClassMainWin%, ; main window, "as symbol" TC 9.xx ControlGet, CheckBox1, Checked,, TCheckBox1, ahk_class %sClassMainWin%, ; main window, "fullscreen" TC 9.xx ControlGet, MyCheckBox3, Checked,, TMyCheckBox3, ahk_class %sClassMainWin%, ; main window, "as symbol" TC 10.52 ControlGet, MyCheckBox2, Checked,, TMyCheckBox2, ahk_class %sClassMainWin%, ; main window, "fullscreen" TC 10.52 ControlGet, MyCheckBox1, Checked,, TMyCheckBox1, ahk_class %sClassMainWin%, ; main window ;TMyComboBox1 ; Shortcut key ;TComboBox1 ; Shortcut key ; old TC 7.04a if (AltEdit4 . AltEdit3 . AltEdit2 . AltEdit1 <> "") { sText1 := AltEdit1 sText2 := AltEdit2 sText3 := AltEdit3 if ("" != AltEdit4) ; and ("?" != AltEdit1) ; *** TC 10.52 { sText1 := AltEdit2 sText2 := AltEdit3 sText3 := AltEdit4 } } else { sText1 := Edit1 sText2 := Edit2 sText3 := Edit3 if (Edit3 = "") sText3 := V6Edit3 } ; *** get title of entry + *** Auto-detect name of Edit control ControlSend, %varButTit%, {Space}, ahk_class %sClassMainWin% ; Button "Change Title" WinWaitActive, ahk_class %sClassDialog% ; dialog "Change Title" ControlGetText, sMenuTitle, TAltEdit1, ahk_class %sClassDialog% ; get old title if (sMenuTitle = "") { ControlGetText, sMenuTitle, TEdit1, ahk_class %sClassDialog% ; get old title sEditName0 := "TEdit1" ; TC 7.04a 0=add control sEditName1 := "TEdit1" ; TC 7.04a sEditName2 := "TEdit2" ; TC 7.04a sEditName3 := "TEdit3" ; TC 7.04a if (Edit3 . AltEdit3 = "") sEditName3 := "Edit1" ; TC 6.51 } else { sEditName0 := "TAltEdit1" ; TC 9.xx 0=add control sEditName1 := "TAltEdit1" sEditName2 := "TAltEdit2" sEditName3 := "TAltEdit3" if ("" != AltEdit4) ; and ("?" != AltEdit1) ; *** TC 10.52 { sEditName0 := "TAltEdit1" ; TC 10.52 0=add control sEditName1 := "TAltEdit2" sEditName2 := "TAltEdit3" sEditName3 := "TAltEdit4" } } DetectTitleOkButton() ControlSend, %sOkButName%, {Space}, ahk_class %sClassDialog% ; Button OK, close "Title" dialog WinWaitActive, ahk_class %sClassMainWin% ; main hotlist editor window ; *** sending {Space} to "Change title" button changes button names in Dir Hotlist (#1 gets "&>>" instead of "Help") ; *** ControlClick instead of {Space} leaves button names unchanged ; *** => redetect button names here DetectButtonNames() ; get current button names ; *** add new entry ControlSend, %varButAdd%, {Space}, ahk_class %sClassMainWin% ; Button "Add Menu Entry" WinWaitActive, ahk_class %sClassDialog% ; dialog "Change Title" ControlSetText, %sEditName0%, %sMenuTitle% [copy], ahk_class %sClassDialog% ; Title (TC7.04a:TEdit1, TC7.50a:TAltEdit1) DetectTitleOkButton() ControlSend, %sOkButName%, {Space}, ahk_class %sClassDialog% ; Button OK, close "Title" dialog WinWaitActive, ahk_class %sClassMainWin% ; main window ; *** sending {Space} to "OK" button changes button names in Dir Hotlist (#1 gets "&>>" instead of "Help") ; *** ControlClick does the same here ; *** => redetect button names! DetectButtonNames() ; get current button names ; *** fill stored values from source entry ; if (sDialogType = "start") ; TC 7.04a uses just TEdit1+2 for dir hotlist ; { ControlSetText, %sEditName3%, %sText3%, ahk_class %sClassMainWin% ; main window ; TAltEdit3 / TEdit3 ; } ControlSetText, %sEditName2%, %sText2%, ahk_class %sClassMainWin% ; main window ControlSetText, %sEditName1%, %sText1%, ahk_class %sClassMainWin% ; main window ; if (sDialogType = "start") ; { if CheckBox3 ; *** My3/2 in TC 10.52, 2/1 in TC 9.xx Control, Check,, TCheckBox3, ahk_class %sClassMainWin% ; main window else Control, UnCheck,, TCheckBox3, ahk_class %sClassMainWin% ; main window if CheckBox2 Control, Check,, TCheckBox2, ahk_class %sClassMainWin% ; main window else Control, UnCheck,, TCheckBox2, ahk_class %sClassMainWin% ; main window if CheckBox1 Control, Check,, TCheckBox1, ahk_class %sClassMainWin% ; main window else Control, UnCheck,, TCheckBox1, ahk_class %sClassMainWin% ; main window ; if MyCheckBox3 ; *** My3/2 in TC 10.52, 2/1 in TC 9.xx Control, Check,, TMyCheckBox3, ahk_class %sClassMainWin% ; main window else Control, UnCheck,, TMyCheckBox3, ahk_class %sClassMainWin% ; main window if MyCheckBox2 Control, Check,, TMyCheckBox2, ahk_class %sClassMainWin% ; main window else Control, UnCheck,, TMyCheckBox2, ahk_class %sClassMainWin% ; main window if MyCheckBox1 Control, Check,, TMyCheckBox1, ahk_class %sClassMainWin% ; main window else Control, UnCheck,, TMyCheckBox1, ahk_class %sClassMainWin% ; main window ; *** set cursor to command value ControlFocus, %sEditName3%, ahk_class %sClassMainWin% ; main window ; TAltEdit3 ControlSend, %sEditName3%, {HOME} ; } Return ; ***************************************************************************************************** DetectButtonNames() { global ControlGetTExt, sButNam1, TButton1 if (sButNam1="&>>") { ; *** Starter menu (and Dir Hotlist after "Change Title" in TC 7.50a/7.55, using ControlClick or sending {Space}) varButAdd := "TButton8" ;;* 8=&Add Item... varButSub := "TButton7" ;;* 7=Add s&ubmenu... varButDel := "TButton6" ;;* 6=&Delete Item varButTit := "TButton5" ;;* 5=Change &Title varButOK := "TButton4" ;;* 4=OK varButCan := "TButton3" ;;* 3=Cancel ;;* 2=Help ;;* 1=&>> } else { ; *** Dir Hotlist varButAdd := "TButton7" ;;* 7=&Add Item... varButSub := "TButton6" ;;* 6=Add s&ubmenu... varButDel := "TButton5" ;;* 5=&Delete Item varButTit := "TButton4" ;;* 4=Change &Title varButOK := "TButton3" ;;* 3=OK varButCan := "TButton2" ;;* 2=Cancel ;;* 1=Help } } DetectTitleOkButton() { ; *** Autodetect name of OK-button in dialog "Add Item"; global Loop, 3 { ControlGetText, sTmp, TButton%a_index% if (sTmp="OK") { sOkButName=TButton%a_index% Break } } if (sOkButName="") { MsgBox, Error: Version/Language autodetect failed (adding title), stopping script. ExitApp } }
Back to AutoHotkey