Jump to content



Photo

Run Dialog Replacement


  • Please log in to reply
9 replies to this topic

#1 Yashied

Yashied

    Happy in Moscow

  • MVPs
  • 2,512 posts

Posted 10 May 2009 - 10:53 PM

LAST VERSION - 1.0
24-May-09

Project closed.

A simple script to replace the native Run dialog in Windows XP.

AutoIt         
#cs ----------------------------------------------------------------------------  AutoIt Version: 3.3.0.0  Author:         Yashied  Script Function:     Run Dialog. #ce ---------------------------------------------------------------------------- #Region AutoIt3Wrapper #AutoIt3Wrapper_Outfile=OutputRun.exe #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_Res_Description=Opens a program, folder, document, or Web site #AutoIt3Wrapper_Res_Fileversion=1.0 #AutoIt3Wrapper_Res_Language=1033 #AutoIt3Wrapper_Run_Au3check=n #AutoIt3Wrapper_Run_After=UtilitiesResHackerResHacker.exe -delete %out%, %out%, DIALOG, 1000, #AutoIt3Wrapper_Run_After=UtilitiesResHackerResHacker.exe -delete %out%, %out%, MENU, 166, #AutoIt3Wrapper_Run_After=UtilitiesResHackerResHacker.exe -delete %out%, %out%, ICON, 161, #AutoIt3Wrapper_Run_After=UtilitiesResHackerResHacker.exe -delete %out%, %out%, ICON, 162, #AutoIt3Wrapper_Run_After=UtilitiesResHackerResHacker.exe -delete %out%, %out%, ICON, 164, #AutoIt3Wrapper_Run_After=UtilitiesResHackerResHacker.exe -delete %out%, %out%, ICON, 169, #EndRegion AutoIt3Wrapper #Region Initialization #NoTrayIcon #Include <ComboConstants.au3> #Include <GUIComboBoxEx.au3> #Include <GUIConstantsEx.au3> #Include <GUIEdit.au3> #Include <Misc.au3> #Include <WindowsConstants.au3> #include <UDFsMRU.au3> Opt('MustDeclareVars', 1) Opt('MouseCoordMode', 2) Opt('WinTitleMatchMode', 3) Global Const $GUI_NAME = 'Run' Global Const $REG_KEY_NAME = 'HKCUSOFTWARE' & $GUI_NAME Global Const $GCL_HICON = -14 Global Const $GCL_HICONSM = -34 Global Const $WIN_LEFT_TOP = 0 Global Const $WIN_RIGHT_TOP = 1 Global Const $WIN_LEFT_BOTTOM = 2 Global Const $WIN_RIGHT_BOTTOM = 3 Global Const $WM_DROPFILES = 0x0233 If _Singleton('RunDlg', 1) = 0 Then     WinActivate('Run')     Exit EndIf Global $Form, $GUIMsg, $Combo, $Dummy, $Input, $ButtonOk, $ButtonCancel, $ButtonBrowse Global $Cmd, $pCmd = '', $Parameters = StringStripWS(_RegRead($REG_KEY_NAME, 'Parameters', 'REG_SZ', ''), 3) Global $Mru = _MRU_Create($REG_KEY_NAME & 'MRU'), $Fn, $Path = @MyDocumentsDir Global $Width, $Height #EndRegion Initialization #Region Main State If $CmdLine[0] > 0 Then     Select         Case StringLower($CmdLine[1]) = '/reset'             _MRU_Reset($Mru)             _MRU_RegWrite($Mru)             _MRU_Release($Mru)             RegWrite($REG_KEY_NAME, 'Parameters', 'REG_SZ', '')             Exit         Case Else             $pCmd = $CmdLine[1]             $Parameters = ''     EndSelect EndIf CreateForm() While 1     $GUIMsg = GUIGetMsg()     Select         Case ($GUIMsg = $ButtonCancel) Or ($GUIMsg = $GUI_EVENT_CLOSE)             _MRU_Release($Mru)             Exit         Case ($GUIMsg = $ButtonOk)             $Fn = StringStripWS(GUICtrlRead($Combo), 3)             $Parameters = StringStripWS(GUICtrlRead($Input), 3)             If $Fn > '' Then                 ShellExecute($Fn, $Parameters)                 If Not @error Then                     _MRU_AddItem($Mru, $Fn)                     _MRU_RegWrite($Mru)                     _MRU_Release($Mru)                     RegWrite($REG_KEY_NAME, 'Parameters', 'REG_SZ', $Parameters)                     Exit                 EndIf             EndIf         Case ($GUIMsg = $ButtonBrowse)             $Fn = FileOpenDialog('Select File', $Path, 'All files (*.*)', 1 + 2, '', $Form)             If $Fn > '' Then                 $Path = StringRegExpReplace($Fn, '[^]*$', '')                 GUICtrlSetState($Combo, $GUI_FOCUS)                 _GUICtrlComboBox_SetEditText($Combo, $Fn)                 _GUICtrlComboBox_SetEditSel($Combo, 0, -1)             EndIf         Case ($GUIMsg = $Dummy)             $Cmd = GUICtrlRead($Combo)             If $Cmd <> $pCmd Then                 GUICtrlSetData($Input, '')                 $pCmd = $Cmd             EndIf     EndSelect WEnd #EndRegion Main State #Region Additional Functions Func CreateForm()     Local $Parent     $Form = _GUICreateDlgFrame($GUI_NAME, 380, 160, -1, -1, $WS_SIZEBOX, $WS_EX_ACCEPTFILES, GUICreate('', 0, 0, 0, 0, 0, $WS_EX_TOOLWINDOW))     GUISetIcon(@SystemDir & 'shell32.dll', 25)     GUISetFont(8.5, 400, 0, 'Tahoma', $Form)     GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')     GUIRegisterMsg($WM_DROPFILES, 'WM_DROPFILES')     GUIRegisterMsg($WM_GETMINMAXINFO, 'WM_GETMINMAXINFO')     GUICtrlCreateIcon(@SystemDir & 'shell32.dll', 25, 12, 16, 32, 32)     GUICtrlSetState(-1, $GUI_DISABLE)     GUICtrlSetResizing(-1, 802)     GUICtrlCreateLabel('Type the name of a program, folder, document, or Internet resource, and Windows will open it for you.', 56, 16, 310, 41)     GUICtrlSetResizing(-1, 550)     GUICtrlCreateLabel('Open:', 12, 61, 42, 14)     GUICtrlSetResizing(-1, 802)     $Combo = GUICtrlCreateCombo('', 56, 58, 310, 21, BitOR($CBS_AUTOHSCROLL, $CBS_DROPDOWN))     GUICtrlSetData(-1, _MRU_GetAsString($Mru, '|'))     GUICtrlSetResizing(-1, 550)     $Dummy = GUICtrlCreateDummy()     GUICtrlCreateLabel('With:', 12, 89, 42, 14)     GUICtrlSetResizing(-1, 802)     $Input = GUICtrlCreateInput($Parameters, 56, 86, 310, 21)     GUICtrlSetResizing(-1, 550)     GUICtrlSetResizing(-1, 550)     If $pCmd = '' Then         $pCmd = _Mru_GetItem($Mru, 1)     EndIf     _GUICtrlComboBox_SetEditText($Combo, $pCmd)     If $CmdLine[0] > 0 Then         GUICtrlSetState($Input, $GUI_FOCUS)         _GUICtrlEdit_SetSel($Input, -1, -1)     Else         GUICtrlSetState($Combo, $GUI_FOCUS)         _GUICtrlComboBox_SetEditSel($Combo, 0, -1)     EndIf     $ButtonOk = GUICtrlCreateButton('OK', 130, 129, 75, 23)     GUICtrlSetState(-1, $GUI_DEFBUTTON)     GUICtrlSetResizing(-1, 804)     $ButtonCancel = GUICtrlCreateButton('Cancel', 211, 129, 75, 23)     GUICtrlSetResizing(-1, 804)     $ButtonBrowse = GUICtrlCreateButton('Browse...', 292, 129, 75, 23)     GUICtrlSetResizing(-1, 804)     $Width = _GetWindowWidth($Form)     $Height = _GetWindowHeight($Form)     _SetWindowPos($Form, 3, 3, $Width, $Height, $WIN_LEFT_BOTTOM)     GUISetState() EndFunc   ;==>CreateForm Func _GetDesktopArea()     Const $SPI_GETWORKAREA = 48     Local $tRect = DllStructCreate('long Left;long Top;long Right;long Bottom')     Local $aRect[4], $aRet     $aRet = DllCall('user32.dll', 'int', 'SystemParametersInfo', 'uint', $SPI_GETWORKAREA, 'uint', 0, 'ptr', DllStructGetPtr($tRect), 'uint', 0)     If (@error) Or ($aRet[0] = 0) Then         Return SetError(1, 0, 0)     EndIf     $aRect[0] = DllStructGetData($tRect, 'Left')     $aRect[1] = DllStructGetData($tRect, 'Top')     $aRect[2] = DllStructGetData($tRect, 'Right')     $aRect[3] = DllStructGetData($tRect, 'Bottom')     Return SetError(0, 0, $aRect) EndFunc   ;==>_GetDesktopArea Func _GetTaskbarHeight()     Local $Desktop = _GetDesktopArea()     If @error Then         Return SetError(1, 0, 0)     EndIf     Return SetError(0, 0, @DesktopHeight - $Desktop[3]) EndFunc   ;==>_GetTaskbarHeight Func _GetWindowHeight($hWnd)     Local $tRet, $iHeight     $tRet = _WinAPI_GetWindowPlacement($hWnd)     If @error Then         Return SetError(1, 0, 0)     EndIf     $iHeight = DllStructGetData($tRet, 'rcNormalPosition', 4) - DllStructGetData($tRet, 'rcNormalPosition', 2)     $tRet = 0     Return SetError(0, 0, $iHeight) EndFunc   ;==>_GetWindowHeight Func _GetWindowWidth($hWnd)     Local $tRet, $iWidth     $tRet = _WinAPI_GetWindowPlacement($hWnd)     If @error Then         Return SetError(1, 0, 0)     EndIf     $iWidth = DllStructGetData($tRet, 'rcNormalPosition', 3) - DllStructGetData($tRet, 'rcNormalPosition', 1)     $tRet = 0     Return SetError(0, 0, $iWidth) EndFunc   ;==>_GetWindowWidth Func _GUICreateDlgFrame($sTitle, $iWidth = -1, $iHeight = -1, $iLeft = -1, $iTop = -1, $iStyle = 0, $iExStyle = 0, $hParent = 0)     Local $hWnd = GUICreate($sTitle, $iWidth, $iHeight, $iLeft, $iTop, BitOR($WS_CAPTION, $WS_SYSMENU, $iStyle), BitOR($WS_EX_DLGMODALFRAME, $iExStyle), $hParent)     If (@error) Or ($hWnd = 0) Then         Return SetError(1, 0, 0)     EndIf     Local $hIcon = _WinAPI_GetClassLong($hWnd, $GCL_HICON)     If IsPtr($hIcon) Then         _WinAPI_DestroyIcon($hIcon)     EndIf     _WinAPI_SetClassLong($hWnd, $GCL_HICON, 0)     _WinAPI_SetClassLong($hWnd, $GCL_HICONSM, 0)     Return SetError(0, 0, $hWnd) EndFunc   ;==>_GUICreateDlgFrame Func _MouseIn($X1, $Y1, $X2, $Y2)     Local $pos     $pos = MouseGetPos()     If ($pos[0] >= $X1) And ($pos[0] <= $X2) And ($pos[1] >= $Y1) And ($pos[1] <= $Y2) Then         Return 1     Else         Return 0     EndIf EndFunc   ;==>_MouseIn Func _RegRead($Key, $Value, $Type, $Default)     Local $Val = RegRead($Key, $Value)     If @error Then         RegWrite($Key, $Value, $Type, $Default)         Return $Default     EndIf     Switch StringUpper($Type)         Case 'REG_SZ', 'REG_MULTI_SZ', 'REG_EXPAND_SZ'             If Not IsString($Val) Then                 Return SetError(1, 0, $Default)             EndIf         Case 'REG_BINARY'             If Not IsBinary($Val) Then                 Return SetError(1, 0, $Default)             EndIf         Case 'REG_DWORD'             If Not IsInt($Val) Then                 Return SetError(1, 0, $Default)             EndIf         Case Else             Return SetError(1, 0, $Default)     EndSwitch     Return $Val EndFunc   ;==>_RegRead Func _SetWindowPos($hWnd, $iX, $iY, $iWidth = -1, $iHeight = -1, $iFlag = $WIN_LEFT_TOP)     Local $tRet     $tRet = _WinAPI_GetWindowPlacement($hWnd)     If @error Then         Return SetError(1, 0, 0)     EndIf     If $iWidth < 0 Then         $iWidth = DllStructGetData($tRet, 'rcNormalPosition', 3) - DllStructGetData($tRet, 'rcNormalPosition', 1)     EndIf     If $iHeight < 0 Then         $iHeight = DllStructGetData($tRet, 'rcNormalPosition', 4) - DllStructGetData($tRet, 'rcNormalPosition', 2)     EndIf     Switch $iFlag         Case $WIN_LEFT_TOP             DllStructSetData($tRet, 'rcNormalPosition', $iX, 1)             DllStructSetData($tRet, 'rcNormalPosition', $iY, 2)             DllStructSetData($tRet, 'rcNormalPosition', $iX + $iWidth, 3)             DllStructSetData($tRet, 'rcNormalPosition', $iY + $iHeight, 4)         Case $WIN_RIGHT_TOP             DllStructSetData($tRet, 'rcNormalPosition', @DesktopWidth - $iWidth - $iX, 1)             DllStructSetData($tRet, 'rcNormalPosition', $iY, 2)             DllStructSetData($tRet, 'rcNormalPosition', DllStructGetData($tRet, 'rcNormalPosition', 1) + $iWidth, 3)             DllStructSetData($tRet, 'rcNormalPosition', $iY + $iHeight, 4)         Case $WIN_LEFT_BOTTOM             DllStructSetData($tRet, 'rcNormalPosition', $iX, 1)             DllStructSetData($tRet, 'rcNormalPosition', @DesktopHeight - $iHeight - _GetTaskbarHeight() - $iY, 2)             DllStructSetData($tRet, 'rcNormalPosition', $iX + $iWidth, 3)             DllStructSetData($tRet, 'rcNormalPosition', DllStructGetData($tRet, 'rcNormalPosition', 2) + $iHeight, 4)         Case $WIN_RIGHT_BOTTOM             DllStructSetData($tRet, 'rcNormalPosition', @DesktopWidth - $iWidth - $iX, 1)             DllStructSetData($tRet, 'rcNormalPosition', @DesktopHeight - $iHeight - _GetTaskbarHeight() - $iY, 2)             DllStructSetData($tRet, 'rcNormalPosition', DllStructGetData($tRet, 'rcNormalPosition', 1) + $iWidth, 3)             DllStructSetData($tRet, 'rcNormalPosition', DllStructGetData($tRet, 'rcNormalPosition', 2) + $iHeight, 4)         Case Else     EndSwitch     _WinAPI_SetWindowPlacement($hWnd, DllStructGetPtr($tRet))     $tRet = 0     Return SetError(0, 0, 1) EndFunc   ;==>_SetWindowPos Func _WinAPI_GetClassLong($hWnd, $nIndex)     Local $Ret = DllCall('user32.dll', 'int', 'GetClassLong', 'hwnd', $hWnd, 'int', $nIndex)     If (@error) Or ($Ret[0] = 0) Then         Return SetError(1, 0, 0)     EndIf     Return $Ret[0] EndFunc   ;==>_WinAPI_GetClassLong Func _WinAPI_SetClassLong($hWnd, $nIndex, $dwNewLong)     Local $Ret = DllCall('user32.dll', 'int', 'SetClassLong', 'hwnd', $hWnd, 'int', $nIndex, 'long', $dwNewLong)     If (@error) Or ($Ret[0] = 0) Then         Return SetError(1, 0, 0)     EndIf     Return $Ret[0] EndFunc   ;==>_WinAPI_SetClassLong #EndRegion Additional Functions #Region Windows Message Functions Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)     Switch BitAND($wParam, 0xFFFF)         Case $Combo             Switch BitShift($wParam, 16)                 Case $CBN_EDITCHANGE                     _GUICtrlComboBox_AutoComplete($Combo)                     ContinueCase                 Case $CBN_SELCHANGE                     GUICtrlSendToDummy($Dummy)             EndSwitch     EndSwitch     Return $GUI_RUNDEFMSG EndFunc   ;==>WM_COMMAND Func WM_DROPFILES($hWnd, $iMsg, $wParam, $lParam)     Local $Data, $Drag, $Size, $Name, $File     Local $Amt = DllCall('shell32.dll', 'int', 'DragQueryFile', 'hwnd', $wParam, 'int', -1, 'ptr', 0, 'int', 255)     If $Amt[0] = 0 Then         Return 0     EndIf     $Drag = DllCall('shell32.dll', 'int', 'DragQueryFile', 'hwnd', $wParam, 'int', 0, 'ptr', 0, 'int', 0)     $Size = $Drag[0] + 1     $Name = DllStructCreate('char[' & $Size & ']')     DllCall('shell32.dll', 'int', 'DragQueryFile', 'hwnd', $wParam, 'int', 0, 'ptr', DllStructGetPtr($Name), 'int', $Size)     $File = DllStructGetData($Name, 1)     $Name = 0     GUISetState(@SW_RESTORE)     If _MouseIn(56, 86, 366 + (_GetWindowWidth($Form) - $Width), 107) Then         If StringInStr($File, ' ') Then             $File = '"' & $File & '"'         EndIf         GUICtrlSetState($Input, $GUI_FOCUS)         GUICtrlSetData($Input, GUICtrlRead($Input) & $File)         _GUICtrlEdit_SetSel($Input, -1, -1)     Else         GUICtrlSetState($Combo, $GUI_FOCUS)         _GUICtrlComboBox_SetEditText($Combo, $File)         _GUICtrlComboBox_SetEditSel($Combo, 0, -1)     EndIf     Return 0 EndFunc   ;==>WM_DROPFILES Func WM_GETMINMAXINFO($hWnd, $iMsg, $wParam, $lParam)     Local $tMINMAXINFO = DllStructCreate('int ptReserved[2];int ptMaxSize[2];int ptMaxPosition[2];int ptMinTrackSize[2];int ptMaxTrackSize[2]', $lParam)     DllStructSetData($tMINMAXINFO, 'ptMinTrackSize', $Width, 1)     DllStructSetData($tMINMAXINFO, 'ptMinTrackSize', $Height, 2)     DllStructSetData($tMINMAXINFO, 'ptMaxTrackSize', @DesktopWidth, 1)     DllStructSetData($tMINMAXINFO, 'ptMaxTrackSize', $Height, 2)     Return 0 EndFunc   ;==>WM_GETMINMAXINFO #EndRegion Windows Message Functions



