Sign in to follow this  
Followers 0
Xichael

XP file rename without selecting extension

6 posts in this topic

Here are a few examples of this being done in AutoHotkey:

http://lifehacker.com/355580/mimic-vistas-file-rename-feature-in-xp

http://www.donationcoder.com/Software/Skrommel/TheEnd/TheEnd.ahk

Could someone here make this happen in AutoIt? I'm clueless in this regard.

Since I already have a multipurpose AutoIt script running, I'd rather have this function pasted in there, than have a whole other program running...

Thanks! :)

Share this post


Link to post
Share on other sites



Looking at this code (Oh my God this is a ridiculous language):

#IfWinActive ahk_class CabinetWClass 
~F2:: 
Gosub, AnalyzeRename 
return 
#IfWinActive ahk_class Progman 
~F2:: Gosub, AnalyzeRename 
return #IfWinActive

AnalyzeRename:
OldClipboard = %Clipboard%
sleep 100
Send, ^c
StringGetPos,ExtensionPos, Clipboard,.,R
if (ExtensionPos != -1)
{
Position := StrLen(Clipboard) - ExtensionPos
Send, +{Left %Position%}
}
Clipboard = %OldClipboard%
return

These are the functions you're going to want to use (pretty much in this order)

HotKeySet
ClipGet
Sleep
Send
StringInStr (be sure to set Occurrence to -1)
StringLeft
Send
ClipPut

Give it a try and post what you come up with.

Is there a reason why (like one of the commentors in that first link said) you don't use "Hide extensions for known file types." ?

Share this post


Link to post
Share on other sites

#include <file.au3>

$file = "C:\hello.txt"

$new_name = "test"

Local $szDrive, $szDir, $szFName, $szExt
Local $filepath = _PathSplit($file, $szDrive, $szDir, $szFName, $szExt)

ConsoleWrite($szDrive & $szDir & $new_name & $szExt & @CRLF)


[font="Impact"] I always thought dogs laid eggs, and I learned something today. [/font]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

hmm, one thing is that i leave the hide known extensions unchecked, i like to know all the files....

in some cases i have liked this extension being kept intact if possible, which i felt was nice to see in windows vista, but i thought we had it in autoit already.

this essentially involves

monitoring selection ,

then listing file name,

then use something like _pathsplit() described above

then change the selection with area less the extension

Edited by rajeshontheweb

Share this post


Link to post
Share on other sites

Here: http://www.autoitscript.com/forum/index.php?showtopic=88903&view=findpost&p=638874


*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Here: #638874

Thanks ProgAndy! It works like a charm.

Now, how to get it incorporated into my current always-on script? I've tried, and failed...

I'll post it here, if someone more adept than I would care to figure out how to get ProgAndy's script working inside of it:

#NoTrayIcon

HotKeySet("#x", "MonitorOff")
HotKeySet("#v", "ToggleWaveVolume")
HotKeySet("#h", "ToggleHiddenFiles")

Opt("WinTitleMatchMode", 4) ;For MonitorOff
Global $LastWaveVolume = 0 ;For ToggleWaveVolume
Global $LastFileState = 0  ;For ToggleHiddenFiles

While 1
    Sleep(50)
WEnd

;===============MonitorOff================
Func MonitorOff()
    Sleep(500)
    Local $HWND = WinGetHandle("classname=Progman")
    Local $WM_SYSCommand = 274
    Local $SC_MonitorPower = 61808
    DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND, "int", $WM_SYSCommand, "int", $SC_MonitorPower, "int", 2)
EndFunc

;=============ToggleWaveVolume===============
Func ToggleWaveVolume()
    If $LastWaveVolume = 0 Or $LastWaveVolume = 1 Then
        WaveVolumeDown()
        $LastWaveVolume = 2
    Else
        WaveVolumeUp()
        $LastWaveVolume = 1
    EndIf
EndFunc

Func WaveVolumeDown()
    Run("sndvol32.exe")
    WinWaitActive("Volume Control", "Volume Control")
    Send("{TAB}")
    Sleep(100)
    Send("{TAB}")
    Sleep(100)
    Send("{TAB}")
    Sleep(100)
    Send("{TAB}")
    Sleep(100)
    Send("{END}")
    Send("{UP 40}")
    Sleep(200)
    Send("!{F4}")
EndFunc

Func WaveVolumeUp()
    Run("sndvol32.exe")
    WinWaitActive("Volume Control", "Volume Control")
    Send("{TAB}")
    Sleep(100)
    Send("{TAB}")
    Sleep(100)
    Send("{TAB}")
    Sleep(100)
    Send("{TAB}")
    Sleep(100)
    Send("{HOME}")
    Sleep(200)
    Send("!{F4}")
EndFunc

;==============ToggleHiddenFiles===============
Func ToggleHiddenFiles()
    If $LastFileState = 0 Or $LastFileState = 1 Then
        ShowFiles()
        $LastFileState = 2
    Else
        HideFiles()
        $LastFileState = 1
    EndIf
EndFunc

Func ShowFiles()
    Run("control folders")
    WinWaitActive("Folder Options")
    Send("^{TAB}")
    Sleep(300)
    Send("{TAB}")
    Send("{DOWN 10}")
    Send("{SPACE}")
    Send("{DOWN 2}")
    Send("{SPACE}")
    WinWaitActive("Warning")
    Send("{LEFT}")
    Send("{ENTER}")
    WinWaitActive("Folder Options")
    Send("{TAB 2}")
    Send("{ENTER}")
EndFunc

Func HideFiles()
    Run("control folders")
    WinWaitActive("Folder Options")
    Send("^{TAB}")
    Sleep(300)
    Send("{TAB}")
    Send("{DOWN 9}")
    Send("{SPACE}")
    Send("{DOWN 3}")
    Send("{SPACE}")
    Send("{TAB 2}")
    Send("{ENTER}")
EndFunc

***EDIT***

I just noticed that ProgAndy's script prevents explorer windows from being closed via a double-click on the icon in the top left corner (my preferred way of closing windows)...

I'll try some of the other scripts in that thread, unless someone can come up with a fix for ProgAndy's script.

Edited by Xichael

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0