Visual studio Visual Studio环境变量脚本

Visual studio Visual Studio环境变量脚本,visual-studio,autohotkey,explorer,Visual Studio,Autohotkey,Explorer,我想要测试和反馈,我希望这是这个mods的正确位置,请根据需要移动/删除 任何更改环境变量的人都经常知道VisualStudio不会自动提取它们 我发现退出并重新启动explorer.exe的所有实例会使Visual Studio在不重新启动的情况下获取最新的环境变量集 不幸的是,这意味着你失去了所有打开的窗口 我已经写了一个AutoHotKey www.AutoHotKey.com脚本来解决这个问题 ; Array must be initialised Full_Path := Object

我想要测试和反馈,我希望这是这个mods的正确位置,请根据需要移动/删除

任何更改环境变量的人都经常知道VisualStudio不会自动提取它们

我发现退出并重新启动explorer.exe的所有实例会使Visual Studio在不重新启动的情况下获取最新的环境变量集

不幸的是,这意味着你失去了所有打开的窗口

我已经写了一个AutoHotKey www.AutoHotKey.com脚本来解决这个问题

; Array must be initialised
Full_Path := Object()

; First Array dimension must be setup
Full_Path[j] := A_LoopField

; Generate a list of HWND's for explorer windows
WinGet, id, list, ahk_class CabinetWClass

; iterate over all HWND's filling in our Full_Path array
Loop, %id%
{
    ; store hwnd in this_id for current loop
    this_id := id%A_Index%

    ; Get the window information for this_id
    WinGetText, pathToStore, ahk_id %this_id%

    ; strips the address out of the text storing in ActiveAddress
    StringSplit, ActiveAddress, pathToStore, `n

    ; Turn's Path Into Variable
    pathToStore = %ActiveAddress1%

    ; Remove's The Beginning "Address:" Phrase
    pathToStore := RegExReplace(pathToStore, "^Address: ", "")

    ; Remove's Carriage Returns Incase it Exist in pathToStore
    StringReplace, pathToStore, pathToStore, `r, , all

    ; Store the result in the Full_Path array
    ifExist, %pathToStore%
        Full_Path%A_Index% := pathToStore
}

; We can now kill all instances of explorer.exe at command prompt
Loop, %id%
{
    ; Store hwnd in id array
    this_id := id%A_Index%

    ; get process id to kill from stored hwnd
    WinGet, pidVal, PID, ahk_id %this_id%

    ; kill the explorer process
    Run, taskkill /f /pid %pidVal%
}
; kill explorer shell
RunWait, taskkill /f /im explorer.exe

; restart explorer shell
Run, explorer

; open all windows we had open previously
Loop, %id%
{
    ; store actual path to open in local variable path To Open
    pathToOpen := Full_Path%A_Index%

    ; Run explorer providing the correct path to open
    Run, explorer %pathToOpen%
}
Return
如果您能提出任何建议或改进,我们将不胜感激。 希望它对其他人有用。

另一种方法:

; Get fullpath of all opened explorer windows:
If WinExist("ahk_class CabinetWClass") ; explorer
{
    list := ""
    ; https://autohotkey.com/boards/viewtopic.php?p=28751#p28751
    for window in ComObjCreate("Shell.Application").Windows
    {
       explorer_path := ""
       try explorer_path := window.Document.Folder.Self.Path 
       list .= explorer_path ? explorer_path "`n" : "" 
    }
    list := trim(list, "`n")
    ; MsgBox, "%list%"
}

; We can now restart the Explorer.exe Process:
RunWait, %comspec% /c taskkill /f /im explorer.exe ,,hide
Process, WaitClose, explorer.exe
Run, explorer.exe

; open all explorer windows we had open previously:
If (list != "")
{
    Process, wait, explorer.exe
    Loop, parse, list, `n
        Run %A_LoopField% 
}