topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday April 18, 2024, 2:14 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Open Folder Hack  (Read 3475 times)

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Open Folder Hack
« on: May 01, 2009, 01:12 AM »
I really really hate the SHBrowseForFolder() thing they give you in Windows. How about this for an OpenFolder Hack using the standard FileOpen Dialog?  Might seem different at first but any users who like hotkey gizmos might not mind Alt-RightClicking the Mouse as alternative to using that lame folder browser!!

ahk script that demonstrates folder selected by Alt Right Clicking the mouse


; use FiLeOpen Dialog instead of that stupid BrowseForFolder thing!

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
selectopen = 1
FileSelectFile,SelectedFolder,2,%A_MyDocuments%\*.*,Alt Right Mouse Click to select Folder,All Files(*.*)
selectopen = 0
If ErrorLevel
ExitApp

!RButton::
If %selectopen%
{
    Clipboard =
    Send ^c
    ClipWait,2
    SelectedFolder = %Clipboard%
    Send {Esc}
    MsgBox, 0, , Folder Selected is %Clipboard%
    ExitApp
}

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: Open Folder Hack
« Reply #1 on: May 01, 2009, 06:32 PM »
hmmmmmmm guess ahk has some restrictions about using a hotkey inside a function.  Just quickly looking through some user defined functions I see people using a line label like you do for gosub.. maybe that's why.  It would be nice to put this hack in a separate script in a very usable way.

So far I cleaned it up just a bit to use a variable for the Open Folder Dialog so that the same variable can be used by the hotkey to see if that window is active. After return from
FileSelectFile() the SelectedFolder variable should either contain the folder path or blank.  Note that ErrorLevel should be non-0 on success because the hotkey code sends {Esc} to close the dialog.

;set File Open Dialog to Prompt users how to select a folder
FolderPrompt = Alt Right Mouse Click to select Folder
FileSelectFile,DummyVar,2,%A_MyDocuments%\*.*,%FolderPrompt%,All Files(*.*)
If Not SelectedFolder
MsgBox, 0, , No Folder Selected
Else
MsgBox, 0, , Folder Selected is %SelectedFolder%
ExitApp

!RButton::
IfWinActive,%FolderPrompt%
{
    Clipboard =
    Send ^c
    ClipWait,2
    SelectedFolder = %Clipboard%
    Send {Esc}
}
Return
« Last Edit: May 01, 2009, 06:34 PM by MilesAhead »