/* author - Target last update - September 2012 Description - a simple launch bar with parameters. User defined commands stared in an ini file */ #persistent #singleinstance, force ifnotexist, sur.ini { iniwrite, P.H.A.R.T, sur.ini, commands, title iniwrite, 0, sur.ini, commands, count iniwrite,%a_space% , sur.ini, commands, faves } screen:= (a_screenwidth - 75) yy:=30 xx:= 1 xb:= 5 table:= object() menu, tray, nostandard menu, tray, add, Editor, amend menu, tray, add, exit, quit iniread, myfaves, %a_scriptdir%\SUR.INI, commands, faves iniread, title, %a_scriptdir%\SUR.INI, commands, title iniread, cnt, %a_scriptdir%\SUR.INI, commands, count gui, margin, 5, 5 gui, add, combobox, x5 y+5 w450 r5 vfaves gsubmit_,%myfaves% gui, add, button, x+5 yp w15 h15 gamend, x ;sizeme, .. loop, %cnt% { iniread, tmp_, SUR.INI, buttons, b%a_index% ctr:= a_index if XB > %screen% { yy+=30 XB:=5 } loop, parse, tmp_,| { if a_index = 1 { if a_loopfield contains Separator, separator Xb-=72 else if a_loopfield contains NewLine,newline { yy += 30 xb:= -72 } else gui, add, button, x%xb% y%YY% w75 h25 gaction, %a_loopfield% ;v%CTR% } table[ctr, a_index]:= a_loopfield } xb+=77 } gui, +alwaysontop +toolwindow gui, show, center autosize noactivate, %title% winget, myid, ID, %title% wingetpos,,,scr,, %title% ;Serves You Right if scr > 470 { scr//=2 scr-= 235 guicontrol,move, faves, x%scr% scr+=455 guicontrol,movedraw, x, x%scr% } settimer, mouseover, 100 return ;+++++++++++++++++++++++++++++++++++ quit: guiclose: exitapp return ;+++++++++++++++++++++++++++++++++++ Submit_: gui, submit, nohide return ;+++++++++++++++++++++++++++++++++++ action: shft:= shift_ if not faves { if shft = U { msgbox, No Target Specified return } } if msg contains Requires Confirmation { msgbox,4,Confirmation, %cmd%`n`nDo you REALLY want to do this? ifmsgbox, no return } If shft = D { stringreplace, cmd, cmd,%faves%,,all stringreplace, cmd, cmd,###,,all } run %cmd% return ;+++++++++++++++++++++++++++++++++++ mouseover: getkeystate, shift_, shift, P mousegetpos,,,win,btn wingetactivetitle, win_ guicontrolget, ww, , %btn%, 1 if win <> %myid% { tooltip ;, %btn% return } if btn = %Chk% return chk:= btn if win_ = Editor { if btn = Button1 tooltip, Move Up else if btn = Button2 tooltip, Insert Separator else if btn = Button3 tooltip, Start New Line else if btn = Button4 tooltip, Move Down else tooltip } else { if btn = button1 tooltip, Editor else for index, value in table { if table[index,1] = ww { CMD:= table[index,2] msg:= cmd if table[index,3] ; = Y msg.= "`n`n## Requires Confirmation ##" if faves { stringreplace, CMD, CMD, ###,%faves%, all stringreplace, msg, msg, ###,%faves%, all } tooltip,%msg% Break } else tooltip } } return ;+++++++++++++++++++++++++++++++++++ amend: ;settimer, mouseover, off ;tooltip gui, +owndialogs gui, hide gui, editor:default gui, Editor:margin, 5, 5 gui, Editor:add, groupbox, w675 h130, commands gui, Editor:add, listview,x15 y20 w100 r5 grid multi nosort altsubmit vcmds glist_, Button|CMD lv_modifycol(1,80) lv_modifycol(2,0) iniread, cnt, sur.ini, commands, count loop, %cnt% { iniread, tmp_, sur.ini, buttons, b%a_index% loop, parse, tmp_, | { lv_add("",a_loopfield, tmp_) break } } gui, Editor:add, button, x+5 yp+1 w22 h22 border vup_ gresort, U ;UP.png gui, Editor:add, button, xp y+5 w22 h22 border vb_ gresort, B ;break.png ;gresort, -- gui, Editor:add, button, xp y+5 w22 h22 border vn_ gresort, N ;newline.png ;gresort, -- gui, Editor:add, button, xp y+5 w22 h22 border vd_ gresort, D ;down.png gui, Editor:add, text, x150 yp-60 w50 right, Alias gui, Editor:add, edit, x+5 yp-3 w75 vtmp__1 gsubmit_ gui, Editor:add, text, x+25 yp+3, Confirmation (Y/N) gui, Editor:add, edit, x+5 yp-3 w30 vtmp__3 gsubmit_ gui, Editor:add, text, x150 y+8 w50 right, Command gui, Editor:add, edit, x+5 yp-3 w465 -wrap vtmp__2 gsubmit_ gui, Editor:add, button, xp y+10 w75 vCMDADD gcmds_, ADD gui, Editor:add, button, x+5 w75 vCMDCHG gcmds_, CHANGE gui, Editor:add, button, x+5 w75 vCMDDEL gcmds_, DELETE gui, Editor:add, groupbox, x5 y140 w590 h130, Favourites gui, Editor:add, listview,x15 y155 w490 r5 grid multi -readonly vfaves, favourites lv_modifycol(1,470) iniread, tmp_, sur.ini, commands, Faves loop, parse, tmp_, | lv_add("",a_loopfield) gui, Editor:add, button, x+5 yp w75 vFAVADD gFaves_, ADD gui, Editor:add, button, xp y+5 w75 vFAVDEL gfaves_, DELETE gui, Editor:add, button,x605 y220 w75 vguiAPP g_gui_, APPLY gui, Editor:add, button,xp y+5 w75 vguiCAN g_gui_, CANCEL gui, Editor:show,,Editor winget, myid, ID, Editor ;%title% return list_: gui, listview, cmds loop,3 tmp__%a_index%:= list_cnt:= lv_getcount("selected") if list_cnt = 1 { if a_guievent = normal { lv_gettext(tmp_, a_eventinfo,2) stringsplit, tmp__, tmp_,| guicontrol,,tmp__1, %tmp__1% guicontrol,,tmp__3, %tmp__3% guicontrol,,tmp__2, %tmp__2% } } else if list_cnt > 1 { guicontrol,,tmp__1, %tmp__1% guicontrol,,tmp__3, %tmp__3% guicontrol,,tmp__2, %tmp__2% } gui, submit, nohide return cmds_: gui, listview, cmds if a_guicontrol = CMDADD { lv_modify(0,"-select") lv_add("select",tmp__1,tmp__1 . "|" . tmp__2 . "|" . tmp__3) } else if a_guicontrol = CMDCHG lv_modify(lv_getnext(),"select",tmp__1,tmp__1 . "|" . tmp__2 . "|" . tmp__3) else ;if a_guicontrol = CMDDEL { loop % lv_getcount("Selected") ;% lv_delete(lv_getnext()) } gui, submit, nohide return faves_: gui, listview, faves if a_guicontrol = FAVADD { gui, Editor:hide inputbox, tmp_, New Favourite, Enter a new favourite here,, 550, 100 if tmp_ lv_add("",tmp_) gui, Editor:show } else ;if a_guicontrol = FAVdel { loop % lv_getcount("selected") ;% lv_delete(lv_getnext()) } return _gui_: tmp__0:= loop, 3 tmp__%a_index%:= if a_guicontrol = guiapp { inidelete,sur.ini,buttons gui, listview, faves loop % lv_getcount() ;% { lv_gettext(tmp__1,a_index) if tmp__0 tmp__0.= "|" tmp__0.= tmp__1 } sort, tmp__0, U d|TMP iniwrite, %tmp__0%, sur.ini,commands, faves gui, listview, cmds TMP__1:= LV_GETCOUNT() iniwrite, %tmp__1%, sur.ini, commands, count loop % lv_getcount() ;% { lv_gettext(tmp__1,a_index, 2) iniwrite, %tmp__1%, sur.ini,buttons, b%a_index% } reload } gui, Editor:destroy gui, 1:default gui, 1:show winget, myid, ID, %title% ;settimer, mouseover, 100 return resort: gui, listview, cmds tmp_1:= tmp_2:= row_:= lv_getnext() lv_gettext(tmp_1 , row_ , 1) lv_gettext(tmp_2 , row_ , 2) if a_guicontrol = up.png { if row_ < 2 return lv_delete(row_) row_ -- lv_insert(row_,"",tmp_1,tmp_2) } else if a_guicontrol = down.png { if(row_ = lv_getcount()) return lv_delete(row_) row_ ++ lv_insert(row_,"",tmp_1,tmp_2) } else if a_guicontrol = break.png { Lv_modify(row_,"-select") lv_insert(row_,"","Separator","Separator") } else if a_guicontrol = newline.png { Lv_modify(row_,"-select") lv_insert(row_,"","NewLine","NewLine") } Lv_modify(row_,"select") return