Jump to content

Leaderboard

Popular Content

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

  1. 4 points
  2. Using @ScriptFullPath as the _Singleton()'s occurrence name will not work because it will contain one or more prohibited backslashes (\), which will make the _Singleton() function fail and return 0. That syntax would exit upon every invocation. If you want to use a macro, then @ScriptName should be unique enough. If all you want the duplicate process to do when launched is exit, then you just need: #Include <misc.au3> _Singleton(@ScriptName) You only need to set $iFlag to 1 if you want to capture the fact that a duplicate process has been launched, for example, if you want to show a message box before exiting. By default ($iFlag = 0), upon executing the function above, the script will immediately exit with an exit code of -1 (if a duplicate script is already running). The example below shows when using the @ScriptFullPath macro, if you were checking the return of _Singleton(@ScriptFullPath, 1) to 0 in order to exit, then it would have exited upon every execution of the function. When using @ScriptName, only executions after the initial execution would exit. #include <Misc.au3> ConsoleWrite("_Singleton(@ScriptFullPath, 1) = 0: " & (_Singleton(@ScriptFullPath, 1) = 0) & @CRLF) ConsoleWrite("_Singleton(@ScriptFullPath, 1) = 0: " & (_Singleton(@ScriptFullPath, 1) = 0) & @CRLF) ConsoleWrite(@CRLF) ConsoleWrite("_Singleton(@ScriptName, 1) = 0: " & (_Singleton(@ScriptName, 1) = 0) & @CRLF) ConsoleWrite("_Singleton(@ScriptName, 1) = 0: " & (_Singleton(@ScriptName, 1) = 0) & @CRLF) Console output: _Singleton(@ScriptFullPath, 1) = 0: True _Singleton(@ScriptFullPath, 1) = 0: True _Singleton(@ScriptName, 1) = 0: False _Singleton(@ScriptName, 1) = 0: True
    2 points
  3. RTFC

    Pointer to a pointer

    That would depend entirely on what you wish to do with it afterwards, but try option 1 first. If you study _HighMem_MapExternalMemory(), you see that I pre-allocate a (uniquely, predictably) PID-named region in virtual memory first, which allows another process (if it knows the PID of the original process) to open it and remap it within their own (virtual) memory space. Anything allocated within that region is then also accessible to the other process; it just has to be remapped in the new context. Look into _WinAPI_CreateFileMapping, _WinAPI_OpenFileMapping, and _WinAPI_MapViewOfFile for more info (Note: these function names are confusing, because we're mapping virtual memory with it, not a file).
    1 point
  4. RTFC

    Pointer to a pointer

    #include <WinAPISys.au3> Local $tmp=_WinAPI_GetSystemInfo() Local $BaseAddress = Ptr($tmp[2]) ; "Lowest-Accessible Memory Address" You didn't specify what __GetBaseAddress() actually does. With the above it should work (for the current PID). (the Highmem UDF of course takes care of all this low-level stuff for you automatically...)
    1 point
  5. Jos

    SMTP Mailer UDF

    You need some form of richtext so I think html is your only option.
    1 point
  6. OJBakker

    AutoIt Snippets

    This is my Showmacros.au3 script. It is one of the first scripts I have made with AutoIt , but I have enhanced it a few times. It uses an array with all the macro names in the same order as the helpfile and reports all macro's with their values (if available) with arraydisplay. If you don't like this order, just rearrange the array and be happy! #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #include <Array.au3> AutoItSetOption("MustDeclareVars", 1) Local $asMacroNames = [ _ "@AppDataCommonDir", "@AppDataDir", "@AutoItExe", "@AutoItPID", "@AutoItVersion", "@AutoItX64", "@COM_EventObj", "@CommonFilesDir", _ "@Compiled", "@ComputerName", "@ComSpec", "@CPUArch", "@CR", "@CRLF", "@DesktopCommonDir", "@DesktopDepth", "@DesktopDir", "@DesktopHeight", _ "@DesktopRefresh", "@DesktopWidth", "@DocumentsCommonDir", "@error", "@exitCode", "@exitMethod", "@extended", _ "@FavoritesCommonDir", "@FavoritesDir", "@GUI_CtrlHandle", "@GUI_CtrlId", "@GUI_DragFile", "@GUI_DragId", "@GUI_DropId", "@GUI_WinHandle", _ "@HomeDrive", "@HomePath", "@HomeShare", "@HotKeyPressed", "@HOUR", "@IPAddress1", "@IPAddress2", "@IPAddress3", "@IPAddress4", "@KBLayout", "@LF", _ "@LocalAppDataDir", "@LogonDNSDomain", "@LogonDomain", "@LogonServer", "@MDAY", "@MIN", "@MON", "@MSEC", "@MUILang", "@MyDocumentsDir", _ "@NumParams", "@OSArch", "@OSBuild", "@OSLang", "@OSServicePack", "@OSType", "@OSVersion", "@ProgramFilesDir", "@ProgramsCommonDir", "@ProgramsDir", _ "@ScriptDir", "@ScriptFullPath", "@ScriptLineNumber", "@ScriptName", "@SEC", "@StartMenuCommonDir", "@StartMenuDir", "@StartupCommonDir", "@StartupDir", _ "@SW_DISABLE", "@SW_ENABLE", "@SW_HIDE", "@SW_LOCK", "@SW_MAXIMIZE", "@SW_MINIMIZE", "@SW_RESTORE", "@SW_SHOW", "@SW_SHOWDEFAULT", "@SW_SHOWMAXIMIZED", _ "@SW_SHOWMINIMIZED", "@SW_SHOWMINNOACTIVE", "@SW_SHOWNA", "@SW_SHOWNOACTIVATE", "@SW_SHOWNORMAL", "@SW_UNLOCK", "@SystemDir", "@TAB", "@TempDir", "@TRAY_ID", _ "@TrayIconFlashing", "@TrayIconVisible", "@UserName", "@UserProfileDir", "@WDAY", "@WindowsDir", "@WorkingDir", "@YDAY", "@YEAR", "@NoMacro"] ; above are the macro's from autoit v3.3.16.1 These can also be found in file au3check.dat but than a compiled script (exe) would need to know where to find this file. Local $sMacroValue Local $aMacroArray[UBound($asMacroNames)][4] For $k = 0 To UBound($asMacroNames) - 1 $aMacroArray[$k][0] = $asMacroNames[$k] $aMacroArray[$k][1] = "" $aMacroArray[$k][2] = Execute($asMacroNames[$k]) If @error Then $aMacroArray[$k][1] = "N/A" $aMacroArray[$k][3] = "" $sMacroValue = " " Switch $asMacroNames[$k] Case "@COM_EventObj" $sMacroValue &= "Only valid in a COM even function" Case "@GUI_CtrlId", "@GUI_CtrlHandle", "@GUI_WinHandle" $sMacroValue &= "Only valid in an event function" Case "@GUI_DragFile", "@GUI_DragId", "@GUI_DropId" $sMacroValue &= "Only valid in a drop event function" Case "@exitCode", "@exitMethod" $sMacroValue &= "Only valid in a function in OnAutoItExitRegister" Case "@TRAY_ID" $sMacroValue &= "Only valid in Tray event function" Case Else $sMacroValue &= "Not a valid macro" EndSwitch $aMacroArray[$k][2] = $sMacroValue Else ; hex/dec view for non-visual macro's $aMacroArray[$k][3] = VarGetType($aMacroArray[$k][2]) Switch $asMacroNames[$k] Case "@CR", "@CRLF", "@LF", "@TAB" $aMacroArray[$k][2] = "Hex: " & StringToBinary($aMacroArray[$k][2]) & " Dec: " & _ArrayToString(StringToASCIIArray($aMacroArray[$k][2]), " ") Case "@HOUR", "@MDAY", "@MIN", "@MON", "@MSEC", "@SEC", "@WDAY", "@YDAY", "@YEAR" $aMacroArray[$k][2] = " now: " & $aMacroArray[$k][2] ; group these in view sort on macrovalue EndSwitch EndIf Next _ArrayDisplay($aMacroArray, "AutoIt Macro's Overview. Type = VarGetType(Execute('@Macro'))", Default, $ARRAYDISPLAY_COLALIGNLEFT + $ARRAYDISPLAY_NOROW, Default, "Macro Name|Avail.|Macro Value|Type") ShowMacros.au3
    1 point
×
×
  • Create New...