Files to download

Binary
Redirection to Run_bin.zip, 431 KB

Attached File  Run_bin.html   130bytes   124 downloads

Source
To run this example you need to download MRU UDF Library .

Attached File  Run.au3   13.07K   405 downloads

Edited by Yashied, 05 March 2012 - 08:07 PM.






#2 lsakizada

lsakizada

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 392 posts

Posted 16 May 2009 - 07:55 AM

AutoIt         
#cs ----------------------------------------------------------------------------  AutoIt Version: 3.3.0.0  Author:         Yashied  Script Function:     Run Dialog. #ce ---------------------------------------------------------------------------- #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_outfile=Run.exe #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_Res_Description=Opens a program, folder, document, or Web site #AutoIt3Wrapper_Res_Fileversion=1.0 #AutoIt3Wrapper_Res_Language=1033 #AutoIt3Wrapper_Run_AU3Check=n #AutoIt3Wrapper_Run_After=Utilities\ResHacker\ResHacker.exe -delete %out%, %out%, DIALOG, 1000, #AutoIt3Wrapper_Run_After=Utilities\ResHacker\ResHacker.exe -delete %out%, %out%, MENU, 166, #AutoIt3Wrapper_Run_After=Utilities\ResHacker\ResHacker.exe -delete %out%, %out%, ICON, 161, #AutoIt3Wrapper_Run_After=Utilities\ResHacker\ResHacker.exe -delete %out%, %out%, ICON, 162, #AutoIt3Wrapper_Run_After=Utilities\ResHacker\ResHacker.exe -delete %out%, %out%, ICON, 164, #AutoIt3Wrapper_Run_After=Utilities\ResHacker\ResHacker.exe -delete %out%, %out%, ICON, 169, #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #NoTrayIcon #Include <ComboConstants.au3> #Include <GUIComboBoxEx.au3> #Include <GUIConstantsEx.au3> #Include <GUIEdit.au3> #Include <Misc.au3> #Include <WinAPI.au3> #Include <WindowsConstants.au3> #Include <MRU.au3> Opt('MustDeclareVars', 1) Opt('MouseCoordMode', 2) Opt('WinTitleMatchMode', 3) const $GUI_NAME = 'Run' const $REG_KEY_NAME = 'HKCU\SOFTWARE\' & $GUI_NAME const $GCL_HICON = -14 const $GCL_HICONSM = -34 const $WIN_LEFT_TOP = 0 const $WIN_RIGHT_TOP = 1 const $WIN_LEFT_BOTTOM = 2 const $WIN_RIGHT_BOTTOM = 3 const $WM_DROPFILES = 0x0233 if _Singleton('RunDlg', 1) = 0 then     WinActivate('Run')     exit endif local $Form, $GUIMsg, $Combo, $Input, $ButtonOk, $ButtonCancel, $ButtonBrowse local $Cmd, $pCmd = '', $Parameters = StringStripWS(_RegRead($REG_KEY_NAME, 'Parameters', 'REG_SZ', ''), 3) local $Mru = _MRU_Create($REG_KEY_NAME & '\MRU'), $Fn, $Path = @MyDocumentsDir local $Width, $Height ; Main if $CmdLine[0] > 0 then     select         case StringLower($CmdLine[1]) = '/reset'             _MRU_Reset($Mru)             _MRU_RegWrite($Mru)             _MRU_Release($Mru)             RegWrite($REG_KEY_NAME, 'Parameters', 'REG_SZ', '')             exit         case else             $pCmd = $CmdLine[1]             $Parameters = ''     endselect endif CreateForm() while 1     $Cmd = GUICtrlRead($Combo)     if $pCmd <> $Cmd then         $pCmd = $Cmd         GUICtrlSetData($Input, '')     endif     $GUIMsg = GUIGetMsg()     select         case ($GUIMsg = $ButtonCancel) or ($GUIMsg = $GUI_EVENT_CLOSE)             _MRU_Release($Mru)             exit         case ($GUIMsg = $ButtonOk)             $Fn = StringStripWS(GUICtrlRead($Combo), 3)             $Parameters = StringStripWS(GUICtrlRead($Input), 3)             if $Fn > '' then                 ShellExecute($Fn, $Parameters)                 if not @error then                     _MRU_AddItem($Mru, $Fn)                     _MRU_RegWrite($Mru)                     _MRU_Release($Mru)                     RegWrite($REG_KEY_NAME, 'Parameters', 'REG_SZ', $Parameters)                     exit                 endif             endif         case ($GUIMsg = $ButtonBrowse)             $Fn = FileOpenDialog('Select File', $Path, 'All files (*.*)', 1 + 2, '', $Form)             if $Fn > '' then                 $Path = StringMid($Fn, 1, StringInStr($Fn, '\', 0, -1) - 1)                 GUICtrlSetState($Combo, $GUI_FOCUS)                 _GUICtrlComboBox_SetEditText($Combo, $Fn)                 _GUICtrlComboBox_SetEditSel($Combo, 0, -1)             endif     endselect wend ; Main func WM_COMMAND($hWnd, $msgID, $wParam, $lParam)     switch $lParam         case GUICtrlGetHandle($Combo)             if BitShift($wParam, 0x10) = $CBN_EDITCHANGE then                 _GUICtrlComboBox_AutoComplete($Combo)             endif         case else     endswitch     return $GUI_RUNDEFMSG endfunc; WM_COMMAND         func WM_DROPFILES($hWnd, $msgID, $wParam, $lParam)     local $Data, $Drag, $Size, $Name, $File     local $Amt = DllCall('shell32.dll', 'int', 'DragQueryFile', 'hwnd', $wParam, 'int', 0xFFFFFFFF, 'ptr', 0, 'int', 255)         if $Amt[0] = 0 then         return     endif     $Drag = DllCall('shell32.dll', 'int', 'DragQueryFile', 'hwnd', $wParam, 'int', 0, 'ptr', 0, 'int', 0)     $Size = $Drag[0] + 1     $Name = DllStructCreate('char[' & $Size & ']')     DllCall('shell32.dll', 'int', 'DragQueryFile', 'hwnd', $wParam, 'int', 0, 'ptr', DllStructGetPtr($Name), 'int', $Size)     $File = DllStructGetData($Name, 1)     $Name = 0     GUISetState(@SW_RESTORE)     if _MouseIn(56, 86, 366 + (_GetWindowWidth($Form) - $Width), 107) then         if StringInStr($File, ' ') then             $File = '"' & $File & '"'         endif         GUICtrlSetState($Input, $GUI_FOCUS)         GUICtrlSetData($Input, GUICtrlRead($Input) & $File)         _GUICtrlEdit_SetSel($Input, -1, -1)     else         GUICtrlSetState($Combo, $GUI_FOCUS)         _GUICtrlComboBox_SetEditText($Combo, $File)         _GUICtrlComboBox_SetEditSel($Combo, 0, -1)     endif endfunc; WM_DROPFILES func WM_GETMINMAXINFO($hWnd, $msgID, $wParam, $lParam)         local $tMINMAXINFO = DllStructCreate('int ptReserved[2];int ptMaxSize[2];int ptMaxPosition[2];int ptMinTrackSize[2];int ptMaxTrackSize[2]', $lParam)         DllStructSetData($tMINMAXINFO, 'ptMinTrackSize', $Width, 1)     DllStructSetData($tMINMAXINFO, 'ptMinTrackSize', $Height, 2)     DllStructSetData($tMINMAXINFO, 'ptMaxTrackSize', @DesktopWidth, 1)     DllStructSetData($tMINMAXINFO, 'ptMaxTrackSize', $Height, 2)         return 0 endfunc; WM_GETMINMAXINFO func CreateForm()     local $Parent         $Form = _GUICreateDlgFrame('Run', 380, 160, -1, -1, $WS_SIZEBOX, $WS_EX_ACCEPTFILES, GUICreate('', 0, 0, 0, 0, 0, $WS_EX_TOOLWINDOW))     GUISetIcon(@SystemDir & '\shell32.dll', 25)     GUISetFont(8.5, 400, 0, 'Tahoma', $Form)     GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')     GUIRegisterMsg($WM_DROPFILES, 'WM_DROPFILES')     GUIRegisterMsg($WM_GETMINMAXINFO, 'WM_GETMINMAXINFO')         GUICtrlCreateIcon(@SystemDir & '\shell32.dll', 25, 12, 16, 32, 32)     GUICtrlSetState(-1, $GUI_DISABLE)     GUICtrlSetResizing(-1, 802)     GUICtrlCreateLabel('Type the name of a program, folder, document, or Internet resource, and Windows will open it for you.', 56, 16, 310, 41)     GUICtrlSetResizing(-1, 550)     GUICtrlCreateLabel('Open:', 12, 61, 42, 14)     GUICtrlSetResizing(-1, 802)     $Combo = GUICtrlCreateCombo('', 56, 58, 310, 21, BitOR($CBS_AUTOHSCROLL, $CBS_DROPDOWN))     GUICtrlSetData(-1, _MRU_GetAsString($Mru, '|'))     GUICtrlSetResizing(-1, 550)     GUICtrlCreateLabel('With:', 12, 89, 42, 14)     GUICtrlSetResizing(-1, 802)     $Input = GUICtrlCreateInput($Parameters, 56, 86, 310, 21)     GUICtrlSetResizing(-1, 550)     GUICtrlSetResizing(-1, 550)     if $pCmd = '' then         $pCmd = _Mru_GetItem($Mru, 1)     endif     _GUICtrlComboBox_SetEditText($Combo, $pCmd)     if $CmdLine[0] > 0 then         GUICtrlSetState($Input, $GUI_FOCUS)         _GUICtrlEdit_SetSel($Input, -1, -1)     else         GUICtrlSetState($Combo, $GUI_FOCUS)         _GUICtrlComboBox_SetEditSel($Combo, 0, -1)     endif     $ButtonOk = GUICtrlCreateButton('OK', 130, 129, 75, 23)     GUICtrlSetState(-1, $GUI_DEFBUTTON)     GUICtrlSetResizing(-1, 804)     $ButtonCancel = GUICtrlCreateButton('Cancel', 211, 129, 75, 23)     GUICtrlSetResizing(-1, 804)     $ButtonBrowse = GUICtrlCreateButton('Browse...', 292, 129, 75, 23)     GUICtrlSetResizing(-1, 804)     $Width = _GetWindowWidth($Form)     $Height = _GetWindowHeight($Form)         _SetWindowPos($Form, 3, 3, $Width, $Height, $WIN_LEFT_BOTTOM)         GUISetState()     endfunc; CreateForm func _GetDesktopArea()     const $SPI_GETWORKAREA = 48     local $tRect = DllStructCreate('long Left;long Top;long Right;long Bottom')     local $aRect[4], $aRet         $aRet = DllCall('user32.dll', 'int', 'SystemParametersInfo', 'uint', $SPI_GETWORKAREA, 'uint', 0, 'ptr', DllStructGetPtr($tRect), 'uint', 0)     if (@error) or ($aRet[0] = 0) then         return SetError(1, 0, 0)     endif         $aRect[0] = DllStructGetData($tRect, 'Left')     $aRect[1] = DllStructGetData($tRect, 'Top')     $aRect[2] = DllStructGetData($tRect, 'Right')     $aRect[3] = DllStructGetData($tRect, 'Bottom')     return SetError(0, 0, $aRect) endfunc; _GetDesktopArea func _GetTaskbarHeight()     local $Desktop = _GetDesktopArea()         if @error then         return SetError(1, 0, 0)     endif         return SetError(0, 0, @DesktopHeight - $Desktop[3]) endfunc; _GetTaskbarHeight func _GetWindowWidth($hWnd)         local $tRet, $iWidth         $tRet = _WinAPI_GetWindowPlacement($hWnd)     if @error then         return SetError(1, 0, 0)     endif     $iWidth = DllStructGetData($tRet, 'rcNormalPosition', 3) - DllStructGetData($tRet, 'rcNormalPosition', 1)     $tRet = 0         return SetError(0, 0, $iWidth) endfunc; _GetWindowWidth func _GetWindowHeight($hWnd)         local $tRet, $iHeight         $tRet = _WinAPI_GetWindowPlacement($hWnd)     if @error then         return SetError(1, 0, 0)     endif     $iHeight = DllStructGetData($tRet, 'rcNormalPosition', 4) - DllStructGetData($tRet, 'rcNormalPosition', 2)     $tRet = 0         return SetError(0, 0, $iHeight) endfunc; _GetWindowHeight func _GUICreateDlgFrame($sTitle, $iWidth = -1, $iHeight = -1, $iLeft = -1, $iTop = -1, $iStyle = 0, $iExStyle = 0, $hParent = 0)     local $hWnd = GUICreate($sTitle, $iWidth, $iHeight, $iLeft, $iTop, BitOR($WS_CAPTION, $WS_SYSMENU, $iStyle), BitOR($WS_EX_DLGMODALFRAME, $iExStyle), $hParent)         if (@error) or ($hWnd = 0) then         return SetError(1, 0, 0)     endif         local $hIcon = _WinAPI_GetClassLong($hWnd, $GCL_HICON)         if IsPtr($hIcon) then         _WinAPI_DestroyIcon($hIcon)     endif         _WinAPI_SetClassLong($hWnd, $GCL_HICON, 0)     _WinAPI_SetClassLong($hWnd, $GCL_HICONSM, 0)         return SetError(0, 0, $hWnd) endfunc; _GUICreateDlgFrame func _RegRead($Key, $Value, $Type, $Default)         local $Val = RegRead($Key, $Value)     if @error then         RegWrite($Key, $Value, $Type, $Default)         return $Default     endif         switch StringUpper($Type)         case 'REG_SZ', 'REG_MULTI_SZ', 'REG_EXPAND_SZ'             if not IsString($Val) then                 return SetError(1, 0, $Default)             endif         case 'REG_BINARY'             if not IsBinary($Val) then                 return SetError(1, 0, $Default)             endif         case 'REG_DWORD'             if not IsInt($Val) then                 return SetError(1, 0, $Default)             endif         case else             return SetError(1, 0, $Default)     endswitch     return $Val endfunc; _RegRead func _SetWindowPos($hWnd, $iX, $iY, $iWidth = -1, $iHeight = -1, $iFlag = $WIN_LEFT_TOP)         local $tRet         $tRet = _WinAPI_GetWindowPlacement($hWnd)     if @error then         return SetError(1, 0, 0)     endif     if $iWidth < 0 then         $iWidth = DllStructGetData($tRet, 'rcNormalPosition', 3) - DllStructGetData($tRet, 'rcNormalPosition', 1)     endif     if $iHeight < 0 then         $iHeight = DllStructGetData($tRet, 'rcNormalPosition', 4) - DllStructGetData($tRet, 'rcNormalPosition', 2)     endif     switch $iFlag         case $WIN_LEFT_TOP             DllStructSetData($tRet, 'rcNormalPosition', $iX, 1)             DllStructSetData($tRet, 'rcNormalPosition', $iY, 2)             DllStructSetData($tRet, 'rcNormalPosition', $iX + $iWidth, 3)             DllStructSetData($tRet, 'rcNormalPosition', $iY + $iHeight, 4)         case $WIN_RIGHT_TOP             DllStructSetData($tRet, 'rcNormalPosition', @DesktopWidth - $iWidth - $iX, 1)             DllStructSetData($tRet, 'rcNormalPosition', $iY, 2)             DllStructSetData($tRet, 'rcNormalPosition', DllStructGetData($tRet, 'rcNormalPosition', 1) + $iWidth, 3)             DllStructSetData($tRet, 'rcNormalPosition', $iY + $iHeight, 4)         case $WIN_LEFT_BOTTOM             DllStructSetData($tRet, 'rcNormalPosition', $iX, 1)             DllStructSetData($tRet, 'rcNormalPosition', @DesktopHeight - $iHeight - _GetTaskbarHeight() - $iY, 2)             DllStructSetData($tRet, 'rcNormalPosition', $iX + $iWidth, 3)             DllStructSetData($tRet, 'rcNormalPosition', DllStructGetData($tRet, 'rcNormalPosition', 2) + $iHeight, 4)         case $WIN_RIGHT_BOTTOM             DllStructSetData($tRet, 'rcNormalPosition', @DesktopWidth - $iWidth - $iX, 1)             DllStructSetData($tRet, 'rcNormalPosition', @DesktopHeight - $iHeight - _GetTaskbarHeight() - $iY, 2)             DllStructSetData($tRet, 'rcNormalPosition', DllStructGetData($tRet, 'rcNormalPosition', 1) + $iWidth, 3)             DllStructSetData($tRet, 'rcNormalPosition', DllStructGetData($tRet, 'rcNormalPosition', 2) + $iHeight, 4)         case else                 endswitch     _WinAPI_SetWindowPlacement($hWnd, DllStructGetPtr($tRet))     $tRet = 0         return SetError(0, 0, 1) endfunc; _SetWindowPos func _WinAPI_GetClassLong($hWnd, $nIndex)         local $ret = DllCall('user32.dll', 'int', 'GetClassLong', 'hwnd', $hWnd, 'int', $nIndex)         if (@error) or ($ret[0] = 0) then         return 0     endif     return $ret[0] endfunc; _WinAPI_GetClassLong func _WinAPI_SetClassLong($hWnd, $nIndex, $dwNewLong)         local $ret = DllCall('user32.dll', 'int', 'SetClassLong', 'hwnd', $hWnd, 'int', $nIndex, 'long', $dwNewLong)         if (@error) or ($ret[0] = 0) then         return 0     endif     return $ret[0] endfunc; _WinAPI_SetClassLong

