wraithdu Posted January 24, 2008 Posted January 24, 2008 (edited) So I'm working on a script that creates a drop target. Files/folders can be dragged onto the target to be erased. I've also created a context menu to perform additional commands, such as reloading the GUI to change the graphic used for the drop target, hiding the target, and now I'm adding a list of additional commands that can be performed. In one of the commands I need to prompt the user to select the drive he wants to act on. I'm trying to do this by creating a GUI in the Freespace() function with its own While loop. The loop is exited once the user presses the OK or Cancel button by changing the $dGUIwait variable. The problem is that I cannot get the OK and Cancel buttons to call the OKButton() or CancelButton() functions, so it's stuck in the loop. You'll see in the script that the main target GUI is also created in a function with the main While loop in the main script. I've done this because to reload the GUI with a new picture I basically have to destroy and recreate it. This seemed like the easiest way to accomplish this. The script runs in OnEventMode. I've tried placing the GUI creation code for the popup GUI in the main body of the script, but no luck. I'm sure I have to relocate some code, but I don't know what I have to put where to make this work. Help please expandcollapse popup#Region;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=..\..\App\AppInfo\appicon.ico #AutoIt3Wrapper_outfile=..\..\App\EraserDropTarget\EraserDropTarget.exe #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_Res_Comment=Drop files / folder onto the target to securely erase them. #AutoIt3Wrapper_Res_Description=EraserDropTarget #AutoIt3Wrapper_Res_Fileversion=1.3.0.1 #AutoIt3Wrapper_Res_LegalCopyright=by wraithdu #AutoIt3Wrapper_Res_Language=1033 #EndRegion;**** Directives created by AutoIt3Wrapper_GUI **** #NoTrayIcon Opt("GUIOnEventMode", 1) Opt("GUICloseOnESC", 0) Opt("TrayMenuMode", 1); no default menu Opt("TrayOnEventMode", 1); enable tray events #include <GUIConstants.au3> #include <GDIPlus.au3> Global Const $AC_SRC_ALPHA = 1 Global Const $ULW_ALPHA = 2 Global $nGUI, $hImage, $hotkey, $dGUI, $cDrive, $drivetowipe, $dGUIcancel, $dGUIwait ; tray icon ; -7 = primary mouse button down TraySetOnEvent(-7, "ShowGUI") _GDIPlus_Startup() LoadGUI() While 1 Sleep(1000) WEnd Func LoadGUI() ; read hotkey $hotkey = IniRead(@ScriptDir & "\config.ini", "eraser", "hotkey", "^+s") ; Load PNG file as GDI bitmap $pngSrc = @ScriptDir & "\" & IniRead(@ScriptDir & "\config.ini", "eraser", "image", "eraser.png") $hImage = _GDIPlus_ImageLoadFromFile($pngSrc) ; extract image width and height from PNG $wGUI = _GDIPlus_ImageGetWidth($hImage) $hGUI = _GDIPlus_ImageGetHeight($hImage) $aDesktop = WinGetPos("Program Manager") $xGUI = IniRead(@ScriptDir & "\config.ini", "eraser", "x", "0") If $xGUI > $aDesktop[2] - $wGUI Then $xGUI = $aDesktop[2] - $wGUI ElseIf $xGUI < 0 Then $xGUI = 0 EndIf $yGUI = IniRead(@ScriptDir & "\config.ini", "eraser", "y", "0") If $yGUI > $aDesktop[3] - $hGUI Then $yGUI = $aDesktop[3] - $hGUI ElseIf $yGUI < 0 Then $yGUI = 0 EndIf ; Create GUI $nGUI = GUICreate("EDT", $wGUI, $hGUI, $xGUI, $yGUI, $WS_POPUP, BitOR($WS_EX_ACCEPTFILES,$WS_EX_TOPMOST,$WS_EX_LAYERED,$WS_EX_TOOLWINDOW)) GUISetCursor(0) ; set png background SetBitMap($nGUI, $hImage, 0) ; register messages ;~ Const $WM_DROPFILES = 0x233 GUIRegisterMsg(0x233, "FileDrop") ; context menu $ClickMenu = GUICtrlCreateContextMenu() $OptionsMenu = GUICtrlCreateMenuItem("Config / Help", $ClickMenu) $ReloadMenu = GUICtrlCreateMenuItem("Reload", $ClickMenu) $TasksMenu = GUICtrlCreateMenu("Tasks", $ClickMenu) $Recycle = GUICtrlCreateMenuItem("Erase Recycle Bin", $TasksMenu) $Freespace = GUICtrlCreateMenuItem("Erase Free Space", $TasksMenu) GUICtrlCreateMenuItem("", $ClickMenu) $HideMenu = GUICtrlCreateMenuItem("Hide", $ClickMenu) $ExitMenu = GUICtrlCreateMenuItem("Exit", $ClickMenu) ; GUI Events GUISetOnEvent($GUI_EVENT_CLOSE, "GUIClose") GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "MoveGUI") ; control events GUICtrlSetOnEvent($OptionsMenu, "OptionsMenu") GUICtrlSetOnEvent($ReloadMenu, "ReloadGUI") GUICtrlSetOnEvent($Recycle, "Recycle") GUICtrlSetOnEvent($Freespace, "Freespace") GUICtrlSetOnEvent($HideMenu, "HideGUI") GUICtrlSetOnEvent($ExitMenu, "GUIClose") ; show GUI GUISetState(@SW_SHOW, $nGUI) ;fade in png background For $i = 0 to 255 step 10 SetBitMap($nGUI, $hImage, $i) Next _ReduceMemory() EndFunc ; Reduce memory usage ; Author wOuter ( mostly ) Func _ReduceMemory($i_PID = -1) If $i_PID <> -1 Then Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) Else Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) EndIf Return $ai_Return[0] EndFunc;==> _ReduceMemory() Func MoveGUI() ; 0xA0 = LSHIFT ; 0x01 = LMOUSE If _WinAPI_GetAsyncKeyState(0x01) And _WinAPI_GetAsyncKeyState(0xA0) Then $aPos = WinGetPos("EDT") $mPos = MouseGetPos() $xOfst = $mPos[0] - $aPos[0] $yOfst = $mPos[1] - $aPos[1] While _WinAPI_GetAsyncKeyState(0x01) And _WinAPI_GetAsyncKeyState(0xA0) Sleep(10) $mPos = MouseGetPos() WinMove("EDT", "", $mPos[0] - $xOfst, $mPos[1] - $yOfst) WEnd EndIf EndFunc Func ReloadGUI() $aPos = WinGetPos($nGUI) IniWrite(@ScriptDir & "\config.ini", "eraser", "x", $aPos[0]) IniWrite(@ScriptDir & "\config.ini", "eraser", "y", $aPos[1]) ;fade out png background For $i = 255 to 0 step -10 SetBitMap($nGUI, $hImage, $i) Next ; Release resources GUIDelete($nGUI) _WinAPI_DeleteObject($hImage) LoadGUI() EndFunc Func HideGUI() ; 2 = visible If BitAND(WinGetState("EDT"),2) Then; window is visible ;fade out png background For $i = 255 to 0 step -10 SetBitMap($nGUI, $hImage, $i) Next ; hide GUI WinSetState("EDT", "", @SW_HIDE) ; show tray icon TraySetState(1) TraySetToolTip("Show EraserDropTarget" & @CRLF & "HotKey = " & $hotkey) ; set hotkey HotKeySet($hotkey, "ShowGUI") EndIf EndFunc Func ShowGUI() If Not BitAND(WinGetState("EDT"),2) Then; window is not visible ; release hotkey HotKeySet($hotkey) ; hide tray icon TraySetState(2) ; show gui WinSetState("EDT", "", @SW_SHOW) ;fade in png background For $i = 0 to 255 step 10 SetBitMap($nGUI, $hImage, $i) Next EndIf EndFunc Func OptionsMenu() ShellExecute(@ScriptDir & "\config.ini", "", @ScriptDir, "open") EndFunc Func Recycle() $key = ""; empty variable ; read ini file $method = IniRead(@ScriptDir & "\config.ini", "eraser", "method", "-method Random 1") ; check reg key RegRead("HKCU\Software\Heidi Computers Ltd", "") If @error = 1 Then $key = "delete"; if key does not exist, delete it later ; run, eraser warns on its own except for 0 byte files/folders RunWait('"' & @ScriptDir & '\Eraserl.exe" -recycled ' & $method & ' -resultsonerror -queue') ; clean reg key If $key = "delete" Then RegDelete("HKCU\Software\Heidi Computers Ltd") EndFunc Func Freespace() ; empty variables $drives = "" $key = "" ; get fixed and removable drives, convert to a string $drivesfix = DriveGetDrive("fixed") $drivesrem = DriveGetDrive("removable") For $i = 1 To $drivesfix[0] $drives = $drives & "|" & $drivesfix[$i] Next For $i = 1 To $drivesrem[0] $drives = $drives & "|" & $drivesrem[$i] Next ; create GUI $dGUI = GUICreate("Choose drive...", 139, 74, 398, 271, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_WINDOWEDGE)) $cDrive = GUICtrlCreateCombo("", 56, 8, 73, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL)) $bOK = GUICtrlCreateButton("OK", 16, 40, 49, 25, 0) $bCancel = GUICtrlCreateButton("Cancel", 72, 40, 49, 25, 0) $lDrives = GUICtrlCreateLabel("Drives:", 8, 8, 37, 17) ; control events GUICtrlSetOnEvent($bOK, "OKButton") GUICtrlSetOnEvent($bCancel, "CancelButton") ; set combo data GUICtrlSetData($cDrive, $drives, $drivesfix[1]) ; show GUI GUISetState(@SW_SHOW, $dGUI) ; wait $dGUIwait = 1 $dGUIcancel = 0 While $dGUIwait = 1 Sleep(1000) WEnd If $dGUIcancel = 1 Then Return; if cancel, exit function ; read ini file $method = IniRead(@ScriptDir & "\config.ini", "eraser", "method", "-method Random 1") ; check reg key RegRead("HKCU\Software\Heidi Computers Ltd", "") If @error = 1 Then $key = "delete"; if key does not exist, delete it later ; run ;RunWait('"' & @ScriptDir & '\Eraserl.exe" -disk ' & $drivetowipe & ' ' & $method & ' -resultsonerror -queue') MsgBox(0, "", $drivetowipe & @CRLF & $method) ; clean reg key If $key = "delete" Then RegDelete("HKCU\Software\Heidi Computers Ltd") EndFunc Func OKButton() MsgBox(0, "", "OKButton") GUISetState(@SW_HIDE, $dGUI); hide GUI $drivetowipe = GUICtrlRead($cDrive); read drive selection GUIDelete($dGUI); delete GUI $dGUIwait = 0; exit wait loop EndFunc Func CancelButton() MsgBox(0, "", "CancelButton") GUIDelete($dGUI) $dGUIcancel = 1; set cancel variable $dGUIwait = 0; exit wait loop EndFunc Func GUIClose() $aPos = WinGetPos($nGUI) IniWrite(@ScriptDir & "\config.ini", "eraser", "x", $aPos[0]) IniWrite(@ScriptDir & "\config.ini", "eraser", "y", $aPos[1]) GUIRegisterMsg(0x233, "") ;fade out png background For $i = 255 to 0 step -10 SetBitMap($nGUI, $hImage, $i) Next ; Release resources _WinAPI_DeleteObject($hImage) _GDIPlus_Shutdown() Exit EndFunc Func FileDrop($hWnd, $Msg, $wParam, $lParam) Local $tDrop, $aRet, $iCount, $key $key = ""; empty variable ;read ini file If 1 = IniRead(@ScriptDir & "\config.ini", "eraser", "warn", "1") Then If 7 = MsgBox(4 + 32 + 262144, "Eraser", "Wipe all selected file(s) and folder(s)?") Then Return EndIf $method = IniRead(@ScriptDir & "\config.ini", "eraser", "method", "-method Random 1") RegRead("HKCU\Software\Heidi Computers Ltd", "") If @error = 1 Then $key = "delete"; if key does not exist, delete it later ;string buffer for file path $tDrop = DllStructCreate("char[260]") ;get file count $aRet = DllCall("shell32.dll", "int", "DragQueryFile", _ "hwnd", $wParam, _ "uint", -1, _ "ptr", DllStructGetPtr($tDrop), _ "int", DllStructGetSize($tDrop) _ ) $iCount = $aRet[0] ;get file paths For $i = 0 To $iCount-1 $aRet = DllCall("shell32.dll", "int", "DragQueryFile", _ "hwnd", $wParam, _ "uint", $i, _ "ptr", DllStructGetPtr($tDrop), _ "int", DllStructGetSize($tDrop) _ ) $objtowipe = (DllStructGetData($tDrop, 1)) ;Eraser code If StringInStr(FileGetAttrib($objtowipe), "D") Then Run('"' & @ScriptDir & '\Eraserl.exe" -folder "' & $objtowipe & '" -subfolders ' & $method & ' -resultsonerror -queue') Else Run('"' & @ScriptDir & '\Eraserl.exe" -file "' & $objtowipe & '" ' & $method & ' -resultsonerror -queue') EndIf Next ;finalize DllCall("shell32.dll", "int", "DragFinish", "hwnd", $wParam) ProcessWaitClose("Eraserl.exe") Sleep(1000) If $key = "delete" Then RegDelete("HKCU\Software\Heidi Computers Ltd") Return EndFunc ; ==================================================================================================== =========================== ; SetBitMap ; ==================================================================================================== =========================== Func SetBitmap($hGUI, $hImage, $iOpacity) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize ) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth ($hImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha" , $iOpacity ) DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC (0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC ($hMemDC) EndFunc Edited January 24, 2008 by wraithdu
wraithdu Posted January 24, 2008 Author Posted January 24, 2008 So I got it to work by moving some stuff around. Basically I eliminated the While loop in the Freespace() function, and just used that to create the GUI. The button functions take care of the rest. I'd still like to know why the code above doesn't work though.
Swift Posted January 24, 2008 Posted January 24, 2008 (edited) Thats a nice script for a AutoIt noobie...it works when i tested it...whats wrong with it on your part? Wierd...now it doesnt do anything...ive noticed something...why isnt there a GUICreate()? haha Edited January 24, 2008 by Swift
wraithdu Posted January 25, 2008 Author Posted January 25, 2008 (edited) It should run as long as you include a PNG graphic named 'eraser.png' in the script directory. The problem for me was when you right-click the target, choose 'Tasks -> Erase Free Space'. The popup GUI appears, but the buttons refuse to call the assigned functions. Then it's stuck in the While loop. To get around it I removed the While loop, only created the GUI in the Freespace() function, and ran the actual erasing/hide GUI/delete GUI code from the button functions. Oh, and the GUICreate() is in the LoadGUI() function, and the Freespace() function. Add that PNG, run it and see if it gets stuck in that loop. I'm interested to know how to make it work, just as a challenge Thanks for the compliment! Edited January 25, 2008 by wraithdu
smashly Posted January 25, 2008 Posted January 25, 2008 Hi, Apart from your initial problem .. You might want to check that $drivesrem = DriveGetDrive("removable") is actually returning an array. On my laptop I have no removable drives so your script crashes out when you try to For $i = 1 To $drivesrem[0] The initial problem is the while loop in the Freespace() functionWhile $dGUIwait = 1 Sleep(1000) WEndoÝ÷ Øw«{ljh¥uÈZ¢Ø^~·²yû§rب«¶ò¢êìr¸©µ«¢+ÙÕ¹ÉÍÁ ¤(ìµÁÑäÙÉ¥±Ì(ÀÌØíÉ¥ÙÌôÅÕ½ÐìÅÕ½Ðì(ÀÌØíäôÅÕ½ÐìÅÕ½Ðì(ìÐ¥á¹Éµ½Ù±É¥Ṵ̀½¹ÙÉÐѼÍÑÉ¥¹(ÀÌØíÉ¥ÙÍ¥àôÉ¥ÙÑÉ¥Ù ÅÕ½Ðí¥áÅÕ½Ðì¤(ÀÌØíÉ¥ÙÍÉ´ôÉ¥ÙÑÉ¥Ù ÅÕ½Ðíɵ½Ù±ÅÕ½Ðì¤(½ÈÀÌØí¤ôÄQ¼ÀÌØíÉ¥ÙÍ¥álÁt(ÀÌØíÉ¥ÙÌôÀÌØíÉ¥Ù̵ÀìÅÕ½ÐíðÅÕ½ÐìµÀìÀÌØíÉ¥ÙÍ¥álÀÌØí¥t(9áÐ(%%%ÍÉÉä ÀÌØíÉ¥ÙÍÉ´¤Q¡¸ì ¡¬Ñ¼Í¥¥ÐÌäí̸ÉÉä(½ÈÀÌØí¤ôÄQ¼ÀÌØíÉ¥ÙÍɵlÁt(ÀÌØíÉ¥ÙÌôÀÌØíÉ¥Ù̵ÀìÅÕ½ÐíðÅÕ½ÐìµÀìÀÌØíÉ¥ÙÍɵlÀÌØí¥t(9áÐ(¹%(ìÉÑU$(ÀÌØíU$ôU% ÉÑ ÅÕ½Ðí ¡½½ÍÉ¥Ù¸¸¸ÅÕ½Ðì°ÄÌä°ÜаÌäà°ÈÜݴİ ¥Ñ=H ÀÌØí]M}a}Q==1]%9=°ÀÌØí]M}a}]%9=]¤¤($ÀÌØíÉ¥ÙôU% Ñɱ ÉÑ ½µ¼ ÅÕ½ÐìÅÕ½Ðì°Ôذà°Ṵ̈ÈÔ° ¥Ñ=H ÀÌØí M}I=A=]91%MP°ÀÌØí M}UQ=!M I=10¤¤(ÀÌØí=,ôU% Ñɱ ÉÑ ÕÑѽ¸ ÅÕ½Ðí=,ÅÕ½Ðì°ÄذÐÀ°Ðä°ÈÔ°À¤(ÀÌØí ¹°ôU% Ñɱ ÉÑ ÕÑѽ¸ ÅÕ½Ðí ¹°ÅÕ½Ðì°ÜȰÐÀ°Ðä°ÈÔ°À¤(ÀÌØí±É¥ÙÌôU% Ñɱ ÉÑ1° ÅÕ½ÐíÉ¥ÙÌèÅÕ½Ðì°à°à°ÌܰÄܤ((ì½¹Ñɽ°Ù¹ÑÌ(U%MÑ=¹Ù¹Ð ÀÌØíU%}Y9Q} 1=M°ÅÕ½Ðí ¹± ÕÑѽ¸ÅÕ½Ðì°ÀÌØíU$¤ìÑ¡¥Ìͼդá¥Ð±±Ì¹°(U% ÑɱMÑ=¹Ù¹Ð ÀÌØí=,°ÅÕ½Ðí=- ÕÑѽ¸ÅÕ½Ðì¤(U% ÑɱMÑ=¹Ù¹Ð ÀÌØí ¹°°ÅÕ½Ðí ¹± ÕÑѽ¸ÅÕ½Ðì¤((ìÍнµ¼Ñ(U% ÑɱMÑÑ ÀÌØíÉ¥Ù°ÀÌØíÉ¥Ṵ̀ÀÌØíÉ¥ÙÍ¥álÅt¤((ìÍ¡½ÜU$(U%MÑMÑÑ¡M]}M!=°ÀÌØíU$¤)¹Õ¹()Õ¹=- ÕÑѽ¸ ¤(5Í ½à À°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½Ðí=- ÕÑѽ¸ÅÕ½Ðì¤(U%MÑMÑÑ¡M]}!%°ÀÌØíU$¤ì¡¥U$(ÀÌØíÉ¥ÙѽݥÁôU% ÑɱI ÀÌØíÉ¥Ù¤ìÉÉ¥Ùͱѥ½¸(U%±Ñ ÀÌØíU$¤ì±ÑU$(ÉÍ5Ñ¡½ ¤í±°Ñ¡É͵ѡ½Õ¹Ñ¥½¸)¹Õ¹()Õ¹ÉÍ5Ñ¡½ ¤í5½ÙÑ¡¥Ì¥¹Ñ¼¥ÐÌäí̽ݸչѥ½¸(ìÉ¥¹¤¥±(ÀÌØíµÑ¡½ô%¹¥I¡MÉ¥ÁѥȵÀìÅÕ½ÐìÀäÈí½¹¥¹¥¹¤ÅÕ½Ðì°ÅÕ½ÐíÉÍÈÅÕ½Ðì°ÅÕ½ÐíµÑ¡½ÅÕ½Ðì°ÅÕ½Ð쵵ѡ½I¹½´ÄÅÕ½Ðì¤(졬Éä(II ÅÕ½Ðí!- TÀäÈíM½ÑÝÉÀäÈí!¥¤ ½µÁÕÑÉÌ1ÑÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì¤(%ÉɽÈôÄQ¡¸ÀÌØíäôÅÕ½Ðí±ÑÅÕ½Ðìì¥ä½Ì¹½Ðá¥Íа±Ñ¥Ð±ÑÈ(ìÉÕ¸(íIÕ¹]¥Ð ÌäìÅÕ½ÐìÌäìµÀìMÉ¥ÁѥȵÀìÌäìÀäÈíÉÍɰ¹áÅÕ½Ð쵥ͬÌäìµÀìÀÌØíÉ¥ÙѽݥÁµÀìÌäìÌäìµÀìÀÌØíµÑ¡½µÀìÌäìµÉÍÕ±Ñͽ¹ÉɽȵÅÕÕÌäì¤(5Í ½à À°ÅÕ½ÐìÅÕ½Ðì°ÀÌØíÉ¥ÙѽݥÁµÀì I1µÀìÀÌØíµÑ¡½¤(챸Éä(%ÀÌØíäôÅÕ½Ðí±ÑÅÕ½ÐìQ¡¸I±Ñ ÅÕ½Ðí!- TÀäÈíM½ÑÝÉÀäÈí!¥¤ ½µÁÕÑÉÌ1ÑÅÕ½Ðì¤$)¹Õ¹()Õ¹ ¹± ÕÑѽ¸ ¤(5Í ½à À°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½Ðí ¹± ÕÑѽ¸ÅÕ½Ðì¤(U%±Ñ ÀÌØíU$¤)¹Õ¹ Cheers
wraithdu Posted January 25, 2008 Author Posted January 25, 2008 Thanks for the tips. I'll add the array check for sure. Your solution is actually what I did already. I had an epiphany after letting it rest for a while and fixed it up. I'm still not exactly sure *why* it doesn't work, but at least it's working
pintas Posted August 15, 2008 Posted August 15, 2008 (edited) Hi, I've been trying to use eraserl with autoit but i can't. My idea was to copy eraserl.exe and eraser.dll to %AppData% and delete a folder called experiment in %AppData%, and after that to delete the both eraserl.exe and eraser.dll. I've been using the following: FileCopy(@ScriptDir & "\Data\Eraserl.exe", @AppDataDir, 1) FileCopy(@ScriptDir & "\Data\Eraser.dll", @AppDataDir, 1) RunWait(@AppDataDir & '\Eraserl.exe -folder "%AppData%\experiment" -subfolders -method DoD_E -results -resultsonerror') If FileExists(@AppDataDir & "\Eraserl.exe") Then FileDelete(@AppDataDir & "\Eraserl.exe") If FileExists(@AppDataDir & "\Eraser.dll") Then FileDelete(@AppDataDir & "\Eraser.dll") But i'm getting a "There's nothing to erase." error. What am i doing wrong? Thanks. Edited August 15, 2008 by pintas
wraithdu Posted August 16, 2008 Author Posted August 16, 2008 This is a really weird place to post this question, but the problem is that AutoIt does not automatically expand environment variables, ie %AppData%. You can fix this a few ways. 1. Use Opt("ExpandEnvStrings", 1) 2. Change your strings to use EnvGet("AppData") 3. Use the _WinAPI_ExpandEnvironmentStrings() function
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now