Zed Gecko
Joined: 23 Sep 2006 Posts: 82
|
Posted: Wed Apr 30, 2008 1:14 am Post subject: [Desktop Widget] RUN-Box |
|
|
I wrote the RUN-Box to utilize the enourmous launching capability of the ahk-Run command directly from the Desktop.
Itīs a little Dektop-Wigdget or Desklet or whatever that allows you to type a command, filename or URL in a little Box stuck to the dektop. As long as Run supports it, it will be launchend.
Edit: Due to requests from some Friends i added some more funtionality
RUN-Box Version 2
| Quote: | RUN-Box (Desktop Widget)
Launch URLs, programs and files from your desktop!
Use the RUN-Box from your Desktop or
get a RUN-Box via Hotkey (CTRL+ALT+R) or TrayIcon-Click.
3 Modes availaible (Run, Websearch, Wikipedia-lookup)
- type in Program Names (e.g. notepad.exe) or
File names of media files (e.g. C:\example.jpg) or
URLīs of Webpages (e.g. www.google.de)
- just type the search-term, if in Search mode
- just type the search-term, if in Wikipedia mode
Right-click the Run-Box to configure
- choose the Run-Mode
- (de)activate the Tray Icon
- (de)activate the HotKey: CTRL+ALT+R
Left-click-drag to move on desktop |
RUN-Box Version 2 (10.05.08)
| Code: | ;============Autoexecute-Section=======
#SingleInstance force
#NoTrayIcon
Welcome_Message =
(
RUN-Box (Desktop Widget)
Launch URLs, programs and files from your desktop!
Use the RUN-Box from your Desktop or
get a RUN-Box via Hotkey (CTRL+ALT+R) or TrayIcon-Click.
3 Modes availaible (Run, Websearch, Wikipedia-lookup)
- type in Program Names (e.g. notepad.exe) or
File names of media files (e.g. C:\example.jpg) or
URLīs of Webpages (e.g. www.google.de)
- just type the search-term, if in Search mode
- just type the search-term, if in Wikipedia mode
Right-click the Run-Box to configure
- choose the Run-Mode
- (de)activate the Tray Icon
- (de)activate the HotKey: CTRL+ALT+R
Left-click-drag to move on desktop
)
;-------Read Config Section------------
IniRead, ini_runmode, runbox.ini, general, runmode, run
IniRead, ini_gposX, runbox.ini, general, GposX, 100
IniRead, ini_gposY, runbox.ini, general, GposY, 100
IniRead, ini_gwidth, runbox.ini, general, Gwidth, 198
IniRead, ini_trayicon, runbox.ini, general, TrayIcon, 1
IniRead, ini_hotkey, runbox.ini, general, Hotkey, 1
IniRead, ini_tttime, runbox.ini, general, tttime, 8000
IniRead, ini_searchstring, runbox.ini, search, searchstring, http://www.google.com/search?q=
IniRead, ini_wikistring, runbox.ini, wikipedia, wikistring, http://en.wikipedia.org/wiki/
loop, 20
{
IniRead, tmp_input, runbox.ini, run, %A_Index%, %A_Space%
if (tmp_input != "")
ini_runhistory .= "`n" . tmp_input
}
loop, 20
{
IniRead, tmp_input, runbox.ini, search, %A_Index%, %A_Space%
if (tmp_input != "")
ini_searchhistory .= "`n" . tmp_input
}
loop, 20
{
IniRead, tmp_input, runbox.ini, wikipedia, %A_Index%, %A_Space%
if (tmp_input != "")
ini_wikihistory .= "`n" . tmp_input
}
;---END-Read Config Section------------
;----------Main GUI Section------------
Gui, 1: +Lastfound +Resize +Toolwindow -Caption +NoActivate +MinSize +MaxSize +MinSize198x +MaxSize400x
Gui, 1: +Delimiter`n
Gui, 1: Margin, 6, 6
Gui, 1: Add, ComboBox, x6 y6 w155 r10 vRunChoice Sort,
Gui, 1: Font, s8, Wingdings
Gui, 1: Add, Button, x167 y6 w25 Default vRunButton g1RunButtonAction, Ã
Gui, 1:Show, x%ini_gposX% y%ini_gposY% w%ini_gwidth%
WinGet, active_id, ID, A
ParentID := DllCall( "FindWindowEx", "uint",0, "uint",0, "str", "Progman", "uint",0)
DllCall( "User32.dll\SetParent", UInt,active_ID, UInt,ParentID )
WinSet, Style, -0x20000, ahk_id %active_ID%
;-------END--Main GUI Section----------
;-------Menu Section-------------------
Menu, RunMenu, Add, Run, set_run
Menu, RunMenu, Add, Search, set_search
Menu, RunMenu, Add, Wikipedia, set_wikipedia
Menu, RunMenu, Add
Menu, RunMenu, Add, Config, ConfigGUI
Menu, ConfigMenu, Add, Run Mode, :Runmenu
Menu, ConfigMenu, Add
Menu, ConfigMenu, Add, TrayIcon, TrayIconSwitch
Menu, ConfigMenu, Add, Hotkey Ctrl+Alt+R, HotKeySwitch
Menu, ConfigMenu, Add
Menu, ConfigMenu, Add, Help, xx
Menu, ConfigMenu, Add
Menu, ConfigMenu, Add, Exit, savequit
Menu, TRAY, NoStandard
Menu, TRAY, Add, RUN-Box Popup, ShowPopUp
Menu, Tray, Default, RUN-Box Popup
Menu, Tray, Click, 1
;---End-Menu Section-------------------
;------PopUp-GUI Section-------------------
Gui, 3: +Toolwindow +AlwaysOnTop
Gui, 3: +Delimiter`n
Gui, 3: Margin, 6, 6
Gui, 3: Add, ComboBox, x6 y6 w195 r10 v3RunChoice Sort,
Gui, 3: Font, s8, Wingdings
Gui, 3: Add, Button, x207 y6 w25 Default vRunButton g3RunButtonAction, Ã
Gui, 3: Font, s8, Tahoma
Gui, 3: Add, Radio, x6 y+6 h15 vTypeButtonRun gset_run +0x1000, Run
Gui, 3: Add, Radio, x+6 h15 vTypeButtonSearch gset_search +0x1000, Search
Gui, 3: Add, Radio, x+6 h15 vTypeButtonWiki gset_wikipedia +0x1000, Wiki
;Gui, 3: Show, , RUN-Box PopUp
;--End-PopUp-GUI Section-------------------
OnMessage(0x201, "Gui_Move")
Gosub, Gui_Update
OnExit, savequit
Tooltip,%Welcome_Message%,5, 30
SetTimer, RemoveToolTip, -%ini_tttime%
return
;=======END==Autoexecute-Section=======
;------main execute section------------
1RunButtonAction:
Gui, 1: Submit, Nohide
GoSub, RunButtonAction
return
3RunButtonAction:
Gui, 3: Submit,
RunChoice := 3RunChoice
GoSub, RunButtonAction
return
RunButtonAction:
if (ini_runmode = "run")
{
ini_runhistory := append2string(ini_runhistory, RunChoice)
Run_string = %RunChoice%
Run, %Run_string%, , UseErrorLevel
}
if (ini_runmode = "search")
{
ini_searchhistory := append2string(ini_searchhistory, RunChoice)
Run_string = %ini_searchstring%%RunChoice%
Run, %Run_string%, , UseErrorLevel
}
if (ini_runmode = "wiki")
{
ini_wikihistory := append2string(ini_wikihistory, RunChoice)
Run_string = %ini_wikistring%%RunChoice%
Run, %Run_string%, , UseErrorLevel
}
if (A_LastError != 0)
{
Tooltip, RUN-Error! Number:%A_LastError%,1, 1
SetTimer, RemoveToolTip, -5000
}
Gosub, Gui_Update
return
append2string(input_string, append_string)
{
alloutputstring := append_string . "`n" . input_string
Loop, parse, alloutputstring, `n
{
if (A_Index > 20)
break
if (A_LoopField != "")
outputstring .= "`n" . A_LoopField
}
return %outputstring%
}
RemoveToolTip:
SetTimer, RemoveToolTip, Off
ToolTip
return
;--end-main execute section------------
;-------Config Section-----------------
GuiContextMenu:
Menu, ConfigMenu, Show
return
3GuiContextMenu:
Menu, ConfigMenu, Show
return
xx:
MsgBox,%Welcome_Message%
return
set_run:
Menu, Runmenu, UnCheck, Run
Menu, Runmenu, UnCheck, Search
Menu, Runmenu, UnCheck, Wikipedia
ini_runmode = run
Gosub, Gui_Update
return
set_search:
Menu, Runmenu, UnCheck, Run
Menu, Runmenu, UnCheck, Search
Menu, Runmenu, UnCheck, Wikipedia
ini_runmode = search
Gosub, Gui_Update
return
set_wikipedia:
Menu, Runmenu, UnCheck, Run
Menu, Runmenu, UnCheck, Search
Menu, Runmenu, UnCheck, Wikipedia
ini_runmode = wiki
Gosub, Gui_Update
return
TrayIconSwitch:
Menu, Configmenu, Uncheck, TrayIcon
ini_trayicon := !ini_trayicon
Menu, TRAY, NoIcon
Gosub, Gui_Update
return
HotKeySwitch:
Menu, Configmenu, Uncheck, HotKey Ctrl+Alt+R
ini_hotkey := !ini_hotkey
Hotkey, ~^!r, ShowPopUp, Off
Gosub, Gui_Update
return
ConfigGUI:
Gui, 2:Destroy
Gui, 2: +AlwysOnTop +Toolwindow
Gui, 2:+owner1
Gui, 2:Add, Text, x10 y10, Search Mode: (choose a web-prefix or enter one)
Gui, 2:Add, ComboBox, w300 x10 y+10 vSearchConfig, http://www.google.com/search?q=|http://www.google.es/search?q=|http://www.google.fr/search?q=|http://www.google.de/search?q=|http://search.msn.com/results.aspx?q=|http://search.yahoo.com/search?p=
Gui, 2:Add, Text, x10 y+10, Wikipedia Mode: (choose a web-prefix or enter one)
Gui, 2:Add, ComboBox, w300 x10 y+10 vWikiConfig, http://en.wikipedia.org/wiki/|http://es.wikipedia.org/wiki/|http://fr.wikipedia.org/wiki/|http://de.wikipedia.org/wiki/
Gui, 2:Add, Button, x10 y+10 gSaveConfig, Save
Gui, 2:Add, Button, x+30 gCancelConfig, Cancel
Gui, 2:Show, , RUN-Box Config
GuiControl, 2:, SearchConfig, %ini_searchstring%||
GuiControl, 2:, wikiConfig, %ini_wikistring%||
return
SaveConfig:
Gui, 2:Submit
ini_searchstring := SearchConfig
ini_wikistring := WikiConfig
Gui, 2:Destroy
return
2GuiClose:
2GuiEscape:
CancelConfig:
Gui, 2:Destroy
return
;---END-Config Section-----------------
;-------Main GUI Changing-----
GuiSize:
NewBoxWidth := A_GuiWidth - 43
NewButtonXPos := A_GuiWidth - 31
GuiControl,1: Move, RunChoice, x6 y6 w%NewBoxWidth%
GuiControl,1: Move, RunButton, x%NewButtonXPos% y6 w25
return
GUI_Move(wParam, lParam)
{
global active_ID, ini_guiposX, ini_guiposY
CoordMode, Mouse, Screen
MouseGetPos, Xpos, Ypos, OutputvarWin, OutputVarControl
WinGetPos, winXpos, winYpos, , , ahk_id %active_ID%
if (OutputvarWin = active_ID)
{
if (OutputVarControl = "")
{
xoffset := Xpos - winXpos
yoffset := Ypos - winYpos
; MsgBox, %xoffset% - %yoffset%
Loop
{
GetKeyState, state, LButton
if state = D
{
MouseGetPos, Xpos, Ypos
ini_guiposX := Xpos - Xoffset
ini_guiposY := Ypos - Yoffset
Gui,1: show, x%ini_guiposX% y%ini_guiposY%,
}
else
break
}
}
}
return
}
;-------Main GUI Changing-----
;-------Update GUI and Menu-----
Gui_Update:
if (ini_trayicon = "1")
{
Menu, ConfigMenu, Check, TrayIcon
Menu, TRAY, Icon
}
if (ini_hotkey = "1")
{
Menu, ConfigMenu, Check, HotKey Ctrl+Alt+R
Hotkey, ~^!r, ShowPopUp, On
}
if (ini_runmode = "run")
{
Guicontrol,1: , RunChoice, %ini_runhistory%
Guicontrol,3: , 3RunChoice, %ini_runhistory%
Guicontrol,3: , TypeButtonRun, 1
Menu, Runmenu, Check, Run
return
}
if (ini_runmode = "search")
{
Guicontrol,1: , RunChoice, %ini_searchhistory%
Guicontrol,3: , 3RunChoice, %ini_searchhistory%
Guicontrol,3: , TypeButtonSearch, 1
Menu, Runmenu, Check, Search
return
}
if (ini_runmode = "wiki")
{
Guicontrol,1: , RunChoice, %ini_wikihistory%
Guicontrol,3: , 3RunChoice, %ini_wikihistory%
Guicontrol,3: , TypeButtonWiki, 1
Menu, Runmenu, Check, Wikipedia
return
}
return
;--END--Update GUI and Menu-----
;-----PopUp Gui related----------
ShowPopUp:
Gui, 3: Show, w240 h55 , RUN-Box PopUp
return
3GuiEscape:
3GuiClose:
Gui, 3: Hide
return
;-End-PopUp Gui related----------
;-----ENDSCRIPT---------------
GuiClose:
savequit:
CoordMode, Mouse, Screen
WinGetPos, ini_gposX, ini_gposY, ini_gwidth , , ahk_id %active_ID%
;MsgBox, %ini_gposX% %ini_gposY%
IniWrite, %ini_runmode%, runbox.ini, general, runmode
IniWrite, %ini_gposX%, runbox.ini, general, GposX
IniWrite, %ini_gposY%, runbox.ini, general, GposY
IniWrite, %ini_gwidth%, runbox.ini, general, Gwidth
IniWrite, %ini_trayicon%, runbox.ini, general, TrayIcon
IniWrite, %ini_hotkey%, runbox.ini, general, Hotkey
IniWrite, %ini_searchstring%, runbox.ini, search, searchstring
IniWrite, %ini_wikistring%, runbox.ini, wikipedia, wikistring
Loop, parse, ini_runhistory, `n
{
if (A_Loopfield != "")
IniWrite, %A_Loopfield%, runbox.ini, run, %A_Index%
}
Loop, parse, ini_searchhistory, `n
{
if (A_Loopfield != "")
IniWrite, %A_Loopfield%, runbox.ini, search, %A_Index%
}
Loop, parse, ini_wikihistory, `n
{
if (A_Loopfield != "")
IniWrite, %A_Loopfield%, runbox.ini, wikipedia, %A_Index%
}
ExitApp
return |
Last edited by Zed Gecko on Sat May 10, 2008 4:32 am; edited 2 times in total |
|