Not sure how to phrase this problem.
I'm making a desktop/folder cleanup script. It works fine when the GUI runs once, but when it runs again it says I can't use the same variables twice. Not sure why I'm getting this problem.
use windows + space to simulate it being called again
Code:
;
; AutoHotkey Version: 1.x
; Language: English
; Platform: Win9x/NT
; Author: A.N.Other <myemail@nowhere.com>
;
; Script Function:
; Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;
#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.
EnvGet, USERP, USERPROFILE
#SingleInstance,Force
bagin:
Gui, Add, Radio,vrdel checked gwhatdo x36 y167 w100 h30,&Delete them
Gui, Add, Radio,vrmove gwhatdo x36 y197 w100 h30,&Move them
Gui, Add, Edit,gextns vext x36 y47 w220 h20 -VScroll +Lowercase -VScroll,torrent
gui,submit,nohide
Gui, Add, Edit,vMPath disabled x36 y267 w220 h20 -VScroll, %USERP%\Desktop\%ext%
Gui, Add, Text, x36 y27 w220 h20 , What extension would you like to deal with?
Gui, Add, Text, x36 y137 w220 h20 , What would you like to do with the files?
Gui, Add, Text, x36 y87 w220 h20 , What folder do you want to work in?
Gui, Add, Edit, vwp x36 y107 w220 h20 , %USERP%\Desktop\
Gui, Add, Text, x36 y237 w220 h20 , Where do you want to move them?
Gui, Add, Button, x156 y307 w100 h30 ,Cancel
Gui, Add, Button,default x36 y307 w100 h30 ,OK
GuiControl, Focus,ext
; Generated using SmartGUI Creator 4.0
Gui, Show, x252 y98 h367 w296, New GUI Window
Return
extns:
gui,submit,nohide
Guicontrol,,MPath,%USERP%\Desktop\%ext%\;auto edits the folder as you type the extension
return
whatdo:
GuiControlGet, rmove
if rmove ; This box is checked.
{
GuiControl, Enable, MPath;enables the move path if you select to move the files
gui,submit,nohide
}
else
GuiControl, Disable, MPath;disables the move path if you select to delete the files
return
;Made to detect the extension on drop
GuiDropFiles:
Splitpath,A_GuiEvent,,,ext2
Guicontrol,,ext,%ext2%
Guicontrol,,MPath,%USERP%\Desktop\%ext2%
return
ButtonOK:
gui,submit
stringright,slash,wp,1
if (slash="\") ;checks if the path has a ending slash and adds it if its missing
{
}
else wp=%wp%\
;small part to move all pics into one folder
If (ext="pics")
{
loop,4
{
if (A_Index=1)
{
ext=jpg
}
if (A_Index=2)
{
ext=gif
}
if (A_Index=3)
{
ext=png
}
if (A_Index=4)
{
ext=bmp
}
gosub,actualloop
}
return
}
actualloop:
loop,%wp%*.%ext%
{
if (rdel=1)
{
FileDelete,%A_LoopFileFullPath%;deletes the files in a loop
}
else if (rmove=1)
{
IfNotExist,%Mpath%
{
FileCreateDir,%Mpath%;moves the files in a loop
}
FileMove,%A_LoopFileFullPath%,%Mpath%
}
}
return
;********************************************************
;on kill
;********************************************************
ButtonCancel:
GuiClose:
GuiEscape:
Gui, destroy
return
#space::
gosub,bagin