Also needed MRU.au3

This is realy nice code, I wonder how come no comments on it
Be Green Now or Never (BGNN)!

#3 martin

martin

    ~~\o/~~~/0\=¬''~~~

  • MVPs
  • 7,199 posts

Posted 23 May 2009 - 05:27 PM

Definitely better than the Windows Run option :)

A small suggestion: I think it needs 2 browse buttons.
For example, I tried to open file which I found by browsing, and then I wanted to open it with an application which I wanted to find by browsing.
mgrefyashiedrun

Edited by martin, 24 May 2009 - 07:03 AM.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

#4 colafrysen

colafrysen

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 264 posts

Posted 23 May 2009 - 06:11 PM

Great app, it didn't like drag n drop though

Error:

---------------------------
AutoIt Error
---------------------------
Line 149 (File "C:\Documents and Settings\Ricky\Desktop\Run.au3"):

if _MouseIn(56, 86, 366 + (_GetWindowWidth($Form) - $Width), 107) then
if ^ ERROR

Error: Unknown function name.
---------------------------
OK
---------------------------

Edited by colafrysen, 23 May 2009 - 06:11 PM.

Use the helpfile, It´s one of the best exlusive features of Autoit.http://support.microsoft.com/kb/q555375ALIBI Run - a replacement for the windows run promptPC Controller - an application for controlling other PCsScience flies us to the moon. Religion flies us into buildings.http://bit.ly/cAMPZV

