Leaderboard
Popular Content
Showing content with the highest reputation on 09/07/2015 in all areas
-
For those of us who use SciTE4AutoIt3 then you would've come across (at some stage) the directive #AutoIt3Wrapper_Res_SaveSource, it allows you to save the script to the compiled exe thus allowing you to retrieve at a later stage, great if you accidentally delete your source file. _GetSavedSource() allows you to extract the source file from the compiled executable and save to a file of your choice. Note: You must use #AutoIt3Wrapper_Res_SaveSource=Y at the top of the script for this to work & it must be compiled. Function: #include-once #include <WinAPIRes.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GetSavedSource ; Description ...: Retrieve the source file from a compiled executable, #AutoIt3Wrapper_Res_SaveSource=Y must be used beforehand to embed the file to the executable ; Syntax ........: _GetSavedSource([$sExecutable = ''[, $sSaveFilePath = '']]) ; Parameters ....: $sExecutable - [optional] Executable to retrieve the source file from ; Use a blank string or the Default keyword to use the current executable. Default is '' ; $sSaveFilePath - [optional] FilePath to save the source file to. Nore: The file doesn't have to exist. Default is '' ; Use a blank string or the Default keyword to save to the current directory and using the script's ; name with the au3 prefix. Default is '' ; Return values .: Success - True ; Failure - False and sets @error to non-zero ; Author ........: guinness ; Remarks .......: ; Example .......: Yes ; Note ..........: Thanks to Jos, Yashied & Zedna ; =============================================================================================================================== Func _GetSavedSource($sExecutable = '', $sSaveFilePath = '') Local Enum $GETSAVEDSOURCE_ERROR_NONE, $GETSAVEDSOURCE_ERROR_FILEWRITE, $GETSAVEDSOURCE_ERROR_FINDRESOURCE, $GETSAVEDSOURCE_ERROR_LOADMODULE Local $iError = $GETSAVEDSOURCE_ERROR_LOADMODULE Local $hInstance = (($sExecutable = Default Or StringStripWS($sExecutable, $STR_STRIPALL) = '') ? _WinAPI_GetModuleHandle(Null) : _WinAPI_LoadLibraryEx($sExecutable, $LOAD_LIBRARY_AS_DATAFILE)) If Not @error Then $iError = $GETSAVEDSOURCE_ERROR_FINDRESOURCE ; Get the source file from the executable. This is located at resname 999 Local $hResource = _WinAPI_FindResource($hInstance, $RT_RCDATA, 999) If Not @error Then Local $hData = _WinAPI_LoadResource($hInstance, $hResource) Local $iSize = _WinAPI_SizeOfResource($hInstance, $hResource) Local $pResource = _WinAPI_LockResource($hData) If $sSaveFilePath = Default Or StringStripWS($sSaveFilePath, $STR_STRIPALL) = '' Then $sSaveFilePath = @ScriptDir & '\' & StringLeft(@ScriptName, StringInStr(@ScriptName, '.', $STR_NOCASESENSEBASIC, -1) - 1) EndIf $iError = $GETSAVEDSOURCE_ERROR_FILEWRITE Local $hFilePath = FileOpen($sSaveFilePath, BitOR($FO_OVERWRITE, $FO_BINARY, $FO_UTF8)) If $hFilePath > -1 Then $iError = $GETSAVEDSOURCE_ERROR_NONE Local $tBuffer = DllStructCreate('byte array[' & $iSize & ']', $pResource) FileWrite($hFilePath, DllStructGetData($tBuffer, 'array')) FileClose($hFilePath) EndIf EndIf _WinAPI_FreeLibrary($hInstance) EndIf Return SetError($iError, 0, $iError = $GETSAVEDSOURCE_ERROR_NONE) EndFunc ;==>_GetSavedSource Example 1 of Function: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 ; Use the full version of SciTE4AutoIt3 by Jos #AutoIt3Wrapper_Res_SaveSource=Y #AutoIt3Wrapper_UseX64=N #include <MsgBoxConstants.au3> #include '_GetSavedSource.au3' Example() Func Example() If @Compiled Then If _GetSavedSource(@ScriptFullPath, @ScriptDir & '\' & GetScriptName() & '.au3') Then MsgBox($MB_SYSTEMMODAL, 'Completed', 'The Au3 script was saved in the script directory and is called ' & GetScriptName() & '.au3') Else MsgBox($MB_SYSTEMMODAL, 'Error' & @error, 'An error occurred whilst extracting the Au3 script located in the resources.') EndIf Else MsgBox($MB_SYSTEMMODAL, 'Compile first', 'Please compile this script first and then run the compiled file, you''ll see a new file called "' & _ GetScriptName() & '.au3' & '" is created in the same directory.') EndIf EndFunc ;==>Example ; Return the @ScriptName minus the .exe or .au3 extension and with _SAVEDSOURCE_ appended Func GetScriptName() Return StringLeft(@ScriptName, StringInStr(@ScriptName, '.', $STR_NOCASESENSEBASIC, -1) - 1) & '_SAVEDSOURCE_' EndFunc ;==>GetScriptName Example 2 of Function: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 ; Use the full version of SciTE4AutoIt3 by Jos #AutoIt3Wrapper_Res_SaveSource=Y #AutoIt3Wrapper_UseX64=N #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include '_GetSavedSource.au3' If Not @Compiled Then Exit MsgBox($MB_SYSTEMMODAL, 'Compile first', 'Please compile this script first and then run the compiled file, you''ll see a new file called "' & _ GetScriptName() & '.au3' & '" is created in the same directory.') EndIf ; Check if the commandline parameter 'SaveSource' has been passed to the executable IsSaveSource() Example() Func Example() ; The example of using AutoItWinGetTitle() can be found at: http://www.autoitscript.com/forum/topic/133648-autoitwingettitleautoitwinsettitle-an-example-of-usage/ ; Get the handle of the AutoIt Hidden Window by finding out the title of the AutoIt Hidden Window Local $hAutoIt = AutoItWinShow() ; Read the source file that was extracted from the executable Local $sData = FileRead(@ScriptDir & '\' & GetScriptName() & '.au3') If @error Then ; If the file wasn't extracted then show an error string $sData = '## @error - can''t open the file ##' EndIf ; Set the text of the edit box using the data returned from _GetFile AutoItWinSetText($hAutoIt, $sData) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ; Just hit the close button to Exit the application ExitLoop EndSwitch WEnd EndFunc ;==>Example ; Add text to AutoIt's Hidden Window Func AutoItWinSetText($sString, $hWnd = Default) If Not IsHWnd($hWnd) Or $hWnd = Default Then ; Get the handle of the AutoIt Hidden Window by finding out the title of the AutoIt Hidden Window $hWnd = WinGetHandle(AutoItWinGetTitle()) EndIf Return ControlSetText($hWnd, '', ControlGetHandle($hWnd, '', 'Edit1'), $sString) EndFunc ;==>AutoItWinSetText ; Display AutoIt's Hidden Window. Returns the handle of the window Func AutoItWinShow() ; Get the handle of the AutoIt Hidden Window by finding out the title of the AutoIt Hidden Window Local $hWnd = WinGetHandle(AutoItWinGetTitle()) ; Move the AutoIt Hidden Window and re-size for a better view of the data that will be set WinMove($hWnd, '', (@DesktopWidth / 2) - 250, (@DesktopHeight / 2) - 250, 500, 500) ; Show the AutoIt Hidden Window, normally this is hidden, but in the interest of this example I'm displaying it WinSetState($hWnd, '', @SW_SHOW) Return $hWnd EndFunc ;==>AutoItWinShow ; Return the @ScriptName minus the .exe or .au3 extension and with _SAVEDSOURCE_ appended Func GetScriptName() Return StringLeft(@ScriptName, StringInStr(@ScriptName, '.', $STR_NOCASESENSEBASIC, -1) - 1) & '_SAVEDSOURCE_' EndFunc ;==>GetScriptName ; Check if the commandline parameter 'SaveSource' has been passed to the executable Func IsSaveSource() Return (StringInStr($CmdLineRaw, 'SaveSource') ? _GetSavedSource(@ScriptFullPath, @ScriptDir & '\' & GetScriptName() & '.au3') : Null) EndFunc ;==>IsSaveSource All of the above has been included in a ZIP file. GetSavedSource.zip1 point
-
I meant Alert.au3 and all the other junk you have there. If you want help, then don't expect people to have to fix your reproducer for you. Try using _GUICtrlListBox_Create() instead.1 point
-
use Timer within a Loop~1 point
-
Look at adlibregister1 point
-
I need a life. Can Someone give me one? Saludos1 point
-
Another way to look at it. Set the char/string attributes then write to the control...(as opposed to write, select, change, deselect)... #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiRichEdit.au3> local $sString1 = 'I am a piece of text that wants to be multi-colored. Every letter is a different color.' local $sString2 = 'I am a piece of text that wants to be multi-colored. Every word is a different color.' local $aColors = [0xff0000,0x00ff00, 0x0000ff], $LastColor, $Color $hGui = GUICreate("RichEdit Test", 320, 350) $hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 10, 10, 300, 220, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) GUISetState() for $i = 0 to stringlen($sString1) ; ensure successive unique color $Color = $aColors[random(0,2,1)] while $Color = $LastColor $Color = $aColors[random(0,2,1)] wend $LastColor = $Color _GUICtrlRichEdit_SetCharColor($hRichEdit,$Color) _GUICtrlRichEdit_AppendText($hRichEdit,stringmid($sString1,$i,1)) next _GUICtrlRichEdit_AppendText($hRichEdit,@crlf) local $aTemp = stringsplit($sString2, ' ', 2) for $i = 0 to ubound($aTemp) - 1 ; ensure successive unique color $Color = $aColors[random(0,2,1)] while $Color = $LastColor $Color = $aColors[random(0,2,1)] wend $LastColor = $Color _GUICtrlRichEdit_SetCharColor($hRichEdit,$Color) _GUICtrlRichEdit_AppendText($hRichEdit,$aTemp[$i] & ' ') next While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete() Exit EndSwitch WEnd kylomas1 point
-
RaiNote, Just remove the @CRLFs: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiRichEdit.au3> $hGui = GUICreate("RichEdit Test", 320, 350) $hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 10, 10, 300, 220, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) GUISetState() Sleep(1000) ; Write in black _GUICtrlRichEdit_WriteText($hRichEdit, "I am in BLACK ", Default, Default, 0x000000) Sleep(2000) ; Write in red _GUICtrlRichEdit_WriteText($hRichEdit, "I am in RED " & @CRLF, Default, Default, 0xFF0000) Sleep(2000) ; And back to black _GUICtrlRichEdit_WriteText($hRichEdit, "I am back in BLACK ", Default, Default, 0x000000) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete() Exit EndSwitch WEnd Func _GUICtrlRichEdit_WriteText($hWnd, $sText, $iIncrement = 0, $sAttrib = "", $iColor = -1) ; Count the @CRLFs StringReplace(_GUICtrlRichEdit_GetText($hWnd, True), @CRLF, "") Local $iLines = @extended ; Adjust the text char count to account for the @CRLFs Local $iEndPoint = _GUICtrlRichEdit_GetTextLength($hWnd, True, True) - $iLines ; Add new text _GUICtrlRichEdit_AppendText($hWnd, $sText) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ; Select text between old and new end points _GuiCtrlRichEdit_SetSel($hWnd, $iEndPoint, -1) ; Convert colour from RGB to BGR $iColor = Hex($iColor, 6) $iColor = '0x' & StringMid($iColor, 5, 2) & StringMid($iColor, 3, 2) & StringMid($iColor, 1, 2) ; Set colour If $iColor <> -1 Then _GuiCtrlRichEdit_SetCharColor($hWnd, $iColor) ; Set size If $iIncrement <> 0 Then _GUICtrlRichEdit_ChangeFontSize($hWnd, $iIncrement) ; Set weight If $sAttrib <> "" Then _GUICtrlRichEdit_SetCharAttributes($hWnd, $sAttrib) ; Clear selection _GUICtrlRichEdit_Deselect($hWnd) EndFuncM231 point
-
Maybe now you can, but we all change as developers. I am not writing code like I did 12 months ago, but then I am fortunate to have dipped my toe into other waters outside of the AutoIt lake of trust!1 point
-
just simple pass string with @crlf like "Hola" & @CRLF & "Como estas" Saludos1 point
-
@RaiNote - Take it easy, there's nothing alarming here. @NoiseBit - Patience, someone facile with IE (which excludes ne) will be along sooner or later. kylomas1 point
-
qwert, Before re-inventing the wheel you might want to check out kafu's SMF (Search My Files). He provided a link above. It is SQLite based and the interface is really slick. If nothing else you may get some ideas for a direction or technique. kylomas @ALL - SQLite Expert is a free SQLite manager. It is excellent for rapid prototyping and testing.1 point
-
Did you seriously just post your email address in a public forum?1 point
-
use global. Global $Var="Hi" test() changevar("Hola") test() changevar("Mundo") test() test("¿How Are you?") Func test($s=$Var) MsgBox(0,"",$s) EndFunc Func changevar($str) $Var=$str EndFunc So I do not recommend use that kind of parameter. I prefer keep just the global avoiding using it as parameter. Saludos1 point
-
; line 1 ; line 2 $res = StringRegExpReplace(FileRead(@ScriptFullPath), '^.*?\R', "") Msgbox(0,"", $res)1 point
-
add & @crlf Saludos1 point
-
#include <MsgBoxConstants.au3> Global $Skipline = 0 ;0==> first line Example() Func Example() ; Read the current script file into an array using the filepath. Local $aArray = FileReadToArray(@ScriptFullPath) If @error Then MsgBox($MB_SYSTEMMODAL, "", "There was an error reading the file. @error: " & @error) ; An error occurred reading the current script file. Else Local $temprf For $i = 0 To UBound($aArray) - 1 ; Loop through the array. If $Skipline = $i Then ContinueLoop $temprf &= $aArray[$i] Next EndIf MsgBox(0, 0, $temprf) EndFunc ;==>Example1 point
-
I was able to successfully use this once I went and enabled access for less secure apps here: https://www.google.com/settings/security/lesssecureapps1 point
-
Not really, because even if we say no, that shouldn't stop anyone from re-writing and posting in the examples section. Having it included as an official UDF is basically peace of mind for some people, though honestly whether it's in AutoIt or examples section, these days doesn't really matter. But please continue to re-write. If the code is structured well enough and all "checkboxes" for submission are checked, then I might be convinced to spend some time adding to the UDFs. Though again I make no guarantees that it will be included and will have to be impressed. As the current UDF isn't ready for submission!1 point
-
pdjhh, -1. No recorder included: For the very good reason explained in the first post - which is why you do not get a direct link. -2. no recorder listed on their website: And yet this thread is pinned on the main Help section of the forum for that very reason. -3. can't fill out a contact us form as it keep s saying it's spam: I get lots of emails from people using the contact form (in fact I have just dealt with one) - could it be you causing the problem? -4. website is covered in ads: AutoIt is entirely free - how else do you expect us to pay for the server costs? Anyway, as you seem to have so much trouble getting to the file I extracted it from the linked zip with no difficulty at all and it is now sitting on my hard drive - please PM me if you require a copy. M23 Edit: This is not a general offer. I expect anyone else to do extract the file themselves as it is trivial to do so, despite the protestations of a certain poster.1 point
-
Fran, Like you, I find RichEdit controls quite difficult to deal with. I wrote this little function a while ago to help me out - I hope you find it useful: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiRichEdit.au3> $hGui = GUICreate("RichEdit Test", 320, 350) $hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 10, 10, 300, 220, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) GUISetState() Sleep(2000) ; Increase by 12 pts, set to "bold" and colour red _GUICtrlRichEdit_WriteLine($hRichEdit, "I am the BIG Heading!" & @CRLF, +12, "+bo", 0xFF0000) Sleep(2000) ; Decrease by 6 pts, take away "bold" and colour Green _GUICtrlRichEdit_WriteLine($hRichEdit, "I am the smaller Subheading!" & @CRLF, -6, "-bo", 0x00FF00) Sleep(2000) ; Reduce by the other 6 pts, leave the attibutes alone and colour black _GUICtrlRichEdit_WriteLine($hRichEdit, "I am normal text!" & @CRLF, -6, "", 0x000000) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete() Exit EndSwitch WEnd Func _GUICtrlRichEdit_WriteLine($hWnd, $sText, $iIncrement = 0, $sAttrib = "", $iColor = -1) ; Count the @CRLFs StringReplace(_GUICtrlRichEdit_GetText($hWnd, True), @CRLF, "") Local $iLines = @extended ; Adjust the text char count to account for the @CRLFs Local $iEndPoint = _GUICtrlRichEdit_GetTextLength($hWnd, True, True) - $iLines ; Add new text _GUICtrlRichEdit_AppendText($hWnd, $sText & @CRLF) ; Select text between old and new end points _GuiCtrlRichEdit_SetSel($hWnd, $iEndPoint, -1) ; Convert colour from RGB to BGR $iColor = Hex($iColor, 6) $iColor = '0x' & StringMid($iColor, 5, 2) & StringMid($iColor, 3, 2) & StringMid($iColor, 1, 2) ; Set colour If $iColor <> -1 Then _GuiCtrlRichEdit_SetCharColor($hWnd, $iColor) ; Set size If $iIncrement <> 0 Then _GUICtrlRichEdit_ChangeFontSize($hWnd, $iIncrement) ; Set weight If $sAttrib <> "" Then _GUICtrlRichEdit_SetCharAttributes($hWnd, $sAttrib) ; Clear selection _GUICtrlRichEdit_Deselect($hWnd) EndFuncAs you can see, you have to amend the size and attibutes of the text relative to the previous insertion - not what we are used to, so be careful here. All clear? M231 point