AutoHotkey: Duplicate starter menu entry: Difference between revisions
Jump to navigation
Jump to search
(Update for TC 7.50 rc1) |
(Update for TC 7.55 (and 7.50a), adjust to control names dynamically) |
||
Line 1: | Line 1: | ||
<pre> | <pre> | ||
; //////////////////////////////////////////////////////////////////////////// | ; //////////////////////////////////////////////////////////////////////////// | ||
; // TC_StartMenu_DuplicateEntry.ahk | ; // TC_StartMenu_DuplicateEntry.ahk V2.0 | ||
; // (W) StatusQuo 2008- | ; // (W) StatusQuo 2008-2010 for TC 7.02a (tested up to 7.04a, 7.50a and 7.55) | ||
; // | ; // | ||
; // 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 15: | Line 17: | ||
IfWinNotActive, ahk_class %sClassMainWin%,, WinActivate, ahk_class %sClassMainWin%, | IfWinNotActive, ahk_class %sClassMainWin%,, WinActivate, ahk_class %sClassMainWin%, | ||
WinWaitActive , ahk_class %sClassMainWin%, ; main "Change Start Menu" | WinWaitActive , ahk_class %sClassMainWin%, ; main "Change Start Menu" | ||
/* | /* | ||
* / | |||
sTmpButtonList := "" | |||
Loop, 9 | |||
{ | { | ||
; --- get button names | |||
sTmpVar := "sTmpButNam" . a_index | |||
ControlGetText, %sTmpVar%, TButton%a_index% | |||
sTmpButtonList := sTmpButtonList . a_index . "=" . %sTmpVar% . "`n" | |||
} | } | ||
MsgBox, %sTmpButtonList% | |||
ExitApp | |||
/* | |||
*/ | */ | ||
DetectButtonNames() ; get current button names | |||
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, CheckBox2, Checked,, TCheckBox2, ahk_class %sClassMainWin%, ; main window, "as symbol" | |||
ControlGet, CheckBox1, Checked,, TCheckBox1, ahk_class %sClassMainWin%, ; main window, "fullscreen" | |||
;TMyComboBox1 ; Shortcut key | |||
;TComboBox1 ; Shortcut key ; old TC 7.04a | |||
if (AltEdit3 . AltEdit2 . AltEdit1 <> "") | |||
{ | { | ||
sText1 := AltEdit1 | |||
sText2 := AltEdit2 | |||
sText3 := AltEdit3 | |||
} else { | } 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 | |||
sEditName1 := "TEdit1" ; TC 7.04a | |||
sEditName2 := "TEdit2" ; TC 7.04a | |||
sEditName3 := "TEdit3" ; TC 7.04a | |||
if (Edit3 . AltEdit3 = "") | |||
sEditName3 := "Edit1" ; TC 6.51 | |||
} else { | |||
sEditName1 := "TAltEdit1" | |||
sEditName2 := "TAltEdit2" | |||
sEditName3 := "TAltEdit3" | |||
} | } | ||
; ControlSend, TButton1, {Space}, ahk_class %sClassDialog%, ; Button "Cancel", close "Change Title" dialog | |||
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 | |||
; ControlClick | |||
; *** add new entry | ; *** add new entry | ||
ControlSend, %varButAdd%, {Space}, ahk_class %sClassMainWin%, ; Button "Add Menu Entry" | |||
WinWaitActive, ahk_class %sClassDialog%, ; dialog "Change Title" | |||
ControlSetText, %sEditName1%, %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") | |||
WinWaitActive, | ; *** ControlClick does the same here | ||
; *** => redetect button names! | |||
ControlSetText, %sEditName1%, %sMenuTitle% [copy], ahk_class %sClassDialog% ; Title (TC7.04a:TEdit1) | DetectButtonNames() ; get current button names | ||
ControlSend, % | |||
WinWaitActive, | |||
; *** fill stored values from source entry | ; *** fill stored values from source entry ; 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, %sEditName2%, %sText2%, ahk_class %sClassMainWin%, ; main window | ||
ControlSetText, %sEditName1%, %sText1%, ahk_class %sClassMainWin%, ; main window | ControlSetText, %sEditName1%, %sText1%, ahk_class %sClassMainWin%, ; main window | ||
; if (sDialogType = "start") | |||
if (sDialogType = "start") | ; { | ||
{ | if CheckBox2 | ||
if | |||
Control, Check,, TCheckBox2, ahk_class %sClassMainWin%, ; main window | Control, Check,, TCheckBox2, ahk_class %sClassMainWin%, ; main window | ||
else | else | ||
Control, UnCheck,, TCheckBox2, ahk_class %sClassMainWin%, ; main window | Control, UnCheck,, TCheckBox2, ahk_class %sClassMainWin%, ; main window | ||
if | if CheckBox1 | ||
Control, Check,, TCheckBox1, ahk_class %sClassMainWin%, ; main window | Control, Check,, TCheckBox1, ahk_class %sClassMainWin%, ; main window | ||
else | else | ||
Control, UnCheck,, TCheckBox1, ahk_class %sClassMainWin%, ; main window | Control, UnCheck,, TCheckBox1, 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> |
Revision as of 19:25, 25 June 2010
; //////////////////////////////////////////////////////////////////////////// ; // TC_StartMenu_DuplicateEntry.ahk V2.0 ; // (W) StatusQuo 2008-2010 for TC 7.02a (tested up to 7.04a, 7.50a and 7.55) ; // ; // 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%, ; main "Change Start Menu" /* * / sTmpButtonList := "" Loop, 9 { ; --- get button names sTmpVar := "sTmpButNam" . a_index ControlGetText, %sTmpVar%, TButton%a_index% sTmpButtonList := sTmpButtonList . a_index . "=" . %sTmpVar% . "`n" } MsgBox, %sTmpButtonList% ExitApp /* */ DetectButtonNames() ; get current button names 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, CheckBox2, Checked,, TCheckBox2, ahk_class %sClassMainWin%, ; main window, "as symbol" ControlGet, CheckBox1, Checked,, TCheckBox1, ahk_class %sClassMainWin%, ; main window, "fullscreen" ;TMyComboBox1 ; Shortcut key ;TComboBox1 ; Shortcut key ; old TC 7.04a if (AltEdit3 . AltEdit2 . AltEdit1 <> "") { sText1 := AltEdit1 sText2 := AltEdit2 sText3 := AltEdit3 } 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 sEditName1 := "TEdit1" ; TC 7.04a sEditName2 := "TEdit2" ; TC 7.04a sEditName3 := "TEdit3" ; TC 7.04a if (Edit3 . AltEdit3 = "") sEditName3 := "Edit1" ; TC 6.51 } else { sEditName1 := "TAltEdit1" sEditName2 := "TAltEdit2" sEditName3 := "TAltEdit3" } ; ControlSend, TButton1, {Space}, ahk_class %sClassDialog%, ; Button "Cancel", close "Change Title" dialog 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, %sEditName1%, %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 ; 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 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 ; *** 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