Code:
#f::msgbox, % ExplorerCheck()
#m::CHDIR("A_MyDocuments", "1")
#p::CHDIR("ProgramFiles","0")
#w::CHDIR("A_WinDir")
CHDIR(PathName = "A_MyDocuments", Option = 0)
{
static TimeCheck1, TimeCheck2, TimeCheck3, TimeCheck4
EditDelay = 256 ; adjust it to avoid problem(s)
TimeCheck3 := TimeCheck2, TimeCheck2 := TimeCheck1, TimeCheck1 := A_TickCount - TimeCheck4, TimeCheck4 := A_TickCount
If TimeCheck3
If ((TimeCheck1 + TimeCheck2 + TimeCheck3) / 3 < 1256)
{
Msgbox, 48, CHDIR Utility, Key press average too fast`n(Action stops to avoid Internet Explorer loading problem)
return
}
IfNotExist, %PathName%
{
IfNotInString, PathName, :\o
_cd_p_n_c := %PathName%
IfNotExist, %_cd_p_n_c%
{
msgbox, 48, CHDIR Utility, %PathName% could not be used atm
return
}
Else
PathName := _cd_p_n_c
}
WinGet, WindowCheck, List
Loop, %WindowCheck%
If WindowCheck%A_Index%
{
WindowCheck0 := WindowCheck%A_Index%
WinGet, WindowCheck, ProcessName, ahk_id %WindowCheck0%
If WindowCheck = explorer.exe
{
WinGet, WindowCheck, Style, ahk_id %WindowCheck0%
If WindowCheck = 0x14CF0000
{
ControlSetText, Edit1, %PathName%, ahk_id %WindowCheck0%
TimeCheck := A_TickCount
Loop
{
ControlGetText, ControlText, Edit1, ahk_id %WindowCheck0%
If ControlText = %PathName%
break
If (A_TickCount - TimeCheck > 3000)
break
}
Sleep, %EditDelay%
ControlSend, Edit1, {Enter}, ahk_id %WindowCheck0%
return
}
}
}
If Option <> 0
Run, explorer.exe /e %PathName%, %A_WinDir%
}
ExplorerCheck(WindowName = "List", Option = 0)
{
global _func_e_c_s, _func_e_c_f, _func_e_c_p
Loop, Parse, Option
if A_LoopField is number
_func_e_c_n0 := _func_e_c_n0 A_LoopField
Else
break
_func_e_c_n := 0
If WindowName <> List
WinGet, WindowCheck, List, %WindowName%
Else if WindowName = List
WinGet, WindowCheck, List
Loop, %WindowCheck%
If WindowCheck%A_Index%
{
WindowCheck0 := WindowCheck%A_Index%
WinGet, WindowCheck, ProcessName, ahk_id %WindowCheck0%
If WindowCheck = explorer.exe
{
WinGet, WindowCheck, Style, ahk_id %WindowCheck0%
If WindowCheck = 0x14CF0000
{
_func_e_c_n += 1
If (_func_e_c_n - _func_e_c_n0 = 1)
Goto, _ExplorerCheck_g_info_file_path
}
}
}
return
_ExplorerCheck_g_info_file_path:
ControlGet, _func_e_c_s, List, Selected Col1, SysListView321, ahk_id %WindowCheck0%
ControlGet, _func_e_c_f, List, Focused Col1, SysListView321, ahk_id %WindowCheck0%
ControlGetText, _func_e_c_p, Edit1, ahk_id %WindowCheck0%
If _func_e_c_p
_func_e_c_msgbox := "Folder: " _func_e_c_p
Else
_func_e_c_msgbox =
If _func_e_c_f
_func_e_c_msgbox .= "`nFocus: " _func_e_c_f
If _func_e_c_s
_func_e_c_msgbox .= "`n<Selected Items>`n" _func_e_c_s
if Option is not digit
Msgbox, 64, File Check, %_func_e_c_msgbox%
return _func_e_c_msgbox
}