Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/08/2017 in Posts

  1. Even shorter! Func CreatePath1() Return FileExists("C:\test") ? DirMove("C:\test", "C:\testnew", 1) : DirCreate("C:\testnew") EndFunc ;==>CreatePath
    1 point
  2. The layout of the statement is wrong, it should be Func CreatePath() If FileExists("C:\test") Then DirMove("C:\test", "C:\testnew", 1) Else DirCreate("C:\testnew") EndIf EndFunc ;==>CreatePath or shorter if you want Func CreatePath1() If FileExists("C:\test") Then Return DirMove("C:\test", "C:\testnew", 1) DirCreate("C:\testnew") EndFunc ;==>CreatePath There's also a colon missing from the file path in DirCreate in your post
    1 point
  3. mikell

    Stringmid Between Quotes

    I was sure that this was about to come
    1 point
  4. Have you tried using _IEFrameGetCollection?
    1 point
  5. Its a pun. Saw a t-shirt with that written on it. It not only is true because it is silver colored, but it also implies "if you won't be quite (silence is golden), we can always go with the second best (silver) option and restrain you with duct tape and make you be quiet (duct tape is silver)." Thought it was the funniest t-shirt ever.
    1 point
  6. #include <IE.au3> $oIE = _IECreate('https://stackoverflow.com/questions/901712/how-to-check-whether-a-checkbox-is-checked-in-jquery', 1) _IELoadWait($oIE) $oButtons = _IETagnameGetCollection($oIE, "button") For $oButton in $oButtons If String($oButton.innertext) = " Run code snippet" Then _IEAction($oButton, "click") EndIf Next
    1 point
  7. A quick test revealed indeed that nothing was shown with the STDERR and STDOUT parameters. These 2 give the same result and show me an error message. The first one as console output and the second in the CMD prompt: #include <AutoItConstants.au3> $DOS = Run(@ComSpec & " /k " & "data1.bat", "", default, $STDERR_CHILD + $STDOUT_CHILD) ; Wait until the process has closed using the PID returned by Run. ProcessWaitClose($DOS) ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead. ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : StdoutRead($iPID) = ' & StdoutRead($DOS) & @CRLF ) ;### Debug Console ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : StdoutRead($iPID) = ' & StderrRead($DOS) & @CRLF ) ;### Debug Console ; $DOS2 = Run(@ComSpec & " /k " & "data1.bat") Jos
    1 point
  8. You can try with _ArrayToDeclarationString / _ArrayDeclareFromString from here :
    1 point
  9. After a week’s work with RichEdit controls, I’ve made some observations and come to some conclusions that may help others. The main two are: Rich Text is relatively easy when used inside an AutoIt GUI ... as there are ample commands in the _GUICtrlRichText_*** UDF set. Rich Text is fairly difficult when you start to work with multiple fields and with RTF from other sources, largely because of the wide variations in implementations ... but sometimes due to AutoIt-specific support for rich text formats. As a result of my investigation—and with assistance from mLipok—I’ve produced a Rich Text Tool to help me follow the details of the embedded format definitions. I’m offering it here to help others fathom these details. In the paragraphs that follow the code, I list some of my observations/conclusions in hopes that others might shed additional light. ;======================================== ; Tool for analyzing AutoIt's Rich Text Processing Features ; (and to demonstrate serveral of the common methods) ; >> based on the example script developed by mLipok ; >> with these "tool" enhancements by qwert ; June, 2014 ;======================================== #include <GUIConstantsEx.au3> #include <GuiRichEdit.au3> #include <WindowsConstants.au3> Local $hGui, $hRichEdit, $hRichEdit2, $hRichEdit3, $hRichEdit123 Local $iMsg $hGui = GUICreate("Rich Edit Tools", 1260, 400, -1, 200) ;#Region Create all RichEdit controls $hRichEdit1 = _GUICtrlRichEdit_Create($hGui, "This is a first test.", 10, 10, 300, 100, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) _GUICtrlRichEdit_AppendText($hRichEdit1, @CRLF & "This is more text" & @CRLF) _GUICtrlRichEdit_SetSel($hRichEdit1, 0, 22) _GUICtrlRichEdit_SetFont($hRichEdit1, 14, "Arial") _GUICtrlRichEdit_SetSel($hRichEdit1, -1, -1) $hRichEdit2 = _GUICtrlRichEdit_Create($hGui, "This is a second test.", 10, 130, 300, 100, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) _GUICtrlRichEdit_AppendText($hRichEdit2, @CRLF & "This is more text" & @CRLF) _GUICtrlRichEdit_SetSel($hRichEdit2, 10, 22) _GUICtrlRichEdit_SetFont($hRichEdit2, 14, "Arial") _GUICtrlRichEdit_SetSel($hRichEdit2, -1, -1) $hRichEdit3 = _GUICtrlRichEdit_Create($hGui, "This is a third test.", 10, 250, 300, 100, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) _GUICtrlRichEdit_AppendText($hRichEdit3, @CRLF & "This is more text" & @CRLF) _GUICtrlRichEdit_SetSel($hRichEdit3, 10, 21) _GUICtrlRichEdit_SetFont($hRichEdit3, 14, "Arial") _GUICtrlRichEdit_SetSel($hRichEdit3, -1, -1) $hRichEdit123 = _GUICtrlRichEdit_Create($hGui, "This is the combined result.", 320, 30, 300, 280, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) _GUICtrlRichEdit_AppendText($hRichEdit123, @CRLF & @CRLF) ;#EndRegion Create all RichEdit controls $hVerbatim = GUICtrlCreateEdit ("This is the resulting Rich Text.", 630, 30, 300, 280, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) $hRichResult = _GUICtrlRichEdit_Create($hGui, "Reserved for process result.", 940, 30, 300, 280, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) GUISetFont(16, 700, 0, "Arial") GUICtrlCreateLabel("Combined", 324, 6, 120, 24) GUICtrlCreateLabel("Verbatim", 634, 6, 120, 24) GUICtrlCreateLabel("Result", 944, 6, 120, 24) GUICtrlCreateLabel("\", 562, 310, 120, 24) GUICtrlCreateLabel("\", 872, 310, 120, 24) GUICtrlCreateLabel("/", 680, 310, 120, 24) GUICtrlCreateLabel("/", 990, 310, 120, 24) GUISetFont(12, 400, 0, "Arial") GUICtrlCreateLabel("These tools use the copy/paste method of combining the rich text fields.", 320, 372, 500, 24) $Combine = GUICtrlCreateButton("Combine", 104, 364, 120, 24) GUICtrlSetTip(-1, "Click to redo the combining operation") $ProcessRich = GUICtrlCreateButton("Process", 564, 330, 120, 24) GUICtrlSetTip(-1, "Click to produce Verbatim from Combined") $ProcessVerb = GUICtrlCreateButton("Process", 874, 330, 120, 24) GUICtrlSetTip(-1, "Click to produce Result from Verbatim") GUISetState(@SW_SHOW) Sleep(800) ; for effect only _GUICtrlRichEdit_CopyAllToRichEdit($hRichEdit1, $hRichEdit123) ; Copying $hRichEdit1 to $hRichEdit123 Sleep(800) _GUICtrlRichEdit_CopyAllToRichEdit($hRichEdit2, $hRichEdit123) ; Copying $hRichEdit2 to $hRichEdit123 Sleep(800) _GUICtrlRichEdit_CopyAllToRichEdit($hRichEdit3, $hRichEdit123) ; Copying $hRichEdit3 to $hRichEdit123 Local $Var = _GUICtrlRichEdit_StreamToVar($hRichEdit123, True) $Var = StringReplace($Var, "MS Shell Dlg", "Arial", 0) ; <<<< example of a DIRECT EDIT to change the default font Sleep(800) ;MsgBox(0, "Result", $Var, 0) ; OPTION to view before storing _GUICtrlRichEdit_StreamFromVar ($hRichEdit123, $Var) _GUICtrlRichEdit_StreamToFile($hRichEdit123, @ScriptDir & "\Rich123.rtf", True) GUICtrlSetData($hVerbatim, $Var) Sleep(800) ; again, for effect MsgBox(0, "", "Done", 1) While True $iMsg = GUIGetMsg() Select Case $iMsg = $Combine _GUICtrlRichEdit_SetSel($hRichEdit123, 0, -1) _GUICtrlRichEdit_ReplaceText($hRichEdit123, "New result:" & @CRLF & @CRLF) Sleep(800) ; for effect only _GUICtrlRichEdit_CopyAllToRichEdit($hRichEdit1, $hRichEdit123) Sleep(800) ; for effect only _GUICtrlRichEdit_CopyAllToRichEdit($hRichEdit2, $hRichEdit123) Sleep(800) ; for effect only _GUICtrlRichEdit_CopyAllToRichEdit($hRichEdit3, $hRichEdit123) Sleep(800) ; again, for effect MsgBox(0, "", "Done" & @CRLF & "Verbatim is unchanged at this point." & @CRLF & "Click Process to update it.", 2) Case $iMsg = $ProcessRich Local $Var = _GUICtrlRichEdit_StreamToVar($hRichEdit123, True) GUICtrlSetData($hVerbatim, $Var) MsgBox(0, "", "Done", 1) Case $iMsg = $ProcessVerb _GUICtrlRichEdit_StreamFromVar ($hRichResult, GUICtrlRead($hVerbatim)) MsgBox(0, "", "Done", 1) Case $iMsg = $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($hRichEdit1) ; needed unless script crashes _GUICtrlRichEdit_Destroy($hRichEdit2) ; needed unless script crashes _GUICtrlRichEdit_Destroy($hRichEdit3) ; needed unless script crashes _GUICtrlRichEdit_Destroy($hRichResult) ; needed unless script crashes _GUICtrlRichEdit_Destroy($hRichEdit123) ; needed unless script crashes ; GUIDelete() ; is OK too Exit EndSelect WEnd Func _GUICtrlRichEdit_CopyAllToRichEdit(ByRef $hSourceRichEdit, ByRef $hDestinationRichEdit) Local $aSelection = _GUICtrlRichEdit_GetSel($hSourceRichEdit) ; check for current selection in source control _GUICtrlRichEdit_SetSel($hSourceRichEdit, 0, -1) ; select all contents in source control _GUICtrlRichEdit_Copy($hSourceRichEdit) ; copy selected contents from source control _GUICtrlRichEdit_Paste($hDestinationRichEdit) ; paste content to destination control _GUICtrlRichEdit_SetSel($hSourceRichEdit, $aSelection[0], $aSelection[1]) ; revert back selection in source control EndFunc ;==>_GUICtrlRichEdit_CopyAllToRichEdit Observations of AutoIt’s features and limitations: There is no effective way to assign a default font/size for a RichEdit control. You must assign the font/size to existing segments of characters ... or to the entire contents of a control (with Select All). There is no "native method" to directly write more that one control to a file*. StreamToFile handles formatting well, but can only stream out one named control to a named file. There is no option to append to these files (as there is with normal writes). (* as demonstrated by this tool, methods exist to combine RichEdit controls into a single control for use with the StreamToFile operation.) Likewise, copy to clipboard (_GuiCtrlRichEdit_Copy) preserves RichText formatting and can be useful in moving field content. From what I understand, the clipboard maintains both the RTF and text-only versions of the content. Paste and Paste Special determine which version an application receives. AutoIt's normal file and line writes are for text/data only and cannot be used for RichText controls. _GuiCtrlRichEdit_GetText gets only the text content, without character formatting. If you want to work directly with the RTF syntax, you must first to stream the RichEdit to a Variable ... and then use normal search/replace/add string operations to alter the contents of the variable. You must then update the original RichEdit using StreamFromVar in order to display your result or write to a file (StreamToFile). In Summary Think of a RichEdit control as a “processed container” for format-encoded text. The content is displayed according to rules that are embedded with the text. You can’t see the rules. You only observe their effects. And you can only use the RichEdit UDF actions to make changes to the content in a RichEdit control. If you want to see and work with those rules “verbatim”, first stream the RichEdit contents into a variable and then place the contents of that variable into a normal edit control. Once there, you can parse the rich text statements and apply literal edits and exchanges using String operations. Stream the contents of the edit control back into a RichEdit control to see the effects of those changes. The Rich Edit Tools script provides examples of the types of conversions that can be made. The field on the far right is the “interpreted result” of the verbatim text. Note the direct edit of the default font in the script. (A question: note the use of ByRef in the Function. Since it works without them, what is their purpose in this instance?) Everything I’ve outlined here is subject to correction by anyone with more in-depth experience and understanding. Please feel free to contribute. Thanks to mLipok for posting the basis for this example script, in particular, the _GUICtrlRichEdit_CopyAllToRichEdit method for combining field content.
    1 point
  10. I will try to go into this script in a few days, please emind me via PM, if I forget.
    1 point
  11. BrettF

    MultiLang.au3

    MultiLang.au3 V1.0.0.0- 14 AUG 2010 MultiLang.zip This is a UDF version of how I chose to load different languages into my GUI for AAMP. It uses different XML language files to provide multi-language support. The download includes the UDF, example GUI with 3 languages (English, German, French) to play with. Languages were translated using Google Translate. Don't expect it to be correct. In your programs try not to do this. Wherever possible find a fluent speaker and give them a cookie. Change Log: 1.0.0.0 - 14 AUG 2010 Inital Version Released Comments and Criticism welcome.
    1 point
×
×
  • Create New...