Leaderboard
Popular Content
Showing content with the highest reputation on 05/26/2015 in all areas
-
Advanced Math UDF
robertocm reacted to scintilla4evr for a topic
I started writing this UDF a while ago, so I decided to share it here. This is an UDF full of advanced mathematical functions. It allows to work with primes, create number sequences, interpolate, calculate values of functions like Riemann zeta. Full list of functions: Changelog: Download1 point -
This is a visual Crop Tool, Version 1.0.0.5 Load the image in the Crop GUIMove the cross-hair to the upper left corner where to start croppingMark the rectangle with left mouse button, releaseAdjust the position with left mouse, release (right mouse = start over)Press enterImage is saved in same folder, same format, with '_cr' added to file nameAs simple as that. Updated script, Visual Crop UDF 1.0.0.4 examples.au3 Visual Crop UDF 1.0.0.4.au3 (No obscuration of non-selected area) Visual Crop UDF 1.0.0.5.au3 (with obscuration) Ver 1.0.0.1 Avoid trespassing the edge of the GUI while selecting the crop area.Ver 1.0.0.4 Mark crop area in any directionResizing Corner grabbers (use with Ctrl Left Mouse button)Mouse cursor changes over move and resizing corner grabbersRedraw when left mouse clicking outside of crop area (restart crop), right Mouse click, same result.Magnifier de-/selectable with Ctrl-M or F2. (original function by Melba23) Note: without image ratio: Magnifier remains visible till the crop area has been marked with image ratio: Magnifier is only visible until the rectangle appears, first corner has been marked. Ver 1.0.0.5 Obscure non crop area, did some hard thinking and found my way... Missing still: ?Enjoy GreenCan Related:1 point
-
_GetPrime() returns larger primes, 300 digits+
BinaryBrother reacted to jchd for a topic
Welcome to the wonderful world of crypto-size arithmetic and number theory! Kid sister secrecy and strong crypto are indeed different worlds, needing different tools and once in strong crypto realm, you lose common sense due to the incredible size of numbers you need to manipulate, even it seems so easy to talk about 500-digit (or more) numbers. Unfortunately with have at our disposal notations which hide the groundplay we are on: writing 10^50000 is easily understandable (even AutoIt deals with it with BigNum) but actually getting some grasp of what we're talking about is a completely different beast. Say, how many primes betwwen 10^50000 and 10.1^50000 seems a reasonable question at first. At first only, because you just can't give an exact answer to it and the best approximation you come up with is itself something ous brain can't fully realize! Whatever common sense tells you about small samples often becomes a solid concrete block once in the vicinity of 1024-bit values, or beyond. Things as simple as enumerating integers seem overly simple for values you can count instictively (up to 5 in general), still you can manage more with a computer and typical For loops, but with crypto-size numbers you lose control of the consequences of what intuition had told you over years. That was the whole point of the funny quote and the reason why it went thru to us today. Not only the number of hydrogen atoms in our own universe is way beyond common sense, but it itsself reveals sooo ridiculously negligible in face of crypto-size quantities and number-theoretic properties. All of this tells you something: only theory built on solid grounds allows you to assert things about numbers when you let them reach really large values.1 point -
asakust, Glad I could help. M231 point
-
Large Prime Numbers
BinaryBrother reacted to jchd for a topic
And then? Just ask if you need more, there is ample supply! (<-- read the other post I just made)1 point -
Regex expression
Alexxander reacted to Melba23 for a topic
Alexxander, This seems to work quite well: #include <Array.au3> $sText = "Geek - Smarter Shopping 1.1.5" & @CRLF & _ "Soccer Stars 1.4.3" & @CRLF & _ "Rock Hero 1.1.3" & @CRLF & _ "Pinterest 4.6.1" & @CRLF & _ "Winter Craft 3: Mine Build 1.1.5" & @CRLF & _ "Flick Shoot 2 1.25" $aRet = StringRegExp($sText, "(?mU)^(.*)([\d.]*)$", 3) _ArrayDisplay($aRet, "", Default, 8)SRE decode: (?mU) - Treat all lines as separate strings - look for shortest match ^ - Start of the line (.*) - Capture all characters up until the next group ([\d.]*) - Capture any group made up of digita and dots until... $ - the end of the lineNo doubt a real guru will be along shortly with a better answer. M231 point -
asakust, Check the order of the parameters for StringFormat - you might find it works better if you get them the right way round. But you might get .99999999999 returned and so I would not recommend that method. If you are working with cash, why not convert everything to cents/pence/lowest and do all the maths on integers, reconverting at the end? M231 point
-
Managing AutoIT Window and font size VS Windows Display 125%/150%
OhBobSaget reacted to UEZ for a topic
This might help you: https://www.autoitscript.com/forum/topic/166479-writing-dpi-awareness-app-workaround/1 point -
Well it's going to be a nightmare figuring out what's going on with simple sort, as it moves selection and focus around. Instead I just quickly implemented a string sort of the items that doesn't require registering. #include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <StructureConstants.au3> $GUI = GUICreate("Listview Custom Draw", 400, 300) $cListView = GUICtrlCreateListView("Column 1|Column 2|Column 3", 2, 2, 394, 268, -1, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) $hListView = GUICtrlGetHandle($cListView) ; Add items For $i = 1 To 30 GUICtrlCreateListViewItem("Row" & $i & ": Col 1|Row" & $i & ": Col 2|Row" & $i & ": Col 3", $cListView) Next GUICtrlCreateInput("Click here to test focus", 50, 275, 200, 18) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Exit Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListView Switch $iCode Case $NM_CUSTOMDRAW If _GUICtrlListView_GetView($hWndFrom) <> 1 Then Return $GUI_RUNDEFMSG ; Not in details mode Local $tCustDraw, $iDrawStage, $iItem, $iSubitem, $hDC, $tRect, $iColor1, $iColor2, $iColor3 $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) $iDrawStage = DllStructGetData($tCustDraw, 'dwDrawStage') Switch $iDrawStage Case $CDDS_PREPAINT Return $CDRF_NOTIFYITEMDRAW Case $CDDS_ITEMPREPAINT Return $CDRF_NOTIFYSUBITEMDRAW Case $CDDS_ITEMPOSTPAINT ; Not handled Case BitOR($CDDS_ITEMPREPAINT, $CDDS_SUBITEM) $iItem = DllStructGetData($tCustDraw, 'dwItemSpec') $iSubitem = DllStructGetData($tCustDraw, 'iSubItem') If _GUICtrlListView_GetItemSelected($hWndFrom, $iItem) Then ; Item to draw is selected $hDC = _WinAPI_GetDC($hWndFrom) $tRect = DllStructCreate($tagRECT) ; We draw the background when we draw the first item. If $iSubitem = 0 Then ; We must send the message as we want to use the struct. _GUICtrlListView_GetSubItemRect returns an array. _SendMessage($hWndFrom, $LVM_GETSUBITEMRECT, $iItem, DllStructGetPtr($tRect)) DllStructSetData($tRect, "Left", 2) _WinAPI_FillRect($hDC, DllStructGetPtr($tRect), _WinAPI_GetStockObject($GRAY_BRUSH)) ; Change the bush here. You can use GDI+ to make your own. EndIf DllStructSetData($tRect, "Left", 2) DllStructSetData($tRect, "Top", $iSubitem) _SendMessage($hWndFrom, $LVM_GETSUBITEMRECT, $iItem, DllStructGetPtr($tRect)) Local $sText = _GUICtrlListView_GetItemText($hWndFrom, $iItem, $iSubitem) _WinAPI_SetBkMode($hDC, $TRANSPARENT) ; It uses the background drawn for the first item. ; Select the font we want to use _WinAPI_SelectObject($hDC, _SendMessage($hWndFrom, $WM_GETFONT)) If $iSubitem = 0 Then DllStructSetData($tRect, "Left", DllStructGetData($tRect, "Left") + 2) Else DllStructSetData($tRect, "Left", DllStructGetData($tRect, "Left") + 6) EndIf _WinAPI_DrawText($hDC, $sText, $tRect, BitOR($DT_VCENTER, $DT_END_ELLIPSIS, $DT_SINGLELINE)) _WinAPI_ReleaseDC($hWndFrom, $hDC) Return $CDRF_SKIPDEFAULT ; Don't do default processing EndIf Return $CDRF_NEWFONT ; Let the system do the drawing for non-selected items Case BitOR($CDDS_ITEMPOSTPAINT, $CDDS_SUBITEM) ; Not handled EndSwitch Case $LVN_COLUMNCLICK $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam) $iCol = DllStructGetData($tInfo, "SubItem") $hHdr = _GUICtrlListView_GetHeader($hWndFrom) ; Work out sort from arrows in header, and clear other arrows $fSort = True For $i = 0 To _GUICtrlHeader_GetItemCount($hHdr) $iFmt = _GUICtrlHeader_GetItemFormat($hHdr, $i) If $i = $iCol Then If BitAND($iFmt, $HDF_SORTUP) Then $fSort = True $iFmt = BitOR(BitAND($iFmt, BitNOT($HDF_SORTUP)), $HDF_SORTDOWN) ElseIf BitAND($iFmt, $HDF_SORTDOWN) Then $fSort = False $iFmt = BitOR(BitAND($iFmt, BitNOT($HDF_SORTDOWN)), $HDF_SORTUP) Else ; Default $iFmt = BitOR(BitAND($iFmt, BitNOT($HDF_SORTUP)), $HDF_SORTDOWN) $fSort = True EndIf _GUICtrlHeader_SetItemFormat($hHdr, $i, $iFmt) Else $iFmt = BitAND($iFmt, BitNOT(BitOR($HDF_SORTUP, $HDF_SORTDOWN))) _GUICtrlHeader_SetItemFormat($hHdr, $i, $iFmt) EndIf Next $tInfo = DllStructCreate("HWND;int;int") DllStructSetData($tInfo, 1, $hWndFrom) DllStructSetData($tInfo, 2, $fSort) DllStructSetData($tInfo, 3, $iCol) $cb = DllCallbackRegister(__Compare, "int", "LPARAM;LPARAM;LPARAM") _SendMessage($hWndFrom, $LVM_SORTITEMSEX, DllStructGetPtr($tInfo), DllCallbackGetPtr($cb)) DllCallbackFree($cb) Return True EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY ; int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort); Func __Compare($nItem1, $nItem2, $lParamSort) Local $tInfo = DllStructCreate("HWND;int;int", $lParamSort) Local $hWndFrom = DllStructGetData($tInfo, 1) Local $fSort = DllStructGetData($tInfo, 2) Local $iCol = DllStructGetData($tInfo, 3) Local $s1 = _GUICtrlListView_GetItemText($hWndFrom, $nItem1, $iCol) Local $s2 = _GUICtrlListView_GetItemText($hWndFrom, $nItem2, $iCol) Return StringCompare($s1, $s2) * ($fSort ? -1 : 1) EndFunc ;==>__Compare This seems to work fine with the custom drawing code.1 point
-
The regex pattern modifier for multiline is your friend: (?m) #include <Array.au3> $fileContent = "This is the first line." $fileContent = $fileContent & "Something something, blah, DescriptionAA1111AA111, and another thing." & @CRLF $fileContent = $fileContent & "06:52:16 this line starts with a valid timestamp" & @CRLF $fileContent = $fileContent & "24:01:01 this line doesn't start with a valid timestamp" & @CRLF $fileContent = $fileContent & "00:00:00 this line also starts with a valid timestamp" & @CRLF $fileContent = $fileContent & "23:59:59 just like this one, which also has a description thingy: DescriptionZZ1234zz123" & @CRLF $fileContent = $fileContent & "This is a bonus line." $fileContent = $fileContent & "DescriptionXy1111aB111, aaaaaand it's gone." & @CRLF $aTimestampLines = StringRegExp($fileContent, "(?m)^((?:0\d|1\d|2[0-3]):[0-5]\d:[0-5]\d .*)$", $STR_REGEXPARRAYGLOBALMATCH ) _ArrayDisplay($aTimestampLines) $aDescriptionLines = StringRegExp($fileContent, "(?m)([a-zA-Z]{2}\d{4}[a-zA-Z]{2}\d{3})", $STR_REGEXPARRAYGLOBALMATCH ) _ArrayDisplay($aDescriptionLines)1 point
-
SciTE 3.5.5.101 for AutoIt
argumentum reacted to Yashied for a topic
SciTE 3.2.5.99 has been updated (build 1.1.4).1 point -
asakust, Go and look up "floating point arithmetic" - or search the forum because it has been discussed I do not know how many times. And before you ask, this is NOT an Autoit problem - it affects all computers regardless of language unless they use special arithmetic routines. M231 point
-
"PM someone else"
BinaryBrother reacted to Melba23 for a topic
Hi, There have been a few threads recently where it has been suggested that members PM other, more experienced, members directly for help. Although we appreciate that this has usually been intended as a joke, this is not a good thing to see and is indeed specifically prohibited in the Forum rules. Anyone doing this in the near future is likely to find that sanctions are imposed, so please resist the temptation. Thanks for your cooperation. M231 point -
Danp2, Excellent - the crystal ball is working well today. A very good example of why you should use constants and not magic numbers - guinness will be pleased! I will alter the function for the next release - thanks for reporting the problem. M23 Edit: And done.1 point