Valuater Posted October 17, 2006 Author Share Posted October 17, 2006 (edited) ; _StringRemoveLine ; Author SmOke_N $string = 'This is an example' & @CRLF & 'Of deleting a line' & @CRLF & 'If you know at least the beginning text of the line.' MsgBox(0, 'Original', $string) $deleteline = _StringRemoveLine($string, 'Of deleting') MsgBox(0, 'Deleted Line', $deleteline) Func _StringRemoveLine($hFile, $sDelete) If FileExists($hFile) Then $hFile = FileRead($hFile);Remove If FileExists($hFile) Then << only Local $nSNS = StringInStr($hFile, @CRLF & $sDelete) - 1 Local $sSFH = StringLeft($hFile, $nSNS) Local $sRL = StringTrimLeft($hFile, StringLen($sSFH) + 2) Local $sLLEN = StringLen(StringLeft($sRL, StringInStr($sRL, @CRLF))) If Not $sLLEN Then $sLLEN = StringLen($sRL) Return $sSFH & StringTrimLeft($hFile, $sLLEN + $nSNS + 2) EndFunc 8) Edited October 17, 2006 by Valuater Link to comment Share on other sites More sharing options...
Valuater Posted October 17, 2006 Author Share Posted October 17, 2006 (edited) ; _RemoveLineInFile ; Author - th.meger expandcollapse popup#include <File.au3> #include <Array.au3> _removeLineInFile("c:\Autoit_UDF.txt", "Autoit", 1) _removeLineInFile("c:\Autoit_UDF.txt", "Autoit", 2) _removeLineInFile("c:\Autoit_UDF.txt", "Autoit", 3) _removeLineInFile("c:\Autoit_UDF.txt", "Autoit", 3, 0) _removeLineInFile("c:\Autoit_UDF.txt", "Autoit", 3, 1) _removeLineInFile("c:\Autoit_UDF.txt", "Autoit", 3, 1, "c:\Autoit_UDF_removesLinesContaingAutoit.txt") ; or use varibales Global $path = "c:\Autoit_UDF.txt" Global $NewPath = "c:\Autoit_UDF_removesLinesContaingAutoit.txt" Global $search = "Autoit" MsgBox(64, "To see the return value", _removeLineInFile($path, $search, 3, 1, $NewPath)) ; display the return value ;=============================================================================== ; ; Function Name: _removeLineInFile ; Description:: _removeLineInFile ; Parameter(s): ; 1. $h_path = Path to file ; 2. $s_search = string pattern ; 3. Opt = 1 Delete line if matches $s_search ; 3. Opt = 2 Delete line if starts with $s_search ; 3. Opt = 3 Delete line if contains $s_search ; 3. Opt = 3 + Parameter 4 : ; 4. 0 = not case sensitive (default) ; 4. 1 = case sensitive ; 5.$h_pathNew = "" file will be overwritten ; 5. $h_pathNew = ... the result is saved in new path ; ; Requirement(s): #include <file.au3> and #include <Array.au3> ; Return Value(s): 1 success ; Return Value(s): -1 file not found ; Return Value(s): -2 invalid path to write ; Author(s): th.meger ; ;=============================================================================== ; Func _removeLineInFile($h_path, $s_search, $i_opt = 1, $i_CaseSensitive = 0, $h_pathNew = "") Local $a_FileOne Local $a_FileTwo[1] If $h_pathNew = "" Then $h_pathNew = $h_path EndIf If Not _FileReadToArray($h_path, $a_FileOne) Then Return -1 For $i = 1 To $a_FileOne[0] Switch $i_opt Case 1 If $a_FileOne[$i] <> $s_search Then _ArrayAdd($a_FileTwo, $a_FileOne[$i]) Case 2 If StringLeft($a_FileOne[$i], StringLen($s_search)) <> $s_search Then _ArrayAdd($a_FileTwo, $a_FileOne[$i]) Case 3 If StringInStr($a_FileOne[$i], $s_search, $i_CaseSensitive) = 0 Then _ArrayAdd($a_FileTwo, $a_FileOne[$i]) EndSwitch Next _FileWriteFromArray($h_pathNew, $a_FileTwo, 1) If @error = 0 Then Return 1 Return -2 EndFunc ;==>_removeLineInFile 8) Edited October 18, 2006 by Valuater Link to comment Share on other sites More sharing options...
Valuater Posted October 18, 2006 Author Share Posted October 18, 2006 ; Window Active/Activate by Exe ; Author - SmOke_N While 1 If _WinActiveByExe('notepad.exe', False) Then MsgBox(64, 'info', 'true') Sleep(100) WEnd Func _WinActiveByExe($sExe, $iActive = True);False to WinActivate, True to just see if it's active If Not ProcessExists($sExe) Then Return SetError(1, 0, 0) Local $aPL = ProcessList($sExe) Local $aWL = WinList() For $iCC = 1 To $aWL[0][0] For $xCC = 1 To $aPL[0][0] If $aWL[$iCC][0] <> '' And _ WinGetProcess($aWL[$iCC][1]) = $aPL[$xCC][1] And _ BitAND(WinGetState($aWL[$iCC][1]), 2) Then If $iActive And WinActive($aWL[$iCC][1]) Then Return 1 If Not $iActive And Not WinActive($aWL[$iCC][1]) Then WinActivate($aWL[$iCC][1]) Return 1 EndIf EndIf Next Next Return SetError(2, 0, 0) EndFunc 8) Doniel 1 Link to comment Share on other sites More sharing options...
Ed_Maximized Posted October 19, 2006 Share Posted October 19, 2006 ; Animated Gif ; Author - gafrost Opt("MustDeclareVars", 1) #include <IE.au3> _Main() Func _Main() Local $pheight = 50, $pwidth = 50, $oIE, $GUIActiveX, $gif $gif = FileOpenDialog("Select Animated Gif", @ScriptDir, "gif files (*.gif)", 3) If @error Then Exit _GetGifPixWidth_Height($gif, $pwidth, $pheight) $oIE = ObjCreate("Shell.Explorer.2") GUICreate("Embedded Web control Test", 640, 580) $GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, $pwidth, $pheight) $oIE.navigate ("about:blank") While _IEPropertyGet($oIE, "busy") Sleep(100) WEnd $oIE.document.body.background = $gif $oIE.document.body.scroll = "no" GUISetState() While GUIGetMsg() <> -3 WEnd EndFunc ;==>_Main Func _GetGifPixWidth_Height($s_gif, ByRef $pwidth, ByRef $pheight) If FileGetSize($s_gif) > 9 Then Local $sizes = FileRead($s_gif, 10) ConsoleWrite("Gif version: " & StringMid($sizes, 1, 6) & @LF) $pwidth = Asc(StringMid($sizes, 8, 1)) * 256 + Asc(StringMid($sizes, 7, 1)) $pheight = Asc(StringMid($sizes, 10, 1)) * 256 + Asc(StringMid($sizes, 9, 1)) ConsoleWrite($pwidth & " x " & $pheight & @LF) EndIf EndFunc ;==>_GetGifPixWidth_Height Example file..... 8) I think you should actualize to this http://www.autoitscript.com/forum/index.ph...st&p=251468 ShapedGUI Creator : Shaped gui the easy way!!!Txt2au3 : the easy way to include text files into your program without fileinstall_GUICreateWithTiledBackground : Put a GIF in the background of your formsSQLite Database BrowserAnimated GIF UDF : Put animations in your GUI's Link to comment Share on other sites More sharing options...
Valuater Posted October 19, 2006 Author Share Posted October 19, 2006 I think you should actualize to thishttp://www.autoitscript.com/forum/index.ph...st&p=251468Done!8) Link to comment Share on other sites More sharing options...
Valuater Posted October 28, 2006 Author Share Posted October 28, 2006 ; Calculate the Distance between two points ; Author - SolidSnake Func _Distance($iX1, $iY1, $iX2, $iY2) Return Sqrt(($iX1 - $iX2) ^ 2 + ($iY1 - $iY2) ^ 2) EndFunc ;==>_Distance 8) Link to comment Share on other sites More sharing options...
Valuater Posted November 20, 2006 Author Share Posted November 20, 2006 ; Control Button by HotKey ; Author - SmOke_N Global $fClickit, $Main, $Button HotKeySet('+4', '_ClickButton') $Main = GUICreate('Some GUI', 200, 100) $Button = GUICtrlCreateButton('Some Button To Click', 10, 35, 180, 30) GUISetState() While 1 Switch GUIGetMsg() Case - 3 Exit Case $Button If Not $fClickit Then MsgBox(64, 'Clicked', 'You clicked the button') Else $fClickit = Not $fClickit MsgBox(64, 'Clicked', 'You used a hotkey to click the button') EndIf EndSwitch WEnd Func _ClickButton() $fClickit = Not $fClickit ControlClick(HWnd($Main), '', $Button) EndFuncsee extended versions herehttp://www.autoitscript.com/forum/index.ph...st&p=2704128) Link to comment Share on other sites More sharing options...
Valuater Posted November 21, 2006 Author Share Posted November 21, 2006 ; Open help file / Open a desired page ; Author - gafrost $sAutoItPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir") Run(@WindowsDir & "\HH.exe " & $sAutoItPath & "\AutoIt3.chm::/html/functions/GUICtrlCreateUpdown.htm") 8) Link to comment Share on other sites More sharing options...
RazerM Posted November 22, 2006 Share Posted November 22, 2006 (edited) ; Switch BGR to RGB and vice versa ; Author - RazerM ConsoleWrite(0xFF0000 = SwitchColor(0x0000FF)) ConsoleWrite(@CRLF) Func SwitchColor ($iColor) Local $iMask $iMask = BitXOR(BitAND($iColor, 0xFF) , ($iColor / 0x10000)) Return BitXOR($iColor, ($iMask * 0x10001)) EndFunc ;==>SwitchColor Edited November 22, 2006 by RazerM My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop. Link to comment Share on other sites More sharing options...
BigDod Posted December 1, 2006 Share Posted December 1, 2006 Any chance that this topic could be stickied as it is very useful and keeps dropping from view. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
theguy0000 Posted December 1, 2006 Share Posted December 1, 2006 Any chance that this topic could be stickied as it is very useful and keeps dropping from view. agreed The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN Link to comment Share on other sites More sharing options...
NELyon Posted December 1, 2006 Share Posted December 1, 2006 I agree too Link to comment Share on other sites More sharing options...
Xenobiologist Posted December 1, 2006 Share Posted December 1, 2006 Hi, me too, but then somebody should delete the posts between the useful stuff. The posts like the one i am writing yet, too. So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
RazerM Posted December 1, 2006 Share Posted December 1, 2006 Or combine them into the first post? I agree it should be stickied though. My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop. Link to comment Share on other sites More sharing options...
ConsultingJoe Posted December 20, 2006 Share Posted December 20, 2006 Simple 12 hour time converter: Func Time() If @HOUR > 12 Then $hour = @HOUR - 12 $AMPM = "PM" ElseIf @HOUR = 0 Then $hour = 12 $AMPM = "AM" Else $hour = @HOUR $AMPM = "AM" EndIf Return $hour & ":" & @MIN & $AMPM EndFunc Check out ConsultingJoe.com Link to comment Share on other sites More sharing options...
Valuater Posted December 22, 2006 Author Share Posted December 22, 2006 ; Speak Object and save to wav file ; Author - SolidSnake _SpeakToWAV("TEST",@ScriptDir&"\respond.wav") Func _SpeakToWAV($sText,$sFile) $ObjVoice=ObjCreate("Sapi.SpVoice") $ObjFile=ObjCreate("SAPI.SpFileStream.1") $objFile.Open($sFile,3) $objVoice.AudioOutputStream = $objFile $objVoice.Speak ($sText) EndFunc 8) Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 22, 2006 Moderators Share Posted December 22, 2006 (edited) Simple 12 hour time converter: Func Time() If @HOUR > 12 Then $hour = @HOUR - 12 $AMPM = "PM" ElseIf @HOUR = 0 Then $hour = 12 $AMPM = "AM" Else $hour = @HOUR $AMPM = "AM" EndIf Return $hour & ":" & @MIN & $AMPM EndFuncLooks familiar, like something I did when helping someone write their alarm clock. Edit: Had to find it: http://www.autoitscript.com/forum/index.ph...st&p=235677 Edited December 22, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Valuater Posted December 22, 2006 Author Share Posted December 22, 2006 heres mine too to run ( exit loop ) at a specific time Func Set_Timed($rt) $split = StringSplit($rt, ":") If $split[0] <> 2 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf Tray_msg("Timed Run is Set at " & $split[1] & ":00 " & $split[2] & @CRLF & "and will be initiated at the scheduled time... thank you ") While 1 $hour = @HOUR If $hour >= 1 And $hour <= 12 Then $amp = "am" ElseIf $hour >= 13 Then $amp = "pm" $hour = $hour - 12 Else ; 00 - for 24th hour $hour = 12 $amp = "am" EndIf If $hour = $split[1]And $amp = $split[2] And @MIN <=2 Then ExitLoop Sleep($time * 10) WEnd EndFunc ;==>Set_Timed 8) Link to comment Share on other sites More sharing options...
Zedna Posted December 22, 2006 Share Posted December 22, 2006 Func _OEM2ANSI($what) $ret = DllCall('user32.dll','Int','OemToChar','str',$what,'str','') Return $ret[2] EndFunc Func _ANSI2OEM($what) $ret = DllCall('user32.dll','Int','CharToOem','str',$what,'str','') Return $ret[2] EndFunc Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Zedna Posted December 22, 2006 Share Posted December 22, 2006 Func _IsChecked($control) Return BitAnd(GUICtrlRead($control),$GUI_CHECKED) = $GUI_CHECKED EndFunc Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Recommended Posts