Имя пользователя:
Пароль:  
Помощь | Регистрация | Забыли пароль?  

Показать сообщение отдельно

Аватара для Creat0R

Must AutoIt


Сообщения: 3054
Благодарности: 1009

Профиль | Сайт | Отправить PM | Цитировать


Цитата 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

-------
“Сделай так просто, как возможно, но не проще этого.”... “Ты никогда не решишь проблему, если будешь думать так же, как те, кто её создал.”

Альберт Эйнштейн

P.S «Не оказываю техподдержку через ПМ/ICQ, и по email - для этого есть форум. ©»

http://creator-lab.ucoz.ru/Images/Icons/autoit_icon.png Русское сообщество AutoIt | http://creator-lab.ucoz.ru/Images/Ic...eator_icon.png CreatoR's Lab | http://creator-lab.ucoz.ru/Images/Icons/oac_icon.png Opera AC Community


Последний раз редактировалось Creat0R, 03-01-2009 в 19:52. Причина: Поправки в коде


Отправлено: 14:31, 03-01-2009 | #1390