#5 Valuater

Valuater

    www.PayFreeWireless.com

  • MVPs
  • 11,078 posts

Posted 23 May 2009 - 06:24 PM

Same as above

ERROR: _MouseIn(): undefined function.


8)

Posted Image

Clic The Pic!!!


#6 Yashied

Yashied

    Happy in Moscow

  • MVPs
  • 2,512 posts

Posted 23 May 2009 - 07:08 PM

I apologize. I use their librarys, and when posting script forgot to insert _MouseIn() function. Corrected.

:)

#7 hegearon

hegearon

    Seeker

  • Active Members
  • 7 posts

Posted 16 June 2009 - 09:43 PM

It's a great script, definitely better than the built in windows Run dialog. I agree with lsakizada another browse button would be great.

#8 pomj

pomj

    Seeker

  • Active Members
  • 7 posts

Posted 02 June 2011 - 10:58 PM

Hi Yashied,

When I try to run this I get the following errormessage:

---------------------------
AutoIt Error
---------------------------
Line 642 (File "C:\Users\michael\Downloads\UDFs\MRU.au3"):

$str &= $MruArray[Asc(StringLeft(StringTrimLeft($MruArray[0], $j - 1), 1)) - 96]
$str &= $MruArray[^ ERROR

Error: Array variable subscript badly formatted.
---------------------------
OK
---------------------------

I'm running the latest beta on win7.

br /michael

#9 Yashied

Yashied

    Happy in Moscow

  • MVPs
  • 2,512 posts

Posted 03 June 2011 - 05:52 AM

Run.exe

#10 qwert

qwert

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 499 posts

Posted 04 June 2011 - 03:30 PM

AutoIt Error
---------------------------
Line 642 (File "C:\Users\michael\Downloads\UDFs\MRU.au3"):

$str &= $MruArray[Asc(StringLeft(StringTrimLeft($MruArray[0], $j - 1), 1)) - 96]
$str &= $MruArray[^ ERROR

Error: Array variable subscript badly formatted.

I'm getting this same error. Can someone suggest a simplifying construct that might pass the syntax check?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users