Leaderboard
Popular Content
Showing content with the highest reputation on 12/03/2024 in all areas
-
Visit a Dentist?2 points
-
it's snowing.... #include <WindowsConstants.au3> #include <WINAPI.au3> Local $isnowflakes = 500 ; number of snowflakes Local $iMinR = 5 ; minimum length of the snowflake's side Local $iMaxR = 8 ; max length Local $aSnow[$isnowflakes][5] Local $AlphaKey = 0xABABAB, $hBackground = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUPWINDOW, $WS_EX_LAYERED + $WS_EX_TOPMOST) GUISetBkColor($AlphaKey, $hBackground) _WinAPI_SetLayeredWindowAttributes($hBackground, $AlphaKey, 0, $LWA_COLORKEY) GUISetState(@SW_SHOW, $hBackground) For $i = 0 To UBound($aSnow) - 1 _Randomize($aSnow, $i, $iMinR, $iMaxR) $aSnow[$i][3] = GUICtrlCreateLabel("", $aSnow[$i][1], $aSnow[$i][2], $aSnow[$i][0], $aSnow[$i][0]) GUICtrlSetBkColor(-1, 16777215) ; snow white Next While 1 For $i = 0 To UBound($aSnow) - 1 $aSnow[$i][2] += $aSnow[$i][4] ; increment y pos GUICtrlSetPos($aSnow[$i][3], $aSnow[$i][1], $aSnow[$i][2]) If $aSnow[$i][2] > @DesktopHeight Then _Randomize($aSnow, $i, $iMinR, $iMaxR) GUICtrlSetPos($aSnow[$i][3], $aSnow[$i][1], $aSnow[$i][2], $aSnow[$i][0], $aSnow[$i][0]) EndIf Next WEnd Func _Randomize(ByRef $aSnow, $i, $iMinR, $iMaxR) $aSnow[$i][0] = Random($iMinR, $iMaxR, 0) ; dimension of snow $aSnow[$i][1] = Random(0 - $iMaxR, @DesktopWidth + $iMaxR, 0) ; x position $aSnow[$i][2] = 0 - $iMaxR ; y position (out of screen at startup) $aSnow[$i][4] = Random(0.1, $iMaxR * 3) EndFunc ;==>_Randomize1 point
-
RegEx a function with its parameters
argumentum reacted to donnyh13 for a topic
Modifying the variable Case (Line 98~) from $asMatch = StringRegExp($sLine, "(^\$[\w\[\]]*[\s]*)", $STR_REGEXPARRAYMATCH) ; can be broken with spaces in array brackets $aArray[ 0] To $asMatch = StringRegExp($sLine, "(^\$[\w]*[\s]*)", $STR_REGEXPARRAYMATCH) I think will fix it.1 point -
RegEx a function with its parameters
argumentum reacted to donnyh13 for a topic
Okay, It still processes correctly, but throws a warning, "> Encountered an unexpected character, trimming it off: ]" Try this ; it will still process, but ... not processing under the correct section (as a variable), but probably in pieces? Could cause unexpected behaviour? Global $aArray[1] = [10] ConsoleWriteDebug($aArray[ 0]) ; add @ScriptLineNumber Could use improving to prevent that probably. Will have to think on solutions.1 point -
RegEx a function with its parameters
donnyh13 reacted to argumentum for a topic
Found the "If ConsoleWriteDebug is commented out, but the comment mark (;) is not the first Character (besides whitespaces)." Could not find the "A parameter contains an Array variable with spaces in the element $aArray[ 0]" Knowing how to brake it, lets me know what not to do. Can you show how to brake it ? Just a line is all I need1 point -
I started on this before you found your above solution, but never had time to finish. I thought I might as well share it now since I completed it. It’s a bit more complex looking than yours, and can also be broken a few different ways. But it does works for the examples you posted, here it is. #include <StringConstants.au3> ; looking to discern the parameters with RegExp ConsoleWriteDebug(anyFunc(' ''1''', "2""", @ScriptLineNumber) & @CRLF) ; add @ScriptLineNumber ConsoleWriteDebug('This, is'' a string' & @CRLF) ; add @ScriptLineNumber ConsoleWriteDebug("This, is' a string" & @CRLF) ; add @ScriptLineNumber ConsoleWriteDebug('This, is'' a string' & @CRLF, @ScriptLineNumber) ; don't add @ScriptLineNumber ConsoleWriteDebug("This, is' a string" & @CRLF, 88, 1, 2) ; don't add @ScriptLineNumber ;~ ConsoleWriteDebug("This is' a string" & @CRLF, @ScriptLineNumber, 1, 2) ; don't touch Global $sString = "This is' a string" ConsoleWriteDebug($sString & @CRLF, @ScriptLineNumber) ; don't add @ScriptLineNumber ConsoleWriteDebug($sString, @ScriptLineNumber) ; don't add @ScriptLineNumber ConsoleWriteDebug($sString) ; ConsoleWriteDebug(anyFunc(anyFunc(' ''1''', "2""", @ScriptLineNumber), "2""", @ScriptLineNumber) & @CRLF) ; add @ScriptLineNumber ConsoleWriteDebug("10", "2") ; add @ScriptLineNumber ConsoleWriteDebug(-1, "2") ; add @ScriptLineNumber anyFunc(ConsoleWriteDebug("10")) ; add @ScriptLineNumber ;~ ConsoleWriteDebug("This is' a string" & @CRLF, 123, 1, 2) ; don't touch ConsoleWrite(_Add_ScriptLineNumber(FileRead(@ScriptFullPath)) & @CRLF) Func _Add_ScriptLineNumber($sScript, $sFuncName = "ConsoleWriteDebug", $iAddAtParameterNumber = 2) Local $sFixedScript = "", $sLine, $sAddCRLF = @CRLF, $sEmptyAddParam = '""' Local $asScript[0], $asMatch[0] Local Const $iQuoteChar = 34 Local $iParam = 1, $iFuncLevel = 1, $iLine = 0 ConsoleWrite("> =========== BEGINNING ===========" & @CRLF) $asScript = StringSplit($sScript, @CRLF, $STR_ENTIRESPLIT) For $i = 1 To $asScript[0] $sLine = $asScript[$i] $iLine += 1 If ($i = $asScript[0]) Then $sAddCRLF = "" If StringRegExp($sLine, "\Q" & $sFuncName & "\E\(") And Not StringRegExp($sLine, "^(?:[\s]*;|[\s]*\b[fF][uU][nN][cC]\b[ ]|[\s]*\b[eE][nN][dD][fF][uU][nN][cC]\b[ ])") Then ; If function is in the line, and not commented out, and not the Func declaration itself. $iParam = 1 $iFuncLevel = 1 $asMatch = StringRegExp($sLine, ".*\Q" & $sFuncName & "\E\([/s]*", $STR_REGEXPARRAYMATCH) _AddLine($sFixedScript, $sLine, $asMatch, $iLine, $sAddCRLF) Do If ($iParam = $iAddAtParameterNumber) And ($iFuncLevel = 1) Then If StringRegExp($sLine, "^[\d]") Then ; Raw digit in position. $asMatch = StringRegExp($sLine, "^[\d]*", $STR_REGEXPARRAYMATCH) If IsArray($asMatch) And ($iLine <> $asMatch[0]) Then ConsoleWrite("! Line " & $iLine & ", Raw line number is incorrect! Current = " & $asMatch[0] & "; Should be: " & $iLine & @CRLF) ElseIf StringRegExp($sLine, "^\Q@ScriptLineNumber\E") Then ; @ScriptLineNumber in position, do nothing. Else $asMatch = StringRegExp($sLine, "^.+?(?:\)|,)", $STR_REGEXPARRAYMATCH) ; Retrieve data to next comma or end parenthesis. If IsArray($asMatch) Then If StringRegExp($asMatch[0], "[^\d\), " & Chr($iQuoteChar) & "]") Then ; See if parameter contains anything other than digits, quotes and/or spaces. ConsoleWrite("- Line " & $iLine & ", Encountered parameter not containing @ScriptLineNumber and no line number alone:" & @TAB & $sLine & @CRLF) ElseIf StringRegExp($asMatch[0], "[\d]") Then ; See if parameter contains digits. $asMatch = StringRegExp($sLine, "[\d]+", $STR_REGEXPARRAYMATCH) If IsArray($asMatch) And ($iLine <> $asMatch[0]) Then ConsoleWrite("! Line " & $iLine & ", Raw quoted line number is incorrect! Current = " & $asMatch[0] & "; Should be: " & $iLine & @CRLF) ElseIf Not StringRegExp($asMatch[0], "\Q@ScriptLineNumber\E") Then ConsoleWrite("- Line " & $iLine & ", Encountered parameter not containing @ScriptLineNumber:" & @TAB & $sLine & @CRLF) Else ConsoleWrite("- Line " & $iLine & ", Encountered unknown parameter in @ScriptLineNumber position:" & @TAB & $sLine & @CRLF) EndIf EndIf EndIf $sFixedScript &= $sLine & $sAddCRLF ExitLoop EndIf Select Case StringRegExp($sLine, "^[a-zA-Z_]") ; A function as it starts with a letter or underscore. $asMatch = StringRegExp($sLine, "^[\w]+\(?[ ]*", $STR_REGEXPARRAYMATCH) _AddLine($sFixedScript, $sLine, $asMatch, $iLine, $sAddCRLF) $iFuncLevel += 1 ; Show I am in a function in a Parameter, and not the main ConsoleWriteDebug function. Case StringRegExp($sLine, "^[\[\(]") ; A Bracket. $asMatch = StringRegExp($sLine, "^((?:\(.+?\)|\[.+?\])[\s]*)", $STR_REGEXPARRAYMATCH) _AddLine($sFixedScript, $sLine, $asMatch, $iLine, $sAddCRLF) ;~ Case StringRegExp($sLine, "^\$") ; A Variable. ; $asMatch = StringRegExp($sLine, "(^\$[\w\[\]]*[\s]*)", $STR_REGEXPARRAYMATCH) ; can be broken with spaces in array brackets $aArray[ 0] $asMatch = StringRegExp($sLine, "(^\$[\w]*[\s]*)", $STR_REGEXPARRAYMATCH) _AddLine($sFixedScript, $sLine, $asMatch, $iLine, $sAddCRLF) Case StringRegExp($sLine, "^['" & Chr($iQuoteChar) & "]") ; A String. $asMatch = StringRegExp($sLine, "^((?:'.*?'|" & Chr($iQuoteChar) & ".*?" & Chr($iQuoteChar) & ")[\s]*)", $STR_REGEXPARRAYMATCH) _AddLine($sFixedScript, $sLine, $asMatch, $iLine, $sAddCRLF) Case StringRegExp($sLine, "^[@&]") ; A Macro or joiner. $asMatch = StringRegExp($sLine, "^((?:@|&)[\w]*[\s]*)", $STR_REGEXPARRAYMATCH) _AddLine($sFixedScript, $sLine, $asMatch, $iLine, $sAddCRLF) Case StringRegExp($sLine, "^[\-\d]") ; A digit, including a negative. $asMatch = StringRegExp($sLine, "^([\-\d,\.]+[\s]*)", $STR_REGEXPARRAYMATCH) _AddLine($sFixedScript, $sLine, $asMatch, $iLine, $sAddCRLF) Case StringRegExp($sLine, "^\)") ; An ending parenthesis. If ($iFuncLevel = 1) Then ; I'm in the main ConsoleWriteDebug function, determine if I need to add @ScriptLineNumber. Else I'm in a function in a function, just decrease count and process. If ($iParam < ($iAddAtParameterNumber - 1)) Then ; Minus 1 to compensate for @ScriptLineNumber parameter being added. While ($iParam < ($iAddAtParameterNumber - 1)) ; If Parameter to fill in @ScriptLineNumber isn't current one, add blanks $sFixedScript &= ", " & $sEmptyAddParam $iParam += 1 WEnd EndIf ConsoleWrite("- Adding @ScriptLineNumber to line: " & $iLine & @CRLF) $sFixedScript &= ", " & "@ScriptLineNumber" & $sLine & $sAddCRLF ExitLoop Else $iFuncLevel -= 1 $asMatch = StringRegExp($sLine, "^\)[\s]*", $STR_REGEXPARRAYMATCH) _AddLine($sFixedScript, $sLine, $asMatch, $iLine, $sAddCRLF) EndIf Case StringRegExp($sLine, "^,") ; A comma. If ($iFuncLevel = 1) Then $iParam += 1 ; I'm in the main ConsoleWriteDebug function, increase Parameter count. Else I'm in a function in a function, just process. $asMatch = StringRegExp($sLine, "^,[\s]*", $STR_REGEXPARRAYMATCH) _AddLine($sFixedScript, $sLine, $asMatch, $iLine, $sAddCRLF) Case Else ; Unexpected character, trim one off ConsoleWrite("> Encountered an unexpected character, trimming it off: " & StringLeft($sLine, 1) & @CRLF) $sFixedScript &= StringLeft($sLine, 1) ; add the removed character to the script string. $sLine = StringTrimLeft($sLine, 1) $asMatch = StringRegExp($sLine, "^[\s]*", $STR_REGEXPARRAYMATCH) ; Remove any white space. _AddLine($sFixedScript, $sLine, $asMatch, $iLine, $sAddCRLF) EndSelect Until $sLine = "" Else ; Just copy the line. $sFixedScript &= $sLine & $sAddCRLF EndIf Next ConsoleWrite("+ =========== FINISHED ===========" & @CRLF) Return $sFixedScript ; with the added ", @ScriptLineNumber)" where needed EndFunc ;==>_Add_ScriptLineNumber Func _AddLine(ByRef $sFixedScript, ByRef $sLine, ByRef $asArray, $iLine, $sAddCRLF) If Not IsArray($asArray) Then ConsoleWrite("! Identification failed on line: " & $iLine & " Skipping" & @CRLF) $sFixedScript &= $sLine & $sAddCRLF $sLine = "" Else $sFixedScript &= $asArray[0] ; add the beginning of the string to the script string. $sLine = StringTrimLeft($sLine, StringLen($asArray[0])) EndIf EndFunc ;==>_AddLine Func ConsoleWriteDebug($sStr = @CRLF, $iLine = @ScriptLineNumber, $iError = @error, $iExtended = @extended) Local $iRet = ConsoleWrite("@@ Debug (" & $iLine & ") : " & $sStr & (StringRight($sStr, 2) = @CRLF ? "" : @CRLF)) Return SetError($iError, $iExtended, $iRet) ; https://www.autoitscript.com/forum/topic/139260-autoit-snippets/?do=findComment&comment=1538974 EndFunc ;==>ConsoleWriteDebug Func anyFunc($1 = "", $2 = "", $3 = "") Return 'anyFunc' & $1 & $2 & $3 EndFunc ;==>anyFunc Can be broken if: A parameter contains an Array variable with spaces in the element $aArray[ 0] [Modified above script with a fix If ConsoleWriteDebug is commented out, but the comment mark (;) is not the first Character (besides whitespaces). Benefits: Works when ConsoleWriteDebug is nested. Works when functions in ConsoleWriteDebug are nested, i.e. ConsoleWriteDebug(anyFunc(anyFunc( Checks for accuracy raw line numbers. Can place @ScriptLineNumber in different Parameter place, filling in skipped parameters with a predesignated string. Maybe it will give some options.1 point
-
WM_COPYDATA return
bladem2003 reacted to Nine for a topic
@bladem2003 You may want to try my UDF here1 point -
GUISetHelp Placement
pixelsearch reacted to ioa747 for a topic
or you could take this approach, where things have their place ;~ ----------------------------------------------- #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> ; ----------------------------------------------- Global $hGUI = GUICreate("Title", 220, 75) ; ----------------------------------------------- ; COLUMN 1 BUTTONS Global $_sCol1Row1 = GUICtrlCreateButton("Item 1", 10, 10, 200, 25) Global $_sCol1Row2 = GUICtrlCreateButton("Item 1", 10, 40, 200, 25) Global $idUserDocs = GUICtrlCreateDummy() ; ----------------------------------------------- Local $aAccelKeys[1][2] = [["{F1}", $idUserDocs]] GUISetAccelerators($aAccelKeys) ; ----------------------------------------------- GUISetState(@SW_SHOW, $hGUI) ; ----------------------------------------------- While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit ; ----------------- ; COLUMN 1 BUTTONS Case $_sCol1Row1 _MyFunction1() Case $_sCol1Row2 _MyFunction2() Case $idUserDocs _UserDocs() EndSwitch WEnd ; ----------------------------------------------- ; COLUMN 1 BUTTONS ; ----------------------------------------------- Func _MyFunction1() MsgBox(0, "", "Inside _MyFunction1") EndFunc ;==>_MyFunction1 ; ----------------------------------------------- Func _MyFunction2() MsgBox(0, "", "Inside _MyFunction2") EndFunc ;==>_MyFunction2 ; ----------------------------------------------- Func _UserDocs() Local $sPdfProgram = "C:\Program Files (x86)\FoxitReader\Foxit Reader.exe" Local $sPdfFile = "C:\Working\TestMe.pdf" ; ----------------------------------------------- ShellExecute($sPdfProgram, $sPdfFile) EndFunc ;==>_UserDocs ; -----------------------------------------------1 point -
RegEx a function with its parameters
donnyh13 reacted to argumentum for a topic
...I update a lot. Please refresh the page every so often if replying .1 point -
Could you try this one, I think I have found a better way to remove topmost to the magnifier in a more efficient way : #include <WindowsConstants.au3> #include "WinMagnifier.au3" _MagnifierInit() Run("Notepad") Sleep(100) Local $hWnd = WinGetHandle("[CLASS:Notepad]"), $aPos[4], $aPosTmp[4] WinGetPosEx($hWnd, $aPos) Local $aHndl = _MagnifierGUICreate($aPos[2], $aPos[3], $aPos[0], $aPos[1]), $hMagnifyGUI = $aHndl[0], $hMagnifyCtrl = $aHndl[1] GUISetState(@SW_SHOWNOACTIVATE, $hMagnifyGUI) _MagnifierSetSource($hMagnifyCtrl, $aPos[0], $aPos[1], $aPos[2], $aPos[3]) _MagnifierSetColorEffect($hMagnifyCtrl, $COLOR_EFFECTS_INVERSION_MATRIX) While WinExists($hWnd) Sleep(10) If WinActive($hWnd) Or _WinAPI_GetParent(WinGetHandle("[ACTIVE]")) = $hWnd Then If Not BitAND(WinGetState($hMagnifyGUI), $WIN_STATE_VISIBLE) Then GUISetState(@SW_SHOWNOACTIVATE, $hMagnifyGUI) WinGetPosEx($hWnd, $aPosTmp) If $aPos[0] <> $aPosTmp[0] Or $aPos[1] <> $aPosTmp[1] Or $aPos[2] <> $aPosTmp[2] Or $aPos[3] <> $aPosTmp[3] Then $aPos = $aPosTmp WinMove($hMagnifyGUI, "", $aPos[0], $aPos[1], $aPos[2], $aPos[3]) _WinAPI_MoveWindow($hMagnifyCtrl, 0, 0, $aPos[2], $aPos[3], False) _MagnifierSetSource($hMagnifyCtrl, $aPos[0], $aPos[1], $aPos[2], $aPos[3]) EndIf WinSetOnTop($hMagnifyGUI, "", $WINDOWS_ONTOP) _WinAPI_RedrawWindow($hMagnifyCtrl) ElseIf Not BitAND(WinGetState($hWnd), $WIN_STATE_MINIMIZED) Then If BitAND(_WinAPI_GetWindowLong($hMagnifyGUI, $GWL_EXSTYLE), $WS_EX_TOPMOST) Then _WinAPI_SetWindowPos($hMagnifyGUI, WinGetHandle("[ACTIVE]"), 0, 0, 0, 0, $SWP_NOMOVE + $SWP_NOSIZE + $SWP_SHOWWINDOW) EndIf ElseIf BitAND(WinGetState($hMagnifyGUI), $WIN_STATE_VISIBLE) Then GUISetState(@SW_HIDE, $hMagnifyGUI) EndIf WEnd _WinAPI_DestroyWindow($hMagnifyCtrl) GUIDelete($hMagnifyGUI) Func WinGetPosEx($hWnd, ByRef $aPos) Local $aTmp = WinGetPos($hWnd) If @error Then Return $aPos = $aTmp ; adjust magnifier to the edge of the window $aPos[0] += 8 $aPos[1] += 1 $aPos[2] -= 16 $aPos[3] -= 9 EndFunc1 point