Jump to content

Autoit Wrappers


Valuater
 Share

Recommended Posts

; _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 by Valuater

NEWHeader1.png

Link to comment
Share on other sites

; _RemoveLineInFile

; Author - th.meger

#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 by Valuater

NEWHeader1.png

Link to comment
Share on other sites

; 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)

NEWHeader1.png

Link to comment
Share on other sites

; 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

Link to comment
Share on other sites

  • 2 weeks later...
  • 4 weeks later...

; 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)
EndFunc

see extended versions here

http://www.autoitscript.com/forum/index.ph...st&p=270412

8)

NEWHeader1.png

Link to comment
Share on other sites

; 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 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

  • 2 weeks later...

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

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

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

  • 3 weeks later...

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

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Link to comment
Share on other sites

  • Moderators

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
Looks 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 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

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)

NEWHeader1.png

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...