Jump to content

argumentum

MVPs
  • Posts

    4,494
  • Joined

  • Last visited

  • Days Won

    133

argumentum last won the day on March 30

argumentum had the most liked content!

About argumentum

Profile Information

  • Member Title
    ✨Universalist ✨
  • Location
    I'm in your browser now =)
  • WWW
    https://www.youtube.com/watch?v=SjwX-zMRxO0&t=5s
  • Interests
    Relax

Recent Profile Visitors

12,010 profile views

argumentum's Achievements

  1. ..since _GDIPlus_ImageSaveToFile() may exist, at times I make my functions f_GDIPlus_ImageSaveToFile(). That prefix lets me know is my function. @Deye - Great idea. @argumentum - I know. ...I may have no clue of what is the question 😅
  2. Func OthersPID($iPID) Local $pid = ProcessExists(@ScriptName) If $pid = @AutoItPID Then Return "is me" If $pid = 0 Then Return "no such EXE" Return "ain't me" EndFunc this was meant for compiled scripts. But you are right, use ProcessList() instead
  3. FileSetAttrib() why do you want to do this systematically ?
  4. #include <GUIConstantsEx.au3> Global $g_idLabel = 0 Example() Func Example() GUICreate("Busy or not, here I go...", 400, 200) $g_idLabel = GUICtrlCreateLabel("nothing", 10, 10, 100) GUISetState(@SW_SHOW) AdlibRegister(flipit, 2000) While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd GUIDelete() EndFunc ;==>Example Func flipit() Local Static $bBusy = False $bBusy = Not $bBusy GUICtrlSetData($g_idLabel, $bBusy ? "busy" : "nothing") GUISetCursor($bBusy ? 1 : 2, 1) EndFunc ;==>flipit ..to tell the user that the script is doing something.
  5. ..using your script I figure that you may want to prefetch the info. It does not change that often.
  6. ...yes it is @Nine. Hence, either AutoIt3, on a direct call internally opens the DLL and keeps it ( that would be a bad move ) or, we change all UDFs to implement a global DllOpen ala GDI UDFs ?. It would be more efficient anyway at the price of loading more than needed. No clue, just an idea.
  7. ...too late I'd make a GUI and master script, and IPC everything else.
  8. Then CreateSemaphoreW works well with global DllOpen() ?, only CreateFileMappingW fails ? To me this is important because I can not know an edge case ( like yours ) where a "single-on" will fail. Also, have you tried with older AutoIt3 versions ? ( just in case it needs "higher up" attention )
  9. Local $hSemaphore = _SingletonSemaphore If _SingletonSemaphore("TestSemaphore", 2) = 0 Then MsgBox(16, "Warning - " & @ScriptName, "An occurrence of test is already running", 30) Exit EndIf MsgBox(64, "OK - " & @ScriptName, "The first occurrence of test is running", 30) DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hSemaphore) Func _SingletonSemaphore($sOccurrenceName, $iFlag = 0) Local Const $ERROR_ALREADY_EXISTS = 183 Local Const $SECURITY_DESCRIPTOR_REVISION = 1 Local $tSecurityAttributes = 0 Local $tagSECURITY_ATTRIBUTES = "dword Length;ptr Descriptor;bool InheritHandle" If BitAND($iFlag, 2) Then ConsoleWrite('If BitAND($iFlag, 2) Then = ' & BitAND($iFlag, 2) & @CRLF) ; The size of SECURITY_DESCRIPTOR is 20 bytes. We just ; need a block of memory the right size, we aren't going to ; access any members directly so it's not important what ; the members are, just that the total size is correct. Local $tSecurityDescriptor = DllStructCreate("byte;byte;word;ptr[4]") ; Initialize the security descriptor. Local $aCall = DllCall("advapi32.dll", "bool", "InitializeSecurityDescriptor", _ "struct*", $tSecurityDescriptor, "dword", $SECURITY_DESCRIPTOR_REVISION) If @error Then Return SetError(@error, @extended, 0) If $aCall[0] Then ; Add the NULL DACL specifying access to everybody. $aCall = DllCall("advapi32.dll", "bool", "SetSecurityDescriptorDacl", _ "struct*", $tSecurityDescriptor, "bool", 1, "ptr", 0, "bool", 0) If @error Then Return SetError(@error, @extended, 0) If $aCall[0] Then ; Create a SECURITY_ATTRIBUTES structure. $tSecurityAttributes = DllStructCreate($tagSECURITY_ATTRIBUTES) ; Assign the members. DllStructSetData($tSecurityAttributes, 1, DllStructGetSize($tSecurityAttributes)) DllStructSetData($tSecurityAttributes, 2, DllStructGetPtr($tSecurityDescriptor)) DllStructSetData($tSecurityAttributes, 3, 0) EndIf EndIf EndIf $hStartEvent = DllCall('kernel32.dll', 'handle', 'CreateSemaphoreW', 'struct*', $tSecurityAttributes, 'long', 0, 'long', 1, 'wstr', $sOccurrenceName) If @error Then Return SetError(@error, @extended, 0) Local $hError = DllCall("kernel32.dll", "dword", "GetLastError") If $hError[0] = $ERROR_ALREADY_EXISTS Then DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hStartEvent[0]) If @error Then Return SetError(@error, @extended, 0) If BitAND($iFlag, 1) Then Return SetError($hError[0], $hError[0], 0) Else Return 0 ; meh Exit -1 EndIf EndIf Return $hStartEvent[0] EndFunc ;==>_SingletonSemaphore give it a try. Parameters [in, optional] lpSemaphoreAttributes A pointer to a SECURITY_ATTRIBUTES structure. If this parameter is NULL, the handle cannot be inherited by child processes. ( https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-createsemaphorew )
  10. CreateMutexW, CreateFileMappingW, CreateSemaphoreW, they all have this $sOccurrenceName. Or maybe am missing something ?
  11. ..it is a pickle but, maybe a WinExists() or ProcessExists() serve as a _Singleton() of sorts ?, is just to not run it twice right ?
  12. See if this version ( https://www.autoitscript.com/forum/topic/211932-google-translation-with-gui/ ) works. If it does, use it as the base for yours. If it does not then try another PC ?, $objErr in my PC don't throw errors.
  13. Updated to the latest update ( 19045.5679 ) and can not replicate an issue.
  14. Not an issue, a feature. Otherwise one can run a malicious .ps1 without knowing. Shouldn't be used unless by the owner of the PC willingly does it. Safety first.
  15. OS Build: 19035.3570 as it came back then for 22H2. What is yours @KaFu ? Edit: am updating to the latest, will see.
×
×
  • Create New...