Leaderboard
Popular Content
Showing content with the highest reputation on 10/21/2019 in all areas
-
FileDelete("output.txt") FileWrite("output.txt", StringRegExpReplace(FileRead("input.txt"), "(?m)^.{10}\K.*", ""))3 points
-
Using StringRegExp, adjusting an end parameter is not needed. This Local $aResult = StringRegExp($sHTML, "Selected Candidate : ([^<]+)", 1) means : after "Selected Candidate : " , get one or more characters which are not a "<"1 point
-
OutlookEX UDF
seadoggie01 reacted to water for a topic
I have already modified the function (by removing a line of code) but haven't released this version yet. For the time being you could simply comment the line in your UDF file.1 point -
Getting first 10 characters of each line in a BIG txt file
ThePoro reacted to FrancescoDiMuro for a topic
@ThePoro Did you try to use the handle of the File with FileReadToArray()? #include <FileConstants.au3> Global $strSourceFileName = @ScriptDir & "\SourceFile.txt", _ $strDestFileName = @ScriptDir & "\DestFile.txt", _ $hdlSourceFile, _ $arrSourceFileContent, _ $hdlDestFile, _ $strRandomString = "", _ $hdlTimer $hdlTimer = TimerInit() $hdlSourceFile = FileOpen($strSourceFileName, $FO_OVERWRITE) For $i = 1 To 50000 Step 1 For $j = 1 To 30 Step 1 $strRandomString &= Chr(Random(65, 90, 1)) Next FileWriteLine($hdlSourceFile, $strRandomString) $strRandomString = "" Next FileClose($hdlSourceFile) ConsoleWrite("It tooks " & Round(TimerDiff($hdlTimer)/1000, 2) & " seconds to generate the test file." & @CRLF) $hdlTimer = TimerInit() $hdlSourceFile = FileOpen($strSourceFileName, $FO_READ) $hdlDestFile = FileOpen($strDestFileName, $FO_OVERWRITE) ;~ $arrSourceFileContent = FileReadToArray($hdlSourceFile) ;~ For $i = 0 To UBound($arrSourceFileContent) - 1 Step 1 ;~ FileWriteLine($hdlDestFile, StringLeft($arrSourceFileContent[$i], 10)) ;~ Next FileWrite($hdlDestFile, StringRegExpReplace(FileRead($hdlSourceFile), '(?m)^.{10}\K.*', '')) FileClose($hdlDestFile) FileClose($hdlSourceFile) ConsoleWrite("It tooks " & Round(TimerDiff($hdlTimer)/1000, 2) & " seconds to read 10 characters from each line of the source file." & @CRLF) EDIT: with the @jchd suggestion, it is even faster!1 point -
Reading XML content and generate new tag in other XML
KickStarter15 reacted to mikell for a topic
As TheXman said if your xml is not a valid one I personally can see nothing but a brute way to parse it using regex or so, and then format the results as Vicious suggested $txt = "<!DOCTYPE dg SYSTEM ""ovidbase.dtd"">" & @crlf & _ "<DG><D V=""2000.3F"" AN=""0128415-201917710-00019"">" & @crlf & _ "<BB>" & @crlf & _ "<TG><TI>Some title here..</TI><STI>Some title here..</STI></TG>" & @crlf & _ "<BY><PN><SN>&NA;</SN></PN><BT>; ==> This is the start tag that I need to get" & @crlf & _ "<P>An event is serious (based on the ICH definition) when the patient outcome is:</P><LS T=""B""><LM>" & @crlf & _ "<P>death</P></LM><LM>" & @crlf & _ "<P>life-threatening</P></LM><LM>" & @crlf & _ "<P>hospitalisation</P></LM><LM>" & @crlf & _ "<P>disability</P></LM><LM>" & @crlf & _ "<P>congenital anomaly</P></LM><LM>" & @crlf & _ "<P>other medically important event</P></LM></LS></BT></BY> ; ==> this is the end tag" & @crlf & _ "<SO><PB>Some Text here...</PB><ISN>XXX-XXXX</ISN><DA><DY>XX</DY><MO>XXXX</MO><YR>XXXX</YR></DA><V>XXXX</V><IS><IP>XX</IP></IS><PG>XX</PG></SO>" & @crlf & _ "<DT>Some heading here...</DT>" & @crlf & _ "</BB>" & @crlf & _ "<BD>" & @crlf & _ "<LV1>" & @crlf & _ "<P>Some sentences here....</P>" & @crlf & _ "<P>Some sentences here....</P>" & @crlf & _ "<P>Some sentences here....</P>" & @crlf & _ "</LV1></BD>" & @crlf & _ "<ED><EDS>" & @crlf & _ "<HD>Some Heading here...</HD>" & @crlf & _ "<RF ID=""R1-19"">1. <URF>Some reference list here...</URF></RF>" & @crlf & _ "</EDS></ED>" & @crlf & _ "<KWS><HD>Heading</HD><KW>Text here</KW><KW>Text here</KW><KW>Text here</KW><KW>Text here</KW><KW>Text here</KW></KWS>" & @crlf & _ "</D></DG>" ;Msgbox(0,"", $txt) #Include <Array.au3> $heading = StringRegExpReplace($txt, '(?s).*<BT>.*?<P>([^<]+).*', "$1") Msgbox(0,"heading", $heading) $items_list = StringRegExpReplace($txt, '(?s).*<LS(.*?)</LS>.*', "$1") $items = StringRegExp($items_list, '<P>([^<]+)', 3) _ArrayDisplay($items)1 point -
Inerting new XML taggings in XML file
KickStarter15 reacted to mikell for a topic
Or do it using the most simple way $insert = "<Para Type=""AttributeHere"">" & @crlf & _ "<Emphasis Type=""Bold"">Information</Emphasis>" & @crlf & _ "<UnorderedList Mark=""None"">" & @crlf & _ "</Heading>An event is serious when the patient outcome is:</Heading>" & @crlf & _ "<ItemContent><Para>* death</Para></ItemContent>" & @crlf & _ "<ItemContent><Para>* Drug interaction</Para></ItemContent>" & @crlf & _ "</UnorderedList></Para>" $txt = "something 1" & @crlf & "<Body>" & @crlf & "something 2" Msgbox(0,"", $txt) $tmp = StringSplit($txt, "<Body>", 3) $txt = $tmp[0] & "<Body>" & $insert & $tmp[1] Msgbox(0,"", $txt)1 point -
Hi, I can switch between Chrome windows, however, when the switch happens and if I am typing in an application, for example, notepad, the focus goes to the Chrome tab. Here is my script: #include <Constants.au3> AutoItSetOption("WinTitleMatchMode", $OPT_MATCHANY) ;2 While 1 WinActivate("[TITLE: ChromeTitle1;CLASS:Chrome_WidgetWin_1]") Sleep(3000) WinActivate("[TITLE: ChromeTitle2;CLASS:Chrome_WidgetWin_1]") Sleep(3000) WinActivate("[TITLE: ChromeTitle3;CLASS:Chrome_WidgetWin_1]") Sleep(3000) WinActivate("[TITLE: ChromeTitle4;CLASS:Chrome_WidgetWin_1]") Sleep(3000) WEnd Is there a way to switch the windows w/o losing the keyboard/mouse focus?1 point
-
JO, Setting a new color for a subitem needs the listview to be repainted, which is done when a message is sent to the LV But you can turn around the hard-coding in the wm_notify - I believe - just by using global vars Anyway I still don't know what you exactly need #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> Global $myitem = -1, $mysubitem = -1 $Form1 = GUICreate("Form1", 350, 250, -1, -1) $ListView1 = GUICtrlCreateListView("Header|Header|Header", 0, 0, 350, 200) GuiCtrlCreateListViewItem('White|White|White',$ListView1) GuiCtrlCreateListViewItem('Pink|Green|Pink',$ListView1) GuiCtrlCreateListViewItem('White|White|White',$ListView1) $btn = GuiCtrlCreateButton('button', 20, 210, 50, 25) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $btn $myitem = 1 $mysubitem = 1 _GUICtrlListView_SetItemText($ListView1, 1, "Red", 1) EndSwitch WEnd Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $tNMHDR, $hWndFrom, $iCode $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom") $iCode = DllStructGetData($tNMHDR, "Code") $hListView = GuiCtrlGetHandle($ListView1) Switch $hWndFrom Case $hListView Switch $iCode Case $NM_CUSTOMDRAW Local $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) Local $iDrawStage = DllStructGetData($tCustDraw, "dwDrawStage") If $iDrawStage = $CDDS_PREPAINT Then Return $CDRF_NOTIFYITEMDRAW If $iDrawStage = $CDDS_ITEMPREPAINT Then Return $CDRF_NOTIFYSUBITEMDRAW Local $iSubItem = DllStructGetData($tCustDraw, "iSubItem") Local $iItem = DllStructGetData($tCustDraw, "dwItemSpec") Local $iColor If $iItem = 1 Then If $iSubItem = 1 Then $iColor = RGB2BGR(0x00aa00) ; green Else $iColor = RGB2BGR(0xffaaff) ; pink EndIf Else $iColor = RGB2BGR(0xFFFFFF) ; white EndIf If $iItem = $myitem and $iSubItem = $mysubitem Then $iColor = RGB2BGR(0xFF0000) ; red DllStructSetData($tCustDraw, "clrTextBk", $iColor) ; background color Return $CDRF_NEWFONT EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func RGB2BGR($iColor) Return BitAND(BitShift(String(Binary($iColor)), 8), 0xFFFFFF) EndFunc ;==>RGB2BGR()1 point
-
WM_NOTIFY - Invalid variable
pixelsearch reacted to KaFu for a topic
Replace $LVN_BEGINLABELEDIT with $LVN_BEGINLABELEDITA.1 point