Leaderboard
Popular Content
Showing content with the highest reputation on 06/06/2020 in all areas
-
GUICtrlOnEvent - Set events without using OnEvent mode
argumentum reacted to MrCreatoR for a topic
This small UDF allows to set events for the controls without using GUIOnEventMode. Also the events function can accept parameters (actually one parameter, which can be an array). Remark: $WM_COMMAND registered by this UDF, so if you or other UDF uses this message, please call __GCSOEE_WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) from that message function to allow this UDF to work properly. Not relevant anymore. Example: #include <GUIConstantsEx.au3> #include 'GUICtrlOnEvent.au3' $hGUI = GUICreate('GUICtrlOnEvent Example', 300, 200) $iButton = GUICtrlCreateButton('Button', 20, 40, 60, 20) _GUICtrlOnEvent_SetEvent($iButton, _Events, 'Button Param') $iLabel = GUICtrlCreateLabel('Label', 20, 80, 60, 20) _GUICtrlOnEvent_SetEvent($iLabel, _Events, 'Label Param') $iInput = GUICtrlCreateInput('Input', 20, 120, 60, 20) _GUICtrlOnEvent_SetEvent($iInput, _Events, 'Input Param') Dim $aEventKeys[] = [$VK_LBUTTON, $VK_RETURN] _GUICtrlOnEvent_SetEventKeys($aEventKeys) GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _Events($hWnd, $iCtrlID, $vParam) Switch $iCtrlID Case $iButton MsgBox(64, $vParam, 'Clicked Button ID: ' & $iCtrlID, 0, $hWnd) Case $iLabel MsgBox(64, $vParam, 'Clicked Label ID: ' & $iCtrlID, 0, $hWnd) Case $iInput MsgBox(64, $vParam, 'Clicked Input ID: ' & $iCtrlID, 0, $hWnd) EndSwitch EndFunc GUICtrlSetOnEventEx.zip GUICtrlOnEvent_0.2.zip1 point -
GUICtrlOnEvent - Set events without using OnEvent mode
argumentum reacted to MrCreatoR for a topic
Update...1 point -
No, surprisingly not . Normally I always name the author(s) when mentioning sources, so that acknowledgements go to the right address. Since they are listed in the function headers, I assumed that would be sufficient. For reasons of politeness among programmers, here is the corresponding addendum : Author : @Ascend4nt , based on code by @KaFu , klaus.s1 point
-
Not Melbas solution (this timeđŸ¤£).1 point
-
How to get currently opened folder's path
argumentum reacted to kcvinu for a topic
@argumentum, It seems that, i can achieve my goal only with your single line code if i turn on "Display full path in title bar" option in folder options.1 point -
[Solved] Parent & Child GUIs and Input control fails
argumentum reacted to Melba23 for a topic
argumentum, You do realise that the child never actually appears? Why are you using the $WS_CHILD style when you are explicitly setting the parent parameter? M23 P.S. Family calls - back tomorrow.1 point -
How to get currently opened folder's path
argumentum reacted to kcvinu for a topic
@argumentum, Thanks a lot. It will give the active explorer window's title. Now, i can get the hWnd of active explorer window and tweak Melba's KaFu's & Ascend4nt's solution which @Musashi pointed.1 point -
It is already an older thread, but maybe it is what you are looking for : windows-explorer-current-folder Since links get lost sometimes, here for the sake of convenience the related code in a spoiler.1 point
-
Ping() issue
Earthshine reacted to TheDcoder for a topic
I see, that is interesting. I do the same, it works good enough when you follow safe practices. Not sure about MalwareBytes, I never used it.1 point -
Ping() issue
obiwanceleri reacted to Earthshine for a topic
Really? I dropped eset ys ago due to all it’s windows issues. It’s garbage. Use windows built-in defender and that’s all you need maybe Malwarebytes in addition1 point -
Here another approach to check if a script was already started using atoms and semaphores. Atom: #include <MsgBoxConstants.au3> Global $iSingleton = Singleton() If Not $iSingleton Then Exit MsgBox($MB_TOPMOST, "Singleton Test", "Process is already running!") EndIf MsgBox($MB_TOPMOST, "Singleton Test", "Singleton atom initialized: " & $iSingleton) Singleton_Delete($iSingleton) ; #FUNCTION# ==================================================================================================================== ; Name ..........: Singleton ; Description ...: Checks if the script has been started already. ; Syntax ........: Singleton([$sOccurrenceName = @ScriptFullPath]) ; Parameters ....: $sOccurrenceName - [optional] a string value. Default is @ScriptFullPath. ; Return values .: If the function succeeds, the return value is the newly created atom or 0 else error is set and false is returned. ; Author ........: UEZ ; Modified ......: ; Remarks .......: If Singleton finds the atom it will return 0 and the atom token will be set to extended macro. It can be used to get the atom string using _WinAPI_AtomGlobalGetName. ; Related .......: ; Link ..........: https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-globalfindatomw ; https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-globaladdatomw ; Example .......: No ; =============================================================================================================================== Func Singleton($sOccurrenceName = @ScriptFullPath) Local $iFind = _WinAPI_AtomGlobalFind($sOccurrenceName) If @error Then Return SetError(1, 0, False) If $iFind Then Return SetExtended($iFind, 0) Local $iAtom = _WinAPI_AtomGlobalAdd($sOccurrenceName) If @error Then Return SetError(2, 0, False) Return $iAtom EndFunc ;==>Singleton ; #FUNCTION# ==================================================================================================================== ; Name ..........: Singleton_Delete ; Description ...: Deletes the atom generated by the first started script. ; Syntax ........: Singleton_Delete($iAtom) ; Parameters ....: $iAtom - an integer value which was generated by Singleton ; Return values .: True if successful else false. ; Author ........: UEZ ; Modified ......: ; Remarks .......: Don't forget to call Singleton_Delete before first started script ends. ; Related .......: ; Link ..........: https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-globaldeleteatom ; Example .......: No ; =============================================================================================================================== Func Singleton_Delete($iAtom) _WinAPI_AtomGlobalDelete($iAtom) If @error Then Return SetError(1, 0, False) Return True EndFunc ;==>Singleton_Delete ;internal functions Func _WinAPI_AtomGlobalFind($sAtomString) Local $aReturn = DllCall("kernel32.dll", "short", "GlobalFindAtomW", "wstr", $sAtomString) If @error Then Return SetError(1, 0, -1) Return $aReturn[0] EndFunc ;==>_WinAPI_AtomGlobalFind Func _WinAPI_AtomGlobalAdd($sAtomString) Local $aReturn = DllCall("kernel32.dll", "short", "GlobalAddAtomW", "wstr", $sAtomString) If @error Then Return SetError(1, 0, -1) Return $aReturn[0] EndFunc ;==>_WinAPI_AtomGlobalAdd Func _WinAPI_AtomGlobalDelete($nAtom) Local $aReturn = DllCall("kernel32.dll", "short", "GlobalDeleteAtom", "short", $nAtom) If @error Then Return SetError(1, 0, -1) Return $aReturn[0] = 0 EndFunc ;==>_WinAPI_AtomGlobalDelete Func _WinAPI_AtomGlobalGetName($nAtom, $iBufferSize = 512) Local $tBufferAtom = DllStructCreate("wchar name[" & $iBufferSize & "]") Local $aReturn = DllCall("kernel32.dll", "uint", "GlobalGetAtomNameW", "short", $nAtom, "struct*", $tBufferAtom, "int", $iBufferSize) If @error Or Not $aReturn[0] Then Return SetError(1, 0, -1) Return $tBufferAtom.name EndFunc ;==>_WinAPI_AtomGlobalGetName Semaphore: #include <MsgBoxConstants.au3> #include <WinAPIError.au3> Global $iSingleton = Singleton("&]8h/x87</htFV4-K*&.b.w~") If Not $iSingleton Then Exit MsgBox($MB_TOPMOST, "Singleton Test", "Process is already running!") EndIf MsgBox($MB_TOPMOST, "Singleton Test", "Singleton Semaphore initialized: " & $iSingleton) ; #FUNCTION# ==================================================================================================================== ; Name ..........: Singleton ; Description ...: Checks if the script has been started already. ; Syntax ........: Singleton($sOccurrenceName) ; Parameters ....: $sOccurrenceName - a string value which will be used to create the semaphore handle. ; Return values .: True if Singleton started the first time. False if script was already started ; Author ........: UEZ ; Modified ......: ; Remarks .......: The system closes the handle automatically when the process terminates. The semaphore object is destroyed when its last handle has been closed. ; Related .......: ; Link ..........: https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createsemaphorea ; Example .......: No ; =============================================================================================================================== Func Singleton($sOccurrenceName) If StringLen($sOccurrenceName) > 260 Then $sOccurrenceName = StringLeft($sOccurrenceName, 260) Local $aReturn = DllCall("kernel32.dll", "handle", "CreateSemaphoreA", "ptr", Null, "long", 0, "long", 1, "str", $sOccurrenceName) If @error Or Not $aReturn[0] Then Return SetError(1, 0, -1) Return SetExtended($aReturn[0], $aReturn[0] And _WinAPI_GetLastErrorMessage() = "The operation completed successfully.") EndFunc ;==>Singleton Just start the script twice to see if it works. The disadvantage of using atoms is that atoms have a memory that means when your app is crashing or you forgot to delete the atom then the atom does still have the $sOccurrenceName saved and thus Singleton will not work if you use the same same value for $sOccurrenceName. With semaphore you don't have this issue. Thanks to jj2007 and SARG.1 point