Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/02/2023 in all areas

  1. ioa747

    Active_SaveFileDlg

    Add All open folder & some extra as contex menu in SaveFileDlg & OpenFileDlg of SciTE Adds the ability to quickly select one of the open folders or one of those you use regularly. as a destination to save the file To test, open a few folders in the background and then select >File >Save As... to SciTE First add your favorite folders on line 58, 59, you can put more, but above line 60 $OpenFolders[0][0] = UBound($OpenFolders) - 1 The number on the front "002|D:\i\Pro\.AutoIT" doesn't matter, but need to have it Thanks to @Lepes suggestion for _WinApi_GetParent function, so that only the SciTE dialogue is caught. ; https://www.autoitscript.com/forum/topic/210165-active_savefiledlg/ ;---------------------------------------------------------------------------------------- ; Title...........: Active_SaveFileDlg.au3 ; Description.....: Add All open folder & some extra as contex menu in SaveFileDlg & OpenFileDlg of SciTE ; AutoIt Version..: 3.3.16.1 Author: ioa747 ;---------------------------------------------------------------------------------------- #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ;~ #NoTrayIcon #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <WinAPISysWin.au3> #include <Misc.au3> #include <Array.au3> Global $hGUI, $hDlgWnd, $hScite If _Singleton(@ScriptName, 1) = 0 Then Exit ; to avoid running it multiple times! While WinExists("[CLASS:SciTEWindow]") $hScite = WinGetHandle("[CLASS:SciTEWindow]") If WinExists("[TITLE:Save File; CLASS:#32770]") Then ; ------------ Save File $hDlgWnd = WinGetHandle("[TITLE:Save File; CLASS:#32770]") _CallFoldersGUI("Save") ElseIf WinExists("[TITLE:Open File; CLASS:#32770]") Then ; -------- Open File $hDlgWnd = WinGetHandle("[TITLE:Open File; CLASS:#32770]") _CallFoldersGUI("Open") EndIf Sleep(500) WEnd Exit ;---------------------------------------------------------------------------------------- Func _CallFoldersGUI($sDlgTitle) If _WinAPI_GetParent($hDlgWnd) = $hScite Then _FoldersGUI($sDlgTitle) While WinActive($hDlgWnd) ; Loop While win exits. Sleep(500) WEnd GUIDelete($hGUI) Else Return EndIf EndFunc ;==>_CallFoldersGUI ;---------------------------------------------------------------------------------------- Func _FoldersGUI($sDlgTitle) $hGUI = GUICreate("MyGUI", 40, 40, -50, -50, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_NOACTIVATE), $hDlgWnd) Local $idDummy = GUICtrlCreateDummy() Local $idButton = GUICtrlCreateButton("contex button", 0, 0, 40, 40, $BS_ICON) GUICtrlSetImage(-1, "shell32.dll", -68) Local $idContext = GUICtrlCreateContextMenu($idButton) Local $OpenFolders = _EnumAllOpenFolder() ; Add some extra folder (the numbers on the front don't matter) _ArrayInsert($OpenFolders, 1, "000|") ; separator _ArrayInsert($OpenFolders, 1, "001|D:\i\Pro\.AutoIT\_Test\005_Test") ; * <--------- Fav1 folder (get one of your own) _ArrayInsert($OpenFolders, 1, "002|D:\i\Pro\.AutoIT") ; * <------------------------ Fav2 folder (get one of your own) $OpenFolders[0][0] = UBound($OpenFolders) - 1 For $i = 1 To $OpenFolders[0][0] GUICtrlCreateMenuItem($OpenFolders[$i][1], $idContext) Next Local $Wpos = WinGetPos($hDlgWnd) ;ConsoleWrite("$Wpos " & $Wpos[0] & "; " & $Wpos[1] & "; " & $Wpos[2] & "; " & $Wpos[3] & @CRLF) Local $aOfset[2] ;$aOfset[0]=X ;$aOfset[1]=Y If $sDlgTitle = "Save" Then $aOfset[0] = 270 $aOfset[1] = 55 ElseIf $sDlgTitle = "Open" Then $aOfset[0] = 270 $aOfset[1] = 50 EndIf GUISetState(@SW_SHOW, $hGUI) WinMove($hGUI, "", $Wpos[0] + $Wpos[2] - $aOfset[0], $Wpos[1] + $Wpos[3] - $aOfset[1]) Local $idMsg While WinExists($hDlgWnd) $Wpos = WinGetPos($hDlgWnd) WinMove($hGUI, "", $Wpos[0] + $Wpos[2] - $aOfset[0], $Wpos[1] + $Wpos[3] - $aOfset[1]) $idMsg = GUIGetMsg() Switch $idMsg Case 6 To $OpenFolders[0][0] + 6 ;ConsoleWrite($OpenFolders[$idMsg - 5][1] & @CRLF) WinActivate($hDlgWnd) If $sDlgTitle = "Save" Then ControlCommand($hDlgWnd, "", "ToolbarWindow324", "SendCommandID", 1280) ControlSetText($hDlgWnd, "", "Edit2", $OpenFolders[$idMsg - 5][1]) ControlSend($hDlgWnd, "", "Edit2", "{ENTER}") ElseIf $sDlgTitle = "Open" Then ControlCommand($hDlgWnd, "", "ToolbarWindow323", "SendCommandID", 1280) ControlSetText($hDlgWnd, "", "Edit2", $OpenFolders[$idMsg - 5][1]) ControlSend($hDlgWnd, "", "Edit2", "{ENTER}") EndIf Case $idButton GUICtrlSendToDummy($idDummy) Case $idDummy MouseClick("right") ;ExitLoop EndSwitch Sleep(10) WEnd GUIDelete($hGUI) Return EndFunc ;==>_FoldersGUI ;---------------------------------------------------------------------------------------- Func _EnumAllOpenFolder() ; enumerating all open folders Local $oShell = ObjCreate("Shell.Application") Local $sPath, $index = 0 Local $aArray[$oShell.Windows.Count + 1][2] = [["hWnd", "Path"]] For $oWin In $oShell.Windows $index += 1 $aArray[0][0] = $index $sPath = StringTrimLeft($oWin.LocationURL, 8) ; trim 'file:///' $sPath = StringReplace($sPath, "/", "\") $sPath = _UnicodeURLDecode($sPath) $aArray[$index][0] = HWnd($oWin.HWND) $aArray[$index][1] = $sPath Next Return $aArray EndFunc ;==>_EnumAllOpenFolder ;---------------------------------------------------------------------------------------- Func _UnicodeURLDecode($toDecode) Local $strChar = "", $iOne, $iTwo Local $aryHex = StringSplit($toDecode, "") For $i = 1 To $aryHex[0] If $aryHex[$i] = "%" Then $i = $i + 1 $iOne = $aryHex[$i] $i = $i + 1 $iTwo = $aryHex[$i] $strChar = $strChar & Chr(Dec($iOne & $iTwo)) Else $strChar = $strChar & $aryHex[$i] EndIf Next Local $Process = StringToBinary($strChar) Local $DecodedString = BinaryToString($Process, 4) Return $DecodedString EndFunc ;==>_UnicodeURLDecode ;----------------------------------------------------------------------------------------
    1 point
  2. #include <Misc.au3> Global $hDLL = DllOpen("user32.dll") While 1 If _IsPressed("10", $hDLL) Then ;10 SHIFT key ConsoleWrite("Shift Key is down" & @CRLF) While _IsPressed("10", $hDLL) ;10 SHIFT key If _IsPressed("12", $hDLL) Then ;12 ALT key ConsoleWrite("SHIFT + ALT is down" & @CRLF) ElseIf _IsPressed("11", $hDLL) Then ;11 CTRL key ConsoleWrite("SHIFT + CTRL is down" & @CRLF) EndIf Sleep(150) WEnd ConsoleWrite("Shift Key is up" & @CRLF) EndIf Sleep(10) WEnd
    1 point
  3. Hello, TheXman You are very kind to me. Thank you for your words, because this makes me feel at home. Helping beginners is somewhat difficult, because we want to do things too fast, without even knowing the documentation. Serious mistake. I will briefly respond to some of your comments. I use tools like Farbar to help users remove all kinds of malware, as well as anti-malware like MalwareBytes, AdwCleaner, etc. The problem is that the malware that I am trying to eradicate is only affecting a certain country or countries (I understand that there is some illegal software download website that is distributing this malware). I have reported to Google (VirusTotal) and sent a sample of the file to Microsoft. But it doesn't appear that they have taken action against the malware. I have yet to report MalwareBytes for example, but in any case there are already reversing technical docs of some of the variants of this malware. I guess some reversing experts will have already done it. Of course, my intention is not to create a definitive removal tool, because I would have to use later a more effective study with Farbar for example, but to at least try to eliminate the most vital processes of the malware. The best thing would be to check the signature of the files, the hashes, etc.; but I would do this in a later step if I got a breakthrough in this first phase of development. The first option that occurred to me was to use C# or Python, but AutoIT seemed like a quick option. This is more of a way of learning. If the tool, once tested on various own computers, works, it could help some users. Sorry, I thought @TempDir would remove temporary files, but of course, it makes sense that @TempDir simply contains the value of the TEMP environment variable. Honestly, I didn't even check the folder that AutoIT creates when it installs. I directly went to the code editor. From now on, I'm going to go much slower with all of this, because I don't want to make any more mistakes. I don't want to bother you We all have many things to do on a daily basis, and your answers have helped me understand that the answers I am looking for, I will not find directly in a search in the forum. At least, code that may be out of date. Thank you for your answers so elaborate, and with so much good information. You have been very helpful. I will try to test and test, before I ask again. All the best.
    1 point
  4. @Lepes I don't think that this is a good method for measuring time with precision, at least over native AutoIt function. I did a quick test comparing that linked function vs just TimerInit and TimerDiff: Func _MicroSeconds() Local Static $nFreq = _WinAPI_QueryPerformanceFrequency() Local $a = _WinAPI_QueryPerformanceCounter() Local $b = _WinAPI_QueryPerformanceCounter() Return (($b - $a) / $nFreq) * 1000000 EndFunc ;==>_MicroSeconds Func _TimerDiff() Local $hTimer = TimerInit() Local $nOutput = TimerDiff($hTimer) * 1000 Return $nOutput EndFunc ;==>_TimerDiff And the speed output: 2023-05-01 09.54.18.626: _MicroSeconds: 13.5 2023-05-01 09.54.18.627: _TimerDiff: 3.2 [================== Run progress, 100,000 times * 2 functions =================] +———————————————+—————————————————+———————————————+——————————————+—————————————+ | Function Name | Time Taken (ms) | Avg Time (ms) | Std Dev (ms) | Faster By % | +———————————————+—————————————————+———————————————+——————————————+—————————————+ | _MicroSeconds | 3288.67 | 0.0329 | 0.0170 | 0.00 | +| _TimerDiff | 396.91 | 0.0040 | 0.0082 | 87.93 | +———————————————+—————————————————+———————————————+——————————————+—————————————+ As you can see _MicroSeconds gave me 13.5us, _TimerDiff 3.2us, and comparing them TimerInit() and TimerDiff() are 87% faster. It can't measure as low as the native functions since they run so much faster. It's likely/possible that TimerInit uses QueryPerformanceCounter or GetTickCount internally anyway, and its internal method of calling these is just a lot faster than a DLL call. Also we're not looking at trying to measure sub-millisecond precision here, and even if _WinAPI_QueryPerformanceCounter was as fast/faster, I think it's still a bit simpler to use TimerInit/TimerDiff.
    1 point
  5. I don't know if it works with TIF's but sure it works with PNG's. Edit: Just tested with the welcomefax.tif (the onliest tif i have) and it works: #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GUICtrlPic.au3> #include <Array.au3> Global $hGui = GUICreate("Show Tif",@DesktopWidth, @DesktopHeight) Global $aDim = WinGetClientSize($hGui) Global $sAutoItPath If @Compiled Then $sAutoItPath=RegRead64('HKLM\Software\AutoIt v3\AutoIt', 'InstallDir')&'\' Else $sAutoItPath= StringReplace(@AutoItExe, "autoit3.exe", "")&'\' $sAutoItPath= StringReplace(@AutoItExe, "autoit3_x64.exe", "") EndIf Global $Background = _GUICtrlPic_Create("C:\Users\(len)Bert\Downloads\Documents\Fax\Inbox\WelcomeFax.tif", 0, 0, $aDim[0], $aDim[1], $SS_CENTERIMAGE, Default) GUICtrlSetState(-1, $Gui_DISABLE) GUISetState() While 1 Switch GUIGetMsg() Case $Gui_EVENT_CLOSE Exit EndSwitch WEnd Func RegRead64($sKeyname, $sValue) ;Aus AutoUpdateIt.au3 Local $sRes = RegRead($sKeyname, $sValue) If @error And @AutoItX64 Then $sKeyname = StringReplace($sKeyname, "HKEY_LOCAL_MACHINE", "HKLM") $sKeyname = StringReplace($sKeyname, "HKLM\SOFTWARE\", "HKLM\SOFTWARE\Wow6432Node\") $sRes = RegRead($sKeyname, $sValue) If @error Then SetError(1) Return "" EndIf EndIf SetError(0) Return $sRes EndFunc ;==>RegRead64 GUICtrlPic.au3
    1 point
  6. Hey guys, I needed a tool to generate a patch from the folder of a software after an update so i could apply this patch to other computers without having to re-download the update on them as well. I've looked a bit on the net and was surprised not beeing able to find one. So i've made my own that i called "file patch manager": I think the explaination in the screenshot above is pretty much straightfoward so i don't need to add a lot more to that This is developped in pure autoit v3.3.14.5, no UDF required. Download Source code: files patch manager v1.1.au3 Compiled exe: files patch manager v1.1.exe I've noticed that the compiled exe can sometimes be detected as a trojan by windows defender :facepalm: But this is a false positive as it's a compiled exe from the untouched source code i'm providing here as well. If you have any doubt feel free to compile it yourself instead of directly using the exe, but i assure you the exe is completely safe. If i had bad intentions i wouldn't share the source code as well More informations on why the false positive happens can be found here: The code is not perfect and could certainly be enhanced but i've tested it and all the steps should work properly in all situations except maybe when using it on a folder that contains files with special attributes (explained below). What could be enhanced: - if the updated version of the folder of the software contains empty folders that did not previously exist in the outdated folder, this tool doesn't carry them over (it could be added easily thought, i made a comment about that in the source code) - i didn't test the tool with a folder that had files with special attributes (hidden, system, ect...) so some tweaking might be needed to use it on such a folder - i didn't had the time to secure the tool properly from user-input mistakes or to add proper error handling to all the functions used to check they return values for errors, but you can easily check if the patch works correctly by trying to apply it to an outdated folder then compare it's byte size to the one of the updated folder. If they match then it's OK. - the GUI design which is pretty basic but doing a fancy thing wasn't my goal here. - when designing the engine to compare the outdated and updated folders i did one that compares the files then the folders. It compares them in 2 steps while it could have been possible to compare both in 1 step by analysing if the compared element was a file or a folder using the FileGetAttrib function. This means that for a software that has a huge number of files and folders (over 10000) the 2 step process will take twice the time it would take with a 1 step process. But since i've never had to work in that case until now, i won't change the compare engine right now. If one of you reach this case and processing time is an essential factor you know what you have to do Shouldn't be too complicated to make the change anyway if needed. If you have any problems using it feel free to ask, i'll do my best to help when i'm available. If possible include the outdated and updated folders you use as the source of your patch so i can run it and check errors by myself as well. If you used this tool for your own needs and made some improvements consider sharing your version as well Enjoy Changelog 22 august 2019 - v1.0: - initial release 23 august 2019 - v1.1: - fix crash if patch generated has no file to delete inside the outdated folder. - added a progress bar to show which file the tool is currently working on, it's size and how many files are remaining so the tool doesn't look frozen when it's working with large files.
    1 point
×
×
  • Create New...