Leaderboard
Popular Content
Showing content with the highest reputation on 07/01/2016 in all areas
-
Help inserting two zeros every other two characters in a string
Mannyfresh15 and one other reacted to mikell for a topic
My 2 cents $sString = "manny1" $sNewString = StringRegExpReplace($sString, '..\K', "00") MsgBox(0, "Result", $sNewString)2 points -
Help inserting two zeros every other two characters in a string
Mannyfresh15 and one other reacted to Melba23 for a topic
Mannyfresh15, Or you could do something like this: $sString = "manny1" $aRet = StringRegExp($sString, "(.{2})", 3) $sNewString = "" For $i = 0 To UBound($aRet) - 1 $sNewString &= $aRet[$i] & "00" Next MsgBox(0, "Result", $sNewString) M232 points -
maniootek, Most certainly not a bug and entirely due to your code. The Help file is quite clear: Warning: blocking of running user functions which executes window messages with commands such as "MsgBox()" can lead to unexpected behavior, the return to the system should be as fast as possible !!! _ArrayDisplay is a blocking function - so the crash is quite expected. You need to set a flag in the handler and then action it in your idle loop - like this: #include <WindowsConstants.au3> ;$WM_NOTIFY #include <GUIConstantsEx.au3> ;$GUI_RUNDEFMSG #include <GuiListView.au3> ;$tagNMHDR #include <Array.au3> Global $fActivated = False GUICreate("") $idListview = GUICtrlCreateListView("col1", 5, 5) GUICtrlCreateListViewItem("item", $idListview) GUICtrlCreateListViewItem("item", $idListview) Local $aArray[0] for $i=0 to 10 _ArrayAdd($aArray, $i) Next GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOK ExitLoop EndSwitch If $fActivated Then $fActivated = False ;msgbox(0,0,$index & $subitemNR) _ArrayDisplay($aArray) EndIf WEnd Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iCode, $tNMHDR, $hWndListView $hWndListView = GUICtrlGetHandle($idListview) If Not IsHWnd($hWndListView) Then $hWndListView = GUICtrlGetHandle($hWndListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case -3 ;$NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) $index = DllStructGetData($tInfo, "Index") $subitemNR = DllStructGetData($tInfo, "SubItem") If $index <> -1 Then $fActivated = True EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY M232 points
-
Help inserting two zeros every other two characters in a string
Mannyfresh15 reacted to ViciousXUSMC for a topic
Meh I'll throw my 2 cents into the pot. $sString = "manny1" $sNewString = StringRegExpReplace($sString, "(.{2})", "${0}00") MsgBox(0, "Result", $sNewString) One Liner just for fun: MsgBox(0, "Results", StringRegExpReplace("Manny1", "(..)", "${0}00"))1 point -
Help inserting two zeros every other two characters in a string
Mannyfresh15 reacted to Jfish for a topic
Glad I could help ... you may want to remove the extra message box from the for loop like I did in my edited post ...1 point -
Help inserting two zeros every other two characters in a string
Mannyfresh15 reacted to Jfish for a topic
#include <String.au3> $sString = "manny1" for $a=StringLen($sString) to 1 step -2 $sString=_StringInsert ($sString, "00",$a) Next MsgBox (0,"Hello" , "Your String After Inserting 00's " & $sString ,0)1 point -
Most efficient way to get prime factorization with autoit
HemantMalve reacted to JLogan3o13 for a topic
@HemantMalve Did you not notice that this thread is almost 7 years old? Please don't resurrect old threads. If you have a script or snippet you would like to share, we have an Examples forum.1 point -
1 point
-
An easy way : Local $sCode = "/* This is a comment */" & @CRLF & _ "/* C++ comments can also" & @CRLF & _ " * span multiple lines" & @CRLF & _ " */" & @CRLF & _ "" & @CRLF & _ "A comment can also start with //, extending to the end of the line. For example:" & @CRLF & _ "" & @CRLF & _ "#include <iostream>" & @CRLF & _ "using namespace std;" & @CRLF & _ "" & @CRLF & _ "main()" & @CRLF & _ "{" & @CRLF & _ " cout << ""Hello World""; // prints Hello World" & @CRLF & _ "" & @CRLF & _ " return 0;" & @CRLF & _ "}" & @CRLF & _ "" & @CRLF & _ "Within a /* and */ comment, // characters have no special meaning. Within a // comment, /* and */ have no special meaning. Thus, you can ""nest"" one kind of comment within the other kind. For example:" & @CRLF & _ "" & @CRLF & _ "/* Comment out printing of Hello World:" & @CRLF & _ "" & @CRLF & _ "cout << ""Hello World""; // prints Hello World" & @CRLF & _ "" & @CRLF & _ "*/" Local $sCodeWithoutComments = StringRegExpReplace($sCode, "(?s)(/\*.*?\*/|//\N*(?=\R|$))\R?", "") ConsoleWrite($sCodeWithoutComments) But with my code, you will have problems if a line of your code contains string with "//" on "/*" or "*/"1 point
-
Allow right click copy on disabled input box
cookiemonster reacted to Melba23 for a topic
cookiemonster, Try setting the input the readonly rather than disabled - the context menu still works and <Select all - Copy> will get you the content: #include <GUIConstantsEx.au3> #include <EditConstants.au3> $hGUI = GUICreate("Test", 500, 500) $cInput = GUICtrlCreateInput("", 10, 10, 200, 20) $cButton = GUICtrlCreateButton("Read-Only", 10, 100, 80, 30) GUISetState() $sOrgText = GUICtrlRead($cInput) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton ; Set readonly style GUICtrlSetStyle($cInput, BitOr($ES_READONLY, $ES_LEFT, $ES_AUTOHSCROLL)) ; Empty the undo buffer GUICtrlSendMsg($cInput, $EM_EMPTYUNDOBUFFER, 0, 0) EndSwitch WEnd M231 point -
Shuffle string
czardas reacted to cookiemonster for a topic
Works perfectly, I had tried doing it this way but messed part of it up, thanks for clarification.1 point -
You have rights to read your own process memory :S. Local $tUserAgent=DllStructCreate("char String[512]") Local $aRet = DllCall("Urlmon.dll", "LONG", "ObtainUserAgentString", "DWORD", 0, "ptr", DllStructGetptr($tUserAgent), "dword*", DllStructGetSize($tUserAgent)) ConsoleWrite( $tUserAgent.String & @CRLF) Saludos1 point
-
Shuffle string
cookiemonster reacted to czardas for a topic
#include <Array.au3> Local $string = 'vXx2586578£&' Local $aChars = StringSplit($string, "", 2) _ArrayShuffle($aChars) Local $sNewString For $i = 0 To UBound($aChars) - 1 $sNewString &= $aChars[$i] Next MsgBox(0, "New String", $sNewString)1 point -
A way, using detectlanguage.com ConsoleWrite( _GetLanguage("buenos dias señor" ) ) Func _GetLanguage($sText) Local $sRet, $aLang Local $sUrl = "https://ws.detectlanguage.com/0.2/detect" Local $sRequest = "key=demo&q=" & $sText Local $oHTTP = ObjCreate("Microsoft.XMLHTTP") If @error Then Return SetError(1, 0, "") $oHTTP.open ("POST", $sUrl,false) $oHTTP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded") $oHTTP.setRequestHeader("Content-Length", StringLen($sRequest) ) $oHTTP.send($sRequest) $sRet = $oHTTP.responseText $aLang = StringRegExp($sRet, '"language":"(\w+)"', 1) If @error Then Return SetError(2, 0, "") Return $aLang[0] EndFunc1 point
-
Maybe there's a whitespace in $_MemoryRead, try ConsoleWrite("The string: " & StringStripWS($_MemoryRead,8) & @LF)1 point
-
You mean something like this here? #include <Constants.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global Const $STM_SETIMAGE = 0x0172 Global $sPathKey = "HKLM64\SOFTWARE\AutoIt v3\AutoIt\" If @OSArch = "x64" Then $sPathKey = "HKLM\SOFTWARE\Wow6432Node\AutoIt v3\AutoIt\" Global $sImage = RegRead($sPathKey, "InstallDir") & "\Examples\GUI\logo4.gif" _GDIPlus_Startup() Global $hBmp = _GDIPlus_BitmapCreateFromFile($sImage) Global $iW = _GDIPlus_ImageGetWidth($hBmp), $iH = _GDIPlus_ImageGetHeight($hBmp) Global $hGUI = GUICreate("Test", 235, 112, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_THICKFRAME), $WS_EX_COMPOSITED) Global $idPic = GUICtrlCreatePic("", 32, 16, $iW, $iH) GUICtrlSetResizing(-1, $GUI_DOCKVCENTER + $GUI_DOCKHCENTER) Global $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp) Global $hB = GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap) If $hB Then _WinAPI_DeleteObject($hB) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_SIZE, "WM_SIZE") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIRegisterMsg($WM_SIZE, "") _WinAPI_DeleteObject($hHBitmap) _GDIPlus_BitmapDispose($hBmp) _GDIPlus_Shutdown() GUIDelete() Exit EndSwitch WEnd Func WM_SIZE($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $wParam, $lParam Local $aSize = ControlGetPos($hWnd, "", $idPic) Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($aSize[2], $aSize[3]) Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetInterpolationMode($hContext, 5) _GDIPlus_GraphicsDrawImageRect($hContext, $hBmp, 0, 0, $aSize[2], $aSize[3]) _GDIPlus_GraphicsDispose($hContext) Local $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) Local $hB = GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap) If $hB Then _WinAPI_DeleteObject($hB) _WinAPI_DeleteObject($hHBitmap) _GDIPlus_BitmapDispose($hBitmap) Return "GUI_RUNDEFMSG" EndFunc1 point
-
xcaliber13, This seems to work: $sText = "blah blah" & @CRLF & _ "Name" & @CRLF & _ "Line 1" & @CRLF & _ "line 2" & @CRLF & _ "blah blah" $aExtract = StringRegExp($sText, "(?i)(NAME.*\R.*\R.*)\R", 3) ConsoleWrite($aExtract[0] & @CRLF) M231 point
-
I don't get it. @mLipok has polished (pun intended) a nice ADO UDF which works flawlessly. Why insist on using another one which causes issues?1 point