Цитата BonD 007:
Когда я писал "в активном окне", я имел ввиду чтобы, к примеру, при нажатии тех же Ctrl + Shift + n создавалась папка в любом окне Explorer'а, которое в данный момент активно (или на рабочем столе) независимо от того, где лежит скрипт. »
|
Рабочий стол не предусматривался, тогда так:
Код:

#NoTrayIcon
Opt("WinWaitDelay", 1)
Global $sFileNameFormat = "New_%i"
HotKeySet("^+n", "_CreateFolder_Proc") ;Ctrl + Shift + n
HotKeySet("^+w", "_Quit") ;Ctrl + Shift + w
While 1
Sleep(1000)
WEnd
Func _CreateFolder_Proc()
Local $sExplorer_Title = "[CLASS:CabinetWClass]"
Local $sPath
If Not WinActive($sExplorer_Title) Then $sExplorer_Title = "[CLASS:ExploreWClass]"
If Not WinActive($sExplorer_Title) Then $sExplorer_Title = "[CLASS:Progman]"
If Not WinActive($sExplorer_Title) Then Return
Switch $sExplorer_Title
Case "[CLASS:CabinetWClass]", "[CLASS:ExploreWClass]"
Local $sWin_Title = WinGetTitle($sExplorer_Title)
Local $sWin_Text = WinGetText($sExplorer_Title)
$sPath = StringRegExpReplace($sWin_Text, "(?s).*(\r\n|)(\w+:\\.*" & $sWin_Title & ")(\r\n|.*)", "\2")
Case "[CLASS:Progman]"
$sPath = @DesktopDir
EndSwitch
If Not StringInStr(FileGetAttrib($sPath), "D") Then $sPath = ControlGetText($sExplorer_Title, "", "Edit1")
If Not StringInStr(FileGetAttrib($sPath), "D") Then Return
Local $iFolder_Num = 1
Local $sNewFolderName = StringFormat($sFileNameFormat, $iFolder_Num)
While StringInStr(FileGetAttrib($sPath & "\" & $sNewFolderName), "D")
$iFolder_Num += 1
$sNewFolderName = StringFormat($sFileNameFormat, $iFolder_Num)
WEnd
DirCreate($sPath & "\" & $sNewFolderName)
EndFunc ;==>_CreateFolder_Proc
Func _Quit()
Exit
EndFunc ;==>_Quit