TouchOdeath
Active Members-
Posts
114 -
Joined
-
Last visited
-
Days Won
1
TouchOdeath last won the day on January 12 2015
TouchOdeath had the most liked content!
Recent Profile Visitors
TouchOdeath's Achievements
-
ioa747 reacted to a post in a topic: IconDock - Mac style Icon toolbar
-
IconDock - Mac style Icon toolbar
TouchOdeath replied to eukalyptus's topic in AutoIt Example Scripts
Heres an updated link again: -
-
twothirtyone reacted to a post in a topic: IconDock - Mac style Icon toolbar
-
2021 version of _RegJump(). Func _RegJump($sKey) ;Function by: Yashied Local $Root, $Text = StringSplit($sKey, '\') If IsArray($Text) Then $Text = $Text[1] Else $Text = $sKey EndIf Switch $Text Case 'HKEY_CLASSES_ROOT', 'HKEY_CURRENT_USER', 'HKEY_LOCAL_MACHINE', 'HKEY_USERS', 'HKEY_CURRENT_CONFIG' $Root = $Text Case 'HKCR', 'HKCR64' $Root = 'HKEY_CLASSES_ROOT' Case 'HKCU', 'HKCU64' $Root = 'HKEY_CURRENT_USER' Case 'HKLM', 'HKLM64' $Root = 'HKEY_LOCAL_MACHINE' Case 'HKU', 'HKU64' $Root = 'HKEY_USERS' Case 'HKCC', 'HKCC64' $Root = 'HKEY_CURRENT_CONFIG' Case Else Return 0 EndSwitch Local $Class = '[CLASS:RegEdit_RegEdit]', $Delay = Opt('WinWaitDelay', 0) Local $Prev, $Result = 1 If WinExists($Class) Then WinClose($Class) If Not WinWaitClose($Class, '', 5) Then $Result = 0 EndIf EndIf If $Result Then $Prev = RegRead('HKCU64\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit', 'Lastkey') If @error Then $Prev = 0 EndIf If Not RegWrite('HKCU64\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit', 'Lastkey', 'REG_SZ', StringReplace($sKey, $Text, $Root, 1)) Then $Result = 0 Else If Not Run('regedit.exe') Then $Result = 0 If IsString($Prev) Then RegWrite('HKCU64\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit', 'Lastkey', 'REG_SZ', $Prev) EndIf EndIf EndIf EndIf Opt('WinWaitDelay', $Delay) Return $Result EndFunc ;==>_RegJump I know I'm necroposting... but I'm saving the next user who finds this using google.
-
Func rc4($sKey, $sStr) Local $s[256], $j = 0, $x, $res, $y, $i local $sKeyLen = StringLen($sKey) For $i = 0 To 255 $s[$i] = $i $j = Mod(($j + $s[$i] + Asc(StringMid($sKey, Mod($i, $sKeyLen)+1, 1))), 256) $x = $s[$i] $s[$i] = $s[$j] $s[$j] = $x Next $i = 0 $j = 0 local $sStrLen = StringLen($sStr)-1 For $y = 0 To $sStrLen $i = Mod(($i + 1), 256) $j = Mod(($j + $s[$i]), 256) $x = $s[$i] $s[$i] = $s[$j] $s[$j] = $x $res &= Chr(BitXOR(Asc(StringMid($sStr, $y+1, 1)), ($s[Mod(($s[$i] + $s[$j]), 256)]))) Next Return $res EndFunc The above is some small speed modifications, untested.
-
Theres a bug in this UDF that needs to be fixed. If your querying a field, and the field is blank, it gives you zero. Well what if the field is actually zero? Theres no way to tell if the field is actually blank, or actually zero. $data = DllStructGetData(DllStructCreate("char[" & $length & "]", $fieldPtr), 1) should be: $data = DllStructGetData(DllStructCreate("char[" & $length & "]", $fieldPtr), 1) if @error then $data = ""
-
_SelfDelete() - Delete the running executable.
TouchOdeath replied to guinness's topic in AutoIt Example Scripts
As far as bash is concerned, from my understanding (correct me if I'm wrong) you can get bash from an official windows update. But that update is for W10 only. As for windows 7/8 you can get win-bash but you have to have that installed first. So as far as what Jos said, I think if you mention anything bash related, then you would logically have to have either some bash install included in your script, or have a pointer to a bash install forum thread in order to get any use out of it. That goes for all version of windows. Also, theres no point in posting a bash script that DOS can do, or powershell can do because you can avoid an install process. Other than a 'heres how to get your foot in the door when programming in bash', which that is definitely helpful. As far as this thread is concerned, in this thread and another thread that is very similar to this thread here: I have sought an opinion. Does it suck, is it good? Does it not work for a different computer for some random stupid windows reason? Haven't gotten a single reply from anyone on either one of them, which to me is shocking because I am talking on point with the thread in both instances. At first I didn't know how to interpret that. Now I will take your silence as approval. There is still an opportunity for someone to post a working DOS _SelfDelete version that is similiar to what guiness has but doesn't suffer from leaving file(s) behind. I'm suprised thats not being talked about instead of this bickering. I'm sure within reason that guinesses _SelfDelete may suffer from explorer.exe keeping a handle on the file preventing you from deleting it at that moment, but I've messed with many different self made version of selfdelete that I'm not 100% sure on that. -
_SelfDelete() - Delete the running executable.
TouchOdeath replied to guinness's topic in AutoIt Example Scripts
I've decided to have some 'fun': ;global $powershellcmd = 'powershell while ((Get-Process '&StringReplace(@ScriptName,".exe","")&' -ErrorAction SilentlyContinue) -match '''& '.{1}' & ''') { Start-Sleep 5 } Remove-Item "' & @AutoItExe & '" -force' ;global $powershellcmd = 'powershell while ((Get-Process '&StringReplace(@ScriptName,".exe","")&' -ErrorAction SilentlyContinue) -match '''& '.{1}' & ''') { Start-Sleep 5 } && cmd.exe /c del "' & @AutoItExe & '"' ;global $powershellcmd = 'powershell while ((Get-Process '&StringReplace(@ScriptName,".exe","")&' -ErrorAction SilentlyContinue) -match '''& '.{1}' & ''') { Start-Sleep 5 } && start cmd.exe /c "ping 127.0.0.1 -n 6 > nul & del "' & @AutoItExe & '""' global $powershellcmd = 'powershell while ((Get-Process '&StringReplace(@ScriptName,".exe","")&' -ErrorAction SilentlyContinue) -match '''& '.{1}' & ''') { Start-Sleep 5 } && start cmd.exe /c "ping 127.0.0.1 -n 6 > nul & start cmd.exe /c del "' & @AutoItExe & '""' _SelfDelete() ClipPut($powershellcmd) while 1 Sleep(100000) WEnd func _SelfDelete() ShellExecute(@ComSpec, '/c ' & $powershellcmd, @TempDir, 'open', @SW_SHOW) EndFunc This is the cleanest I've ever seen this function. Leaves zero trace. I like the powershell loop because you can sleep for however long which means 0% cpu usage. It will delete, but the problem is somehow a handle is open or something. Somehow windows protects and queued for deletion. Each commented global will produce the same result, the first one is powershell only. The rest of them try to spawn a child cmd.exe which does the actual deletion in which I hoped the child process wouldn't have any relation to the original exe, but apparently it does. Hopefully someone can fill in the missing piece. And ya I use a global and its not 100% organized blah blah. Edit: Eureka!! _DeleteEXEonExit() While 1 Sleep(100000) WEnd Func _DeleteEXEonExit($sExefullpath = @AutoItExe) If @Compiled Then Local $sExename = _PathExtract($sExefullpath) Local $sPowershellcmd = 'powershell ' & _ 'while ((Get-Process "' & StringReplace(StringReplace($sExename, ".exe", ""), " ", "' '") & '" -ErrorAction SilentlyContinue) -match ''' & '.{1}' & ''') ' & _ '{ Start-Sleep 5 } ' & _ 'while ((Get-Process explorer -ErrorAction SilentlyContinue) -match ''' & '.{1}' & ''') ' & _ '{ Stop-Process -processname explorer -ErrorAction SilentlyContinue;} ' & _ 'Remove-Item "' & StringReplace($sExefullpath, " ", "' '") & '" -force; start-process ' & @WindowsDir & '\explorer.exe' ShellExecute(@ComSpec, '/c ' & $sPowershellcmd, @TempDir, 'open', @SW_HIDE) EndIf EndFunc ;==>_DeleteEXEonExit Func _PathExtract($sPath, $fold = 0);0=file 1=folder If StringRight($sPath, 1) = "\" Then $sPath = StringTrimRight($sPath, 1) Local $aPath = StringSplit($sPath, "\") Local $sReturn = $aPath[UBound($aPath) - 1] If $fold Then $sReturn = StringReplace($sPath, $sReturn, "") Return $sReturn EndFunc ;==>pathextract explorer.exe was holding the handle!! Zero file trace 0 CPU usage while monitoring if process exists Only way this could be any better is if you were able to do this without having to restart explorer. A powershell less version of this could be done I'm sure, but with higher cpu usage when monitoring the exe (pretty much the way guiness was doing it except not creating a bat file). I don't think you can do a VBS version without having to create a file. Worth putting in the first post in my opinion, or possibly the powershell less version or both. Edit2: I've modified the function to beable to monitor any exe you pass, pretty sweet! You must pass the full path of exe. Added @compiled so it won't delete your script. -
TouchOdeath reacted to a post in a topic: _SelfDelete() - Delete the running executable.
-
argumentum reacted to a post in a topic: _SelfDelete() - Delete the running executable.
-
_SelfDelete() - Delete the running executable.
TouchOdeath replied to guinness's topic in AutoIt Example Scripts
Boththose and argumentum, I'm glad both of you are trying to solve the issues I have identified in this post: However both of you are missing sir guiness's geniousry and a must have about his function: Doing all that without leave a trace would be something else. -
TouchOdeath reacted to a post in a topic: multi threading
-
TouchOdeath reacted to a post in a topic: Convert Multi-Page TIFF to Single Page
-
TouchOdeath reacted to a post in a topic: Convert Multi-Page TIFF to Single Page
-
Convert Multi-Page TIFF to Single Page
TouchOdeath replied to ViciousXUSMC's topic in AutoIt General Help and Support
I'm posting something slightly deviated from the original intent of the OP just FYI. Thank you UEZ and ViciousXUSMC for the wonderful code. I cleaned up some of your main function, but took out the multipage aspect. I added the ability to convert tif to a different file format other than gif: TIFconvert("C:\somefile.tif") ;Tested filetypes: ;Working filetypes: png, gif, bmp, jpg/jpeg ;Not working filetypes: webp Func TIFconvert($sFile, $sFileType = "jpg") _GDIPlus_Startup() Local $sDrive, $sDir, $sFileName, $sExtension Local $aPathSplit = _PathSplit($sFile, $sDrive, $sDir, $sFileName, $sExtension) Local $aBitmaps = _GDIPlus_ImageLoadFromMultiPageImage($sFile) Local $iW = 0, $iH = 0 For $i = 1 To $aBitmaps[0] $iW += _GDIPlus_ImageGetWidth($aBitmaps[$i]) $iH = _GDIPlus_ImageGetHeight($aBitmaps[$i]) > $iH ? _GDIPlus_ImageGetHeight($aBitmaps[$i]) : $iH Next Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap) $iW = 0 For $i = $aBitmaps[0] To 1 Step -1 _GDIPlus_GraphicsDrawImageRect($hGfx, $aBitmaps[$i], $iW, 0, _GDIPlus_ImageGetWidth($aBitmaps[$i]), _GDIPlus_ImageGetHeight($aBitmaps[$i])) $iW += _GDIPlus_ImageGetWidth($aBitmaps[$i]) Next Local $sSave = $sDir & "\" & $sFileName & "." & $sFileType ;_GDIPlus_ImageRotateFlip($hBitmap, 6) _GDIPlus_ImageSaveToFile($hBitmap, $sSave) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_BitmapDispose($hBitmap) For $i = 1 To $aBitmaps[0] _GDIPlus_BitmapDispose($aBitmaps[$i]) Next _GDIPlus_Shutdown() EndFunc ;==>TIFconvert Of course if your doing other GDI+ things outside this function, you won't want to embed startup and shutdown inside the function. -
TouchOdeath reacted to a post in a topic: _AlwaysRun() - Monitor a program and restart if it closed.
-
_AlwaysRun() - Monitor a program and restart if it closed.
TouchOdeath replied to guinness's topic in AutoIt Example Scripts
guinness, thank you sir for this wonderful script. I found some problems: The tasklist return value, the exe name is cut by 25 characters in length. So if your exe name is greater than 25 characters then nothing is returned. If nothing is returned then exe gets ran over and over. When you close out the exe another cmd.exe gets ran thus making multiple processes and wasting resources. This one is not a 'huge' problem, but its wasteful. Multiple .bat files get generated and left residing in the temp folder. Again not a big deal but bad practice. Here is my modification that solves said problems: Func _AlwaysRun($sFilePath = @ScriptFullPath, $sCommandline = '') If $sFilePath = @ScriptFullPath And @Compiled = 0 Then Return SetError(1, 0, 0) EndIf Local Const $STR_NOCASESENSEBASIC = 2 Local Const $sAppName = StringTrimLeft($sFilePath, StringInStr($sFilePath, '\', $STR_NOCASESENSEBASIC, -1)) Local Const $sBatFile = @TempDir & '\' & StringReplace(@ScriptName, StringTrimLeft(@ScriptName, StringInStr(@ScriptName, '.', $STR_NOCASESENSEBASIC, -1) - 1), '') & '.bat' If $sCommandline Then $sCommandline = ' ' & $sCommandline EndIf Local Const $sData = ':START' & @CRLF _ & 'PING -n 2 127.0.0.1 > nul' & @CRLF _ & @CRLF _ & 'TASKLIST /NH /FI "IMAGENAME EQ ' & $sAppName & '" | FIND /I /C "' & StringLeft($sAppName, 25) & '" >0 && GOTO START' & @CRLF _ & 'GOTO END' & @CRLF _ & ':END' & @CRLF _ & 'START "_AlwaysRun" "' & $sFilePath & '"' & $sCommandline & @CRLF _ & 'DEL "' & $sBatFile & '"' & @CRLF _ & 'GOTO START' & @CRLF Local Const $hFileOpen = FileOpen($sBatFile, $FO_OVERWRITE) If $hFileOpen = -1 Then Return SetError(2, 0, 0) EndIf FileWrite($hFileOpen, $sData) FileClose($hFileOpen) Return Run($sBatFile, @TempDir, @SW_HIDE) EndFunc ;==>_AlwaysRun Added a default parameter to $sFilePath so you can call your function like this: _AlwaysRun() or _AlwaysRun(Default,'some command') to easily refer to the current executable. Added /C in FIND because I'm pretty sure its quicker/less CPU intensive for FIND to return count rather than the entire string. It would be nice to come up with a solution that takes less cpu while not changing the check interval. What you have is pretty damn good. Only possible downside I see with this modification is when you close out the exe, the cmd.exe also closes and reopens. The user may put two and two together and say 'oh look.. the cmd.exe ended as soon as the exe closed.. I'll try to close that first'. This may not even be a concern. A slight con with my solution, if cmd.exe gets killed, the bat file will probably remain in temp. One remaining bat file in the temp not ideal... hrmmm.. at the same time not a huge deal... but still... -
Automating sfc /scannow to a button
TouchOdeath replied to Chimaera's topic in AutoIt General Help and Support
I'm going to make this crystal clear for everyone. I'm guessing boththose primary language isn't english. Heres the skinny on all this: When installing Autoit, if you have a 32bit system, when installed will always compile your script as a 32bit executable. So you won't even see the option to install 64bit because you can't run a 64bit program on a 32bit system, you'll get an error. If you have a 64bit system, when installing Autoit it will ask you if you want 'x64 tools' or 'x86 tools'. If you pick x64 it will always compile your scripts as a 64bit executable. If you pick x86, it will always compile your scripts as a 32bit executable. If you have scite4autoit installed you have the option to specify additional compile parameters to override the 'default' bit compile (regardless if you picked 'x64 tools' or x86 tools'). #AutoIt3Wrapper_UseX64=n The option above if 'n' will compile a 32bit executable, if 'y' will compile a 64bit executable. Regardless if you are running a 32bit OS or 64 bit OS. From a 64bit system (Windows Vista+), the above code will always work if compiled from a 32bit executable. It will always fail if compiled from a 64bit executable. Regardless if redirection is on or off. -
Automating sfc /scannow to a button
TouchOdeath replied to Chimaera's topic in AutoIt General Help and Support
You mean 32bit compile not install. Read: http://www.samlogic.net/articles/sysnative-folder-64-bit-windows.htm I'll supply another answer to this thread since neither of you 'like' my answer. Again, this works on my x64 system running W7, as far as other OS's, I don't know, test it yourselves. If StringInStr(@OSArch, "64") Then DllCall("kernel32.dll", "boolean", "Wow64EnableWow64FsRedirection", "boolean", 0) Run(@ComSpec & " /k " & @WindowsDir & "\System32\sfc /scannow", "", @SW_SHOW) DllCall("kernel32.dll", "boolean", "Wow64EnableWow64FsRedirection", "boolean", 1) Else Run(@ComSpec & " /k " & @WindowsDir & "\System32\sfc /scannow", "", @SW_SHOW) EndIf -
Automating sfc /scannow to a button
TouchOdeath replied to Chimaera's topic in AutoIt General Help and Support
I realize this is a year old but heres the real answer (works on my win7 box): If StringInStr(@OSArch, "64") Then Run(@ComSpec & " /k " & @WindowsDir & "\Sysnative\sfc /scannow", "", @SW_SHOW) Else Run(@ComSpec & " /k " & @WindowsDir & "\System32\sfc /scannow", "", @SW_SHOW) EndIf -
IconDock - Mac style Icon toolbar
TouchOdeath replied to eukalyptus's topic in AutoIt Example Scripts
https://autoit.de/index.php/Attachment/79469-IconDock-zip/ With current version of autoit you'll need to rename $ghGDIPDLL to $__g_hGDIPDll in IconDock.au3 -
AdmiralAlkex reacted to a post in a topic: Total privacy
-
try this: #include <IE.au3> Local $oIE = _IECreate("https://intranet.website.net") If IsObj($oIE) Then WinSetState("[CLASS:IEFrame]", "", @SW_MAXIMIZE) Local $oForms = _IEFormGetCollection($oIE) If IsObj($oForms) Then ;the rest of your code Else Msgbox(0,'','error oforms') EndIf Else Msgbox(0,'','error oIE') EndIf Read the parameters for _IECreate. The first parameter if set to 1 will try and match a window, you don't want this. Thats why your getting the 'No match' because yes, it didn't match any existing windows because the window doesn't exist.