Jump to content

Start exe as child of explorer.exe


kiboost
 Share

Go to solution Solved by johnmcloud,

Recommended Posts

Try this :

#include <File.au3>

Func RunFromExplorer($exePath = "")
    If $exePath = "" Then Return

    Local $szDrive, $szDir, $szFName, $szExt
    $paths = _PathSplit($exePath, $szDrive, $szDir, $szFName, $szExt)
    $workingPath = $szDrive&$szDir
    ConsoleWrite($workingPath&@CR)

    $HotKey = "^!j" ; CTRL + ALT + U
    $shortcutPath = @DesktopDir & "\TmpLauncher.lnk"
    FileCreateShortcut($exePath, $shortcutPath, $workingPath, "", "", $exePath, $HotKey, "0", @SW_SHOWNORMAL); create a shortcut
    Send($HotKey) ; send the combination of key for open the software
    sleep(500)
    FileDelete($shortcutPath)
EndFunc


RunFromExplorer("C:\Windows\notepad.exe")
sleep(1000)
RunFromExplorer("C:\Program Files (x86)\Windows NT\Accessories\wordpad.exe")
Exit

Works only first time. then you need to close/reopen session ...

http://discuss.pcmag.com/forums/thread/1004433200.aspx

Win7 pro x64. scripts compiled to x64. - Autoit v3.3.6.1 | Scite 1.79

Link to comment
Share on other sites

true, it is not flexible, and considering the non-robustness of virtual keystrokes compared to direct calls, i'd advise against using this technique as a general all-purpose solution. that's why i suggested to use a shortcut keys combination that is unlikely to be in use (you can do that with FileCreateShortcut although not manually from the .lnk properties dialog). and in your scenario, you seem to need it on a regular basis, so no point in deleting or changing the shortcut or the keys combination.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

well, I would need four or five such shortcut, so I could create them on the fly from logon startscript, and then just use them without creating/deleting them. Not a very nice way but should work.

Win7 pro x64. scripts compiled to x64. - Autoit v3.3.6.1 | Scite 1.79

Link to comment
Share on other sites

  • Solution

My last shot on this:

;johnmcloud

_RunFromExplorer("notepad.exe")
Sleep(1000)
_RunFromExplorer("calc.exe")

Func _RunFromExplorer($ExePath = "")
    If $ExePath = "" Then SetError(1, 0, 0)
    $objShell = ObjCreate("Shell.Application")
    $objShell.FileRun
    WinWait("[CLASS:#32770]", "")
    ControlSetText("[CLASS:#32770]", "", "Edit1", $ExePath)
    ControlClick("[CLASS:#32770]", "", "Button2")
EndFunc   ;==>_RunFromExplorer

Tested on XP and CLASS maybe change on ther o.s. Pratically i'll open the Run Dialog Box and write the path of the software, so it start with explorer parent

Result:

test1.jpg

Edited by johnmcloud
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...