Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/28/2017 in all areas

  1. I know this is an old post but I figured it out after @orbs requested I look at this from another topic. Initially I couldn't figure it out either. I thought the $WS_HSCROLL was word wrap, and it very well may be for a regular edit control, but for richedit there is an actual word wrap option. using EM_SETTARGETDEVICE you can enable/disable word wrap #include <GuiRichEdit.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <Constants.au3> #include <WinAPI.au3> ; build GUI Global Const $nGUI_MaxW = 500, $nGUI_MaxH = 100 Global $nGUI_W = 720, $nGUI_H = 500, $nRichEditOffset = 10, $nRichEditOffsetTop = 30 Global $nToolbarHeight = $nRichEditOffsetTop Global $hGui = GUICreate('RichEdit wrap/unwrap test', $nGUI_W, $nGUI_H, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_SYSMENU)) GUISetBkColor(0xCCDDEE) ; - toolbar ; ** requires an extra lower contour if main rich edit is not docked to edges Global $gToolbarBackground = GUICtrlCreateLabel('', 0, 0, $nGUI_W, $nToolbarHeight) GUICtrlSetResizing(-1, BitOR($GUI_DOCKTOP, $GUI_DOCKLEFT, $GUI_DOCKRIGHT, $GUI_DOCKHEIGHT)) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlSetState(-1, $GUI_DISABLE) Global $gToolbarBackgroundContour = GUICtrlCreateLabel('', 0, $nToolbarHeight+1, $nGUI_W, 1) GUICtrlSetResizing(-1, BitOR($GUI_DOCKTOP, $GUI_DOCKLEFT, $GUI_DOCKRIGHT, $GUI_DOCKHEIGHT)) GUICtrlSetBkColor(-1, 0) GUICtrlSetState(-1, $GUI_DISABLE) ; -- wrap/unwrap Global $bWrap = False Global $gWrap = GUICtrlCreateCheckbox('Wrap', 3, 3, 48, 24, $BS_PUSHLIKE) GUICtrlSetResizing(-1, BitOR($GUI_DOCKTOP, $GUI_DOCKLEFT, $GUI_DOCKSIZE)) ; - main Global $hRichEdit = _GUICtrlRichEdit_Create($hGui, 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz', $nRichEditOffset, $nRichEditOffset + $nRichEditOffsetTop, $nGUI_W - $nRichEditOffset * 2, $nGUI_H - $nRichEditOffset * 2 - $nRichEditOffsetTop - 24, BitOR($ES_MULTILINE, $WS_HSCROLL, $WS_VSCROLL)) _GUICtrlRichEdit_SetSel($hRichEdit, 0, -1, True) _GUICtrlRichEdit_SetFont($hRichEdit, Default, 'Courier New') GUISetState() GUIRegisterMsg($WM_GETMINMAXINFO, "_WM_GETMINMAXINFO") GUIRegisterMsg($WM_SIZE, "_WM_SIZE") ; work with GUI Global $iMsg = 0 While True $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($hRichEdit) Exit Case $gWrap $bWrap = Not $bWrap ConsoleWrite(_GUICtrlRichEdit_WordWrap($hRichEdit, $bWrap) & @LF) EndSwitch WEnd Func _GUICtrlRichEdit_WordWrap($hWnd, $bEnable = True) If (IsHWnd($hWnd) = False) Then Return SetError(1, 0, False) DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $hWnd, "uint", $EM_SETTARGETDEVICE, "wparam", 0, "lparam", Not $bEnable) If (@Error) Then Return SetError(2, @extended, False) Return True EndFunc This topic gave me the answer.
    2 points
  2. @Biatu, my (very simple) implementation of tailing a log file, in native AutoIt: Global $hFile = FileOpen('text.txt') Global $sLine = '' While True $sLine = FileReadLine($hFile) If Not @error Then ConsoleWrite($sLine & @CRLF) WEnd FileClose($hFile) concept: you open a file and get a handle to it. then you keep the handle, and use it constantly to read the file. as long as there is something to read, you read it and the file position advances to the end. if there is nothing new to read, then nothing needs to be done - but the handle is still kept. you may want to elaborate it to detect log rotation, or to optimize your entire script performance, or whatever. P.S. you have the source code for _FileCountLines(). look at it, and see why you should absolutely NOT be using it for this purpose.
    1 point
  3. I don't understand what is your problem. If you want to access a relative path from your script, you can use this : $logfile = @ScriptDir & "\..\subfolder2\file.log"
    1 point
  4. Jos

    autoit With C#

    Have you tried to include the full path in the first parameter? Jos
    1 point
  5. CyBoRgWaR, Put the ControlIDs of the Inputs into an array and then loop through it like this: #include <GUIConstantsEx.au3> Global $aInput_CID[5] $hGUI = GUICreate("Test", 500, 500) For $i = 0 To UBound($aInput_CID) - 1 $aInput_CID[$i] = GUICtrlCreateInput("Test " & $i, 10, 10 + (30 * $i), 50, 20) Next $Button4 = GUICtrlCreateButton("Reset", 10, 450, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Button4 For $i = 0 To UBound($aInput_CID) - 1 GUICtrlSetState($aInput_CID[$i], $GUI_DISABLE) GUICtrlSetData($aInput_CID[$i], "Test " & $i) Next EndSwitch WEnd M23
    1 point
  6. CyBoRgWaR, Indeed you need to define the content - how do you expect AutoIt to know what you set as the original value? And this works fine for me: #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $Inputbox1 = GUICtrlCreateInput("test", 64, 280, 57, 21) $Button4 = GUICtrlCreateButton("Reset", 10, 450, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Button4 GUICtrlSetState($inputbox1,$GUI_DISABLE) GUICtrlSetData($inputbox1, "test") EndSwitch WEnd You might be interested in _GUICtrlEdit_SetCueBanner - that does automatically reset when the control is emptied. M23
    1 point
  7. Adam1213

    Joystick UDF

    Nice program but it did not work with Autoit 3.2, I fixed this. When I made it work its blinking (info on GUI) was really bad (fixed) ;____________________________________________________________________ ; Original program by Ejoc ; ; Improved by Adam1213 (autoit 3.2 compatiblity + improved labels ; ;____________________________________________________________________ #include <GUIConstants.au3> ;_________________ SETUP_____________________________________ Local $joy,$coor,$h,$s,$msg $joy = _JoyInit() dim $labels_text[8]=['X', 'Y', 'Z', 'R', 'U', 'V', 'POV', 'Buttons'] dim $labels_no=UBound($labels_text) dim $labels[$labels_no] dim $labels_value[$labels_no] ;__________ CONFIG ____________________________________________ ;---------- Find the max length of the longest label -------------- $label_len=0 for $text in $labels_text $len=stringlen($text) if $len>$label_len then $label_len=$len endif next $label_len*=6 ;_____________ GUI _______________________________________________ GUICreate('Joystick Test', 200, 200) GUICtrlCreateLabel('Joystick', 40, 20, 100, 20) for $i=0 to $labels_no-1 GuiCtrlCreatelabel($labels_text[$i]&':', 10, 60+$i*12, $label_len, 12) $labels[$i]=GuiCtrlCreatelabel('', 10+$label_len, 60+$i*12, 70, 12) $labels_value[$i]='' next GUISetState() ;_____________________________________________________________________ while 1 $coord=_GetJoy($joy,0) for $i=0 to UBound($coord)-1 if $coord[$i]<>$labels_value[$i] then GUICtrlSetData($labels[$i], $coord[$i]) $labels_value[$i]=$coord[$i] endif next sleep(10) $msg =GUIGetMSG() if $msg = $GUI_EVENT_CLOSE Then Exitloop WEnd $lpJoy=0 ; Joyclose ;====================================== ; _JoyInit() ;====================================== Func _JoyInit() Local $joy Global $JOYINFOEX_struct = "dword[13]" $joy=DllStructCreate($JOYINFOEX_struct) if @error Then Return 0 DllStructSetData($joy, 1, DllStructGetSize($joy), 1);dwSize = sizeof(struct) DllStructSetData($joy, 1, 255, 2) ;dwFlags = GetAll return $joy EndFunc ;====================================== ; _GetJoy($lpJoy,$iJoy) ; $lpJoy Return from _JoyInit() ; $iJoy Joystick # 0-15 ; Return Array containing X-Pos, Y-Pos, Z-Pos, R-Pos, U-Pos, V-Pos,POV ; Buttons down ; ; *POV This is a digital game pad, not analog joystick ; 65535 = Not pressed ; 0 = U ; 4500 = UR ; 9000 = R ; Goes around clockwise increasing 4500 for each position ;====================================== Func _GetJoy($lpJoy,$iJoy) Local $coor,$ret Dim $coor[8] DllCall("Winmm.dll","int","joyGetPosEx", _ "int",$iJoy, _ "ptr",DllStructGetPtr($lpJoy)) if Not @error Then $coor[0] = DllStructGetData($lpJoy,1,3) $coor[1] = DllStructGetData($lpJoy,1,4) $coor[2] = DllStructGetData($lpJoy,1,5) $coor[3] = DllStructGetData($lpJoy,1,6) $coor[4] = DllStructGetData($lpJoy,1,7) $coor[5] = DllStructGetData($lpJoy,1,8) $coor[6] = DllStructGetData($lpJoy,1,11) $coor[7] = DllStructGetData($lpJoy,1,9) EndIf return $coor EndFunc
    1 point
×
×
  • Create New...