Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/29/2023 in all areas

  1. When I started using AutoIt, I used to dump all the community UDFs as well as my own frequently-used scripts into C:\Program Files (x86)\AutoIt3\Include - - terrible idea, of course, and I wouldn't advise anyone to do this. These days I have the following folder structure for UDFs: - I have a folder C:\AutoIt which has subfolders: - - C:\AutoIt\MyLibraries, which has my own scripts, organized as C:\AutoIt\MyLibraries\MyUDFName\MyUDFName.au3 - - C:\AutoIt\CommunityLibraries, which has scripts from other forum members, organized as: C:\AutoIt\CommunityLibraries\CommunityMemberUsername\UDFName\UDFName.au3 For example, I've been playing around with TheXman's "jq" UDF, and this is the storage path: This in itself won't make everything run. Some UDFs will have hardcoded DLL paths which you'll have to edit. And finally, you'll have to make registry edits so you can #include these UDFs without entering the entire path. Here's what I did: #include <Array.au3> #include <File.au3> Global Const $CUSTOMINCLUDE_REGKEYNAME = "HKEY_CURRENT_USER\Software\AutoIt v3\AutoIt" Global Const $CUSTOMINCLUDE_REGKEYVALUENAME = "Include" Global Const $CUSTOMINCLUDE_REGKEYVALUETYPE = "REG_SZ" Global Const $FOLDER_COMMUNITYLIBRARIES = "C:\AutoIt\CommunityLibraries" Global Const $FOLDER_MYLIBRARIES = "C:\AutoIt\MyLibraries" Global $CUSTOMINCLUDE_REGKEYVALUE = "" Local $CommunityUsers = _FileListToArray($FOLDER_COMMUNITYLIBRARIES, "*", $FLTA_FOLDERS, False) _ArrayDelete($CommunityUsers, 0) Local $CommunityLibraries = 0 Local $UDFPath = "" For $i = 0 To UBound($CommunityUsers) - 1 $CommunityLibraries = _FileListToArray($FOLDER_COMMUNITYLIBRARIES & "\" & $CommunityUsers[$i], "*", $FLTA_FOLDERS, False) _ArrayDelete($CommunityLibraries, 0) For $j = 0 To UBound($CommunityLibraries) - 1 $UDFPath = $FOLDER_COMMUNITYLIBRARIES & "\" & $CommunityUsers[$i] & "\" & $CommunityLibraries[$j] If FileExists($UDFPath) Then $CUSTOMINCLUDE_REGKEYVALUE &= $UDFPath & ";" Next Next Local $MyLibraries = _FileListToArray($FOLDER_MYLIBRARIES, "*", $FLTA_FOLDERS, False) _ArrayDelete($MyLibraries, 0) For $j = 0 To UBound($MyLibraries) - 1 $UDFPath = $FOLDER_MYLIBRARIES & "\" & $MyLibraries[$j] If FileExists($UDFPath) Then $CUSTOMINCLUDE_REGKEYVALUE &= $UDFPath & ";" Next $CUSTOMINCLUDE_REGKEYVALUE = StringTrimRight($CUSTOMINCLUDE_REGKEYVALUE, 1) ConsoleWrite($CUSTOMINCLUDE_REGKEYVALUE) RegWrite("HKEY_CURRENT_USER\Software\AutoIt v3\AutoIt", "Include", "REG_SZ", $CUSTOMINCLUDE_REGKEYVALUE) This script scans the "CommunityLibraries" and "MyLibraries" folders and adds all the folder paths where the folder name matches the au3 file name to the registry. So far, it has worked out great for me, because now I can use this: #include <jq.au3> instead of: #include "C:\AutoIt\CommunityLibraries\TheXman\jq\jq.au3" Okay, that's all, I hope this'll be useful for newbies who want an easy system for storing their UDFs :)
    1 point
  2. No no it was absolutely perfekt - and pretty good for my laziness btw, so thank you The holy Help File says : POSIX classes : These are named sets specifications to be used themselves within a character class It says too (see "Anchors") : the dollar matches at the end of the subject text, and also just before a newline sequence if option (?m) is active
    1 point
  3. I'm sure @mikell can explain it much better . Anyway, have a look at the StringRegExp help (in particular : Character classes and POSIX classes). The outer brackets represent a character class, which means a defined set of allowed/disallowed characters . The inner brackets represent a POSIX class, here [:alnum:] So if you use a POSIX class within a character class ,the notation is [[:alnum:]]
    1 point
  4. Hi @UEZ sorry for the mess of my snippets I declared the Global variable $GlobalFlag at the beginning of one of my test drafts but I didn't post it, I only posted the core piece of code... Global $GlobalFlag = False Also, since the CapturePreview function seems to be asynchronous, I've set the $GlobalFlag setting inside the callback function for the CapturePreview so that it's only set to True when the capture is complete. This functio is executed automatically only when CapturePreview has ended Func CoreWebView2CapturePreviewCompletedHandler_Invoke($pSelf, $iErrorCode) ; Ret: dword ConsoleWrite("CoreWebView2CapturePreviewCompletedHandler_Invoke()" & @CRLF) ConsoleWrite("CapturePreview returned Error code: " & $iErrorCode & @CRLF) $GlobalFlag = True Return 0 ; For AddRef/Release #forceref $pSelf, $iErrorCode EndFunc ;==>CoreWebView2CapturePreviewCompletedHandler_Invoke in this way the "wait" loop is exceeded only when the $GlobalFlag becomes True in the CallBack function, i.e. when the screenshot capture is finished. Sorry again for the mess... as soon as I can I try to group all the positive "discoveries" into a single script.
    1 point
  5. Have you tried adding #RequireAdmin at the top of your script?
    1 point
  6. This was a tiny project I had in my mind and never had time to get to do due to demanding projects. Thank you for providing this.
    1 point
  7. _WinAPI_CreateStreamOnHGlobal() seems to work. However, it is important to wait for the screenshot to be completed before reading the stream (I inserted a loop that waits for $GlobalFlag to be True. It is set to True by the callback function when the screenshot is completed). Below snippet shows the captured screenshot in a temporary GUI..... Case $idWebScreenShot ; CapturePreview Local $hStream = _WinAPI_CreateStreamOnHGlobal() $GlobalFlag = False $oCoreWebView2.CapturePreview($COREWEBVIEW2_CAPTURE_PREVIEW_IMAGE_FORMAT_PNG, $hStream, $pICoreWebView2CapturePreviewCompletedHandler) ; above call Forces in turn CoreWebView2CapturePreviewCompletedHandler_Invoke() callback function below to be executed after screenshot is taken Do ; wait until screenshot is completw Sleep(200) Until $GlobalFlag ; is set to True in the CoreWebView2CapturePreviewCompletedHandler_Invoke() below callback function Local $hBitmapFromStream = _GDIPlus_BitmapCreateFromStream($hStream) ;create bitmap from a stream WinAPI_ReleaseStream($hStream) Local $iX = _GDIPlus_ImageGetWidth($hBitmapFromStream) Local $iY = _GDIPlus_ImageGetHeight($hBitmapFromStream) Local $hTempGui = GUICreate('', $iX, $iY, 5, 5) ; to show the screenshot GUISetState(@SW_SHOW,$hTempGui) Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hTempGui) ;create a graphics object from a window handle _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmapFromStream, 0, 0) ;display streamed image MsgBox(0, '', 'pause') ;cleanup resources _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_BitmapDispose($hBitmapFromStream) GUIDelete($hTempGui) Case $GUI_EVENT_CLOSE or something like that as suggested in this post ... Local $hStream = _WinAPI_CreateStreamOnHGlobal() Local $hMemory = _WinAPI_GetHGlobalFromStream($hStream) Local $iMemSize = _MemGlobalSize($hMemory) Local $pMem = _MemGlobalLock($hMemory) Local $tData = DllStructCreate("byte[" & $iMemSize & "]", $pMem) Local $bData = DllStructGetData($tData, 1) _WinAPI_ReleaseStream($hStream) _MemGlobalFree($hMemory) Return $bData
    1 point
  8. Just a loop : Local $aExt = ["*.d2s","*.key","*.ma0","*.ma1","*.ma2","*.ma3","*.map"] For $ext in $aExt FileCopy("C:\Users\------\Saved Games\Diablo II\" & $ext, "F:\Game Backup\Diablo II") Next
    1 point
  9. Andreik

    Bulldozer

    I'll add more these days.
    1 point
  10. MHz

    need to execute cmd commands

    The code below is perhaps worth a try as it attempts to do all 5 commands in a single CMD instance. ; Use to run the command following && only if the ; command preceding the symbol is successful. ; Cmd.exe runs the first command, and then runs ; the second command only if the first command ; completed successfully. ; Reference: ; http://technet.microsoft.com/en-us/library/bb490954.aspx $CMD = 'ipconfig /flushdns && ' & _ 'net stop dnscache && ' & _ 'ipconfig /flushdns && ' & _ 'net start dnscache && ' & _ 'ipconfig /flushdns' ; /k keeps the CMD window open. ; /c closes the CMD window once the command is complete. ; Reference: ; Type CMD /? in a command prompt window for help ; with CMD options. RunWait('"' & @ComSpec & '" /k ' & $CMD, @SystemDir)
    1 point
×
×
  • Create New...