Jump to content

Autoit Wrappers


Valuater
 Share

Recommended Posts

Page 1 - 12/21/2005

****************************************************************************

* = Newest * = Newer

Program Security

Protect and get Paid

30 Day Trial

Password Encryptor

UUID Generator

Decompile to Desktop

Delete Running Program

Notify and Name of any New Process Started

Allow only one Window

Add User Accounts

Check File Date to Current Date

Stop Program from Running Twice

Detect if System is Locked *

Program Animations

Skins for your GUI

GUI Hole - Great!

Animated Gif

GUI Animate Display

Set Mouse Cursor Style

Round GUI Corners

Move A Maximized Window

Detect Window Flashing in TaskBar *

Custom GUI Cursor *

Controls

Get ALL Controls Information

Icon on Button with Text (made easy)

Picture Buttons ( great example )

Moving a Control ( in script )

Control Button by HotKey

If Radio or Checkbox is Checked

Control XP Style for Colors

Get Key State Pressed/Released

Two Tray Menus - Right & Left Click *

Controling Window/GUI

Center Window/GUI on Screen

Center - File Open/Save/Folder Dialog Box

Get Active Window (Title)(Text)

Get Active Window - Executable Path

Change Message Box button text

Move Message Box

Place InputBox OnTop

Run Program in CMD.exe Window with Changed Title.

Examples of using @Comspec

Window Active/Activate by Exe

Get Window Handle by PID

Move any Window - Click & Drag *

Check if Mouse is over a GUI *

UpDates

Auto-request user to update

Locate Autoit/Beta Directory

Get the Latest Beta

Miscellaneous

File size difference before (au3) and after (exe)...

Re-Start your Program

Run any au3 File from Your Program

Get Wave Sound Volume

Reduce Memory Usage

Voice Read Text

Voice Read Text & Save to wav file

Create a "Quick Launch" Shortcut

Windows - copy with progress

Finding if an Application is Hung

Terminate a Script Right before a User Shuts-Down

Read the Last Line of a Text File

Create a Temporary File Name

OEM to ANSI & Reverse

Open Help file to a desired page

Calculate the distance between 2 points

Charactor Generator - chars (0-9, A-Z)

Get Last Error Message *

Strings and Arrays

Find a String within a String or Array

Regular Expressions to find something in an Array

Sort Arrays based on TRUE Numerical Order, including Decimals

Return Min or Max number from 1 or 2 Arrays

Check(when Exit), if Text is not equal Then, prompt the user to save or not save.

Identify duplicate values in arrays

Unique Array Filter

Remove a Line from a File

String Remove a Line

Remove blank lines from a File

Validate String & Validate IP Address *

Controling Screen/View

Toggle Internet Images On/Off

Draw a line on any Screen/Program

Toggle Monitor On/Off

Swith BGR to RGB Color

Mouse repel - keep mouse away from an area

Time Controls

User/System Idle time

Time to Thousandths of a second

Time Machine #1 - Start (program) in Minutes/seconds/miliseconds

Time Machine #2 - Start (program) in Hours & Minutes

Time Machine #3 - Start (program) on Day & Hour

12 Hour Time converter

Run a timed program daily

add your Favorites too!!

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

;Get Wav Sound Volume
; Author gafrost

#include <GUIConstants.au3>

MsgBox(0,"", _SoundGetWaveVolume())

Func _SoundGetWaveVolume()
    Local $WaveVol = -1, $p, $ret
    Const $MMSYSERR_NOERROR = 0
    $p = DllStructCreate ("dword")
    If @error Then
        SetError(2)
        Return -2
    EndIf
    $ret = DllCall("winmm.dll", "long", "waveOutGetVolume", "long", -1, "long", DllStructGetPtr ($p))
    If ($ret[0] == $MMSYSERR_NOERROR) Then
        $WaveVol = Round(Dec(StringRight(Hex(DllStructGetData ($p, 1), 8), 4)) / 0xFFFF * 100)
    Else
        SetError(1)
    EndIf
    $Struct=0 
    Return $WaveVol
EndFunc;==>_SoundGetWaveVolume




run("sndvol32.exe")
WinWait("")
ControlSend("Volume Control", "", "msctls_trackbar322", "{PGUP}")
sleep(1000)
ControlSend("Volume Control", "", "msctls_trackbar322", "{PGUP}")
sleep(1000)
ControlSend("Volume Control", "", "msctls_trackbar322", "{PGUP}")
sleep(1000)
ControlSend("Volume Control", "", "msctls_trackbar322", "{PGDN}")
sleep(1000)
ControlSend("Volume Control", "", "msctls_trackbar322", "{PGDN}")
sleep(1000)
ControlSend("Volume Control", "", "msctls_trackbar322", "{PGDN}")



Global Const $TBM_GETPOS = $TWM_USER
Func _GUICtrlSliderGetPos($h_slider)
   Local $ret
   $ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_slider, "int", $TBM_GETPOS, "int", 0, "int", 0)
   Return $ret[0]
EndFunc;==>_GUICtrlSliderGetPos

 $ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_slider, "int", $TBM_GETPOS, "int", 0, "int", 0)

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

Page 1 - 12/21/2005

****************************************************************************

*******************************************************************************

;Animate Display *nice* addition
; Author ( under research )

***********************************************************************************

I thought it was Raindancer .... :P

http://www.autoitscript.com/forum/index.ph...indpost&p=84102

Link to comment
Share on other sites

  • 3 weeks later...

; Center Window on Screen
; Author cdkid and Valuater

Func _Middle($win, $txt)
    $size = WinGetClientSize($win, $txt)
    Local $y = (@DesktopHeight / 2) - ($size[1] / 2)
    Local $x = (@DesktopWidth / 2) - ($size[0] / 2)
    Return WinMove($win, $txt, $x, $y)
EndFunc  ;==>_Middle

NEWHeader1.png

Link to comment
Share on other sites

; Center - File Open/Save/Folder Dialog Box
;Author - odklizec, MHz, Danny35d
 
 If StringInStr($cmdlineraw, '/MoveWin') Then
     $cmdlineraw = StringSplit(StringMid($cmdlineraw, StringInStr($cmdlineraw, '/MoveWin')), ':')
     While 1
         Select
         Case WinExists($cmdlineraw[2])
             $size=WinGetPos ($cmdlineraw[2])
             $PosX=@DesktopWidth/2 - $size[2]/2
             $PosY=@DesktopHeight/2 - $size[3]/2
             WinMove($cmdlineraw[2], "", $PosX, $PosY)
             WinActivate($cmdlineraw[2])
             ExitLoop
         EndSelect
         Sleep(50)
     WEnd
     Exit
 EndIf
 
 $PID = _FindBrowseWin('Open file Dialog Box')
 $Read_File = FileOpenDialog ( "Open file Dialog Box", @ScriptDir & "\", "AutoIt Files (*.au3)",3,@ScriptFullPath)
 ProcessClose($PID)
 $PID = _FindBrowseWin('Save file Dialog Box')
 $Save_File = FileSaveDialog( "Save file Dialog Box", @ScriptDir, "Scripts (*.aut;*.au3)", 3)
 ProcessClose($PID)
 $PID = _FindBrowseWin('Browse for Folder')
 FileSelectFolder("Choose a folder with plugins..", "","4","c:\")
 ProcessClose($PID)
 
 Func _FindBrowseWin($sTitle)
     If @Compiled Then
         Return(Run(@ScriptFullPath & ' /MoveWin:' & $sTitle))
     Else
         Return(Run(@AutoItExe & ' "' & @ScriptFullPath & '" /MoveWin:' & $sTitle))
     EndIf
 EndFunc

SvenP posted a COM- based method here that happens to open up centered

Important Note: Rename CreateObject to ObjCreate so that the code runs under the current beta version of AutoIt.

Another ...

; Author /dev/null

$message = "Hold down Ctrl or Shift to choose multiple files."

$filename = _MoveFileOpenDialog($message,300,300)

$var = FileOpenDialog($message, @WindowsDir & "\", "Images (*.jpg;*.bmp)", 1 + 4 )

If @error Then
    MsgBox(4096,"","No File(s) chosen")
Else
    $var = StringReplace($var, "|", @CRLF)
    MsgBox(4096,"","You chose " & $var)
EndIf

FileDelete($filename)
func _MoveFileOpenDialog($title,$posx,$posy)
    Local $temp = EnvGet("temp")
    Local $filename = $temp & "\move_file_open_dialog.au3"
   
    Local $script = 'Global $title = "' & $title & '"' & @CRLF
    $script &= 'Global $pos_x = ' & $posx & @CRLF
    $script &= 'Global $pos_y = ' & $posy & @CRLF
    $script &= 'AdlibEnable("_Move",10)' & @CRLF
    $script &= 'while 1' & @CRLF
    $script &= '    sleep(1000)' & @CRLF
    $script &= 'wend' & @CRLF
    $script &= 'Func _Move()' & @CRLF
    $script &= '   if (WinActive($title)) Then' & @CRLF
    $script &= '      WinMove($title,"",$pos_x,$pos_y)' & @CRLF
    $script &= '      Exit' & @CRLF
    $script &= '   EndIf' & @CRLF
    $script &= 'EndFunc' & @CRLF

    FileWrite($filename,$script)
    ;MsgBox(0,"",$script & @CRLF & $filename)
    Run(@AutoItExe & " /AutoIt3ExecuteScript " & $filename)
    sleep(250)
    Return $filename
EndFunc

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

; Reduce memory usage
; Author wOuter ( mostly )

Func _ReduceMemory($i_PID = -1)
    
    If $i_PID <> -1 Then
        Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID)
        Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
        DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
    Else
        Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
    EndIf
    
    Return $ai_Return[0]
EndFunc;==> _ReduceMemory()

NEWHeader1.png

Link to comment
Share on other sites

; find a string within a string
; Author - This-is-me

Func stringbetween($str, $start, $end)
    $pos = StringInStr($str, $start)
    If Not @error Then
        $str = StringTrimLeft($str, $pos + StringLen($start) - 1)
        $pos = StringInStr($str, $end)
        If Not @error Then
            $str = StringTrimRight($str, StringLen($str) - $pos + 1)
            Return $str
        EndIf
    EndIf
EndFunc

*************************************************************************

; find a string in an array
; Aurhor - SmOke_N

Func _ReturnStringArraySearch(ByRef $n_Array, $f_FindString)
    For $i = 1 To UBound($n_Array) - 1
        If StringInStr($n_Array[$i], $f_FindString) Then Return $n_Array[$i]
    Next
EndFunc

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

  • Moderators

Val!!... StringBetween()... I would have never hand looked at google if I hadn't been asked to help with that very subject a while back until you posted that.

This-Is-Me link: http://www.autoitscript.com/forum/index.ph...indpost&p=37172

Link to where we did several different ways:

http://www.autoitscript.com/forum/index.ph...718&mode=linear

The one I use (w0uter):

http://www.autoitscript.com/forum/index.ph...ndpost&p=136319

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

; voice read text
; Author erifash ( and others )

_TalkOBJ("Speak this line of text")

Func _TalkOBJ($s_text)
    Local $o_speech
    $o_speech = ObjCreate("SAPI.SpVoice")
    $o_speech.Speak ($s_text)
    $o_speech = ""
EndFunc ;==>_TalkOBJ

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

I use this one quite often :lmao:

Use regular expressions in an array.

;
; use regular exp[b][/b]ressions to find something in an array
; Author: WhiteCrow (but anyone couldve made it)
;
Func _FindAny($start, $End, $s_array,  $reg_exp[b][/b]ression)

For $Pos = $start To $End
        $ip_regex=StringRegExp ( $s_array[$pos], $reg_exp[b][/b]ression, 1 )
if @error=0 then
    If @extended=1 Then
        Return $Pos
        EndIf
  endif
Next
Return -1
EndFunc

This just returns the position, i ussualy do something with $ip_regex to ;)

Edited by WhiteCrow
Link to comment
Share on other sites

; Notify and Name of any new process started
; Author Valuater

Dim $list = ProcessList()

AdlibEnable("chk_Process")

While 1
    Sleep(20)
WEnd

Func chk_Process()
    $list2 = ProcessList()
    If $list2[0][0] > $list[0][0] Then
        MsgBox(262208,"New Process", $list2[$list2[0][0]][0] & "  ")
        $list[0][0] = $list2[0][0]
    Else
        $list[0][0] = $list2[0][0]
   ; if you close processes - this resets the list
    EndIf
EndFunc

8)

NEWHeader1.png

Link to comment
Share on other sites

; Reduce memory usage
; Author wOuter ( mostly )

Func _ReduceMemory($i_PID = -1)
    
    If $i_PID <> -1 Then
        Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID)
        Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
        DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
    Else
        Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
    EndIf
    
    Return $ai_Return[0]
EndFunc;==> _ReduceMemory()

dumb question... but how does this work???

Link to comment
Share on other sites

  • 3 weeks later...

; Locate Autoit/Beta Directory
; Author - MHz

MsgBox(0, 'AutoIt Directory returned', _DirAutoIt('Beta'))

Func _DirAutoIt($version = 'Prod')
    Switch $version
        Case 'Prod'
            Switch True
                Case FileExists(@ProgramFilesDir & '\AutoIt3')
                    Return @ProgramFilesDir & '\AutoIt3'
                Case RegRead('HKLM\SOFTWARE\AutoIt v3\AutoIt', 'InstallDir')
                    Return RegRead('HKLM\SOFTWARE\AutoIt v3\AutoIt', 'InstallDir')
            EndSwitch
        Case 'Beta'
            Switch True
                Case FileExists(@ProgramFilesDir & '\AutoIt3\Beta')
                    Return @ProgramFilesDir & '\AutoIt3\Beta'
                Case RegRead('HKLM\SOFTWARE\AutoIt v3\AutoIt', 'betaInstallDir')
                    Return RegRead('HKLM\SOFTWARE\AutoIt v3\AutoIt', 'betaInstallDir')
            EndSwitch
    EndSwitch
    If $version = 'Prod' Then $version = 'Public Release'   
    Return FileSelectFolder('Locate AutoIt Directory  (' & $version & ' version)', @HomeDrive)
EndFunc

thx

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

; Get the Latest Beta
; Author - Valuater

#include <INet.au3>
$NBeta = _INetGetSource('http://www.autoitscript.com/autoit3/files/beta/autoit/')
For $x = 500 to 104 Step -1
    If StringInStr( $NBeta, "autoit-v3.1.1."& $x & "-beta-Setup.exe") Then
        $NBeta = "autoit-v3.1.1."& $x & "-beta-Setup.exe"
        ExitLoop
    EndIf
    If $x <= 105 Then
        MsgBox(262208, "Beta Error", "No File Found.   ", 5)
        Return
    EndIf
Next
MsgBox(0,'',$NBeta)
; use InetGet()

8)

NEWHeader1.png

Link to comment
Share on other sites

; voice read text
; Author erifash ( and others )

_TalkOBJ("Speak this line of text")

Func _TalkOBJ($s_text)
    Local $o_speech
    $o_speech = ObjCreate("SAPI.SpVoice")
    $o_speech.Speak ($s_text)
    $o_speech = ""
EndFunc;==>_TalkOBJ

8)

I use _Talkobj() in a lot of apps, that often attempt to speak at the same time, and I have had to use the following to avoid an AutoIt error: Checking @error or for $o_speech=0 did not work, but this does.

Do

Sleep(100)

Local $o_speech = ObjCreate ("SAPI.SpVoice")

Until IsObj ($o_speech)

Talking Clockhttp://www.autoitscript.com/forum/index.php?showtopic=20751Talking Headlineshttp://www.autoitscript.com/forum/index.php?showtopic=20655Sometimes, I sits and thinkssometimes, I just sits

Link to comment
Share on other sites

I use this one quite often ;)

Use regular expressions in an array.

;
; use regular exp[b][/b]ressions to find something in an array
; Author: WhiteCrow (but anyone couldve made it)
;
Func _FindAny($start, $End, $s_array,  $reg_exp[b][/b]ression)

For $Pos = $start To $End
        $ip_regex=StringRegExp ( $s_array[$pos], $reg_exp[b][/b]ression, 1 )
if @error=0 then
    If @extended=1 Then
        Return $Pos
        EndIf
  endif
Next
Return -1
EndFunc

This just returns the position, i ussualy do something with $ip_regex to :king:

now, that was useful. I managed to make an _ArraySearchWithWildcards with it o:)

edit: ok, _ArraySearchWithWildcrads didnt work... :lmao:

Edited by theguy0000

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

  • 2 weeks later...

; ArraySortNum(ByRef $nArray, $Ascending = 0, $Start = 1)
; Sorts arrays based on TRUE Numerical Order, including Decimals
: Author - SmOke_N

#include <Array.au3>

; Example sort Array created with StringSplit.
$avArray = StringSplit("6,8,10,4,2,13,12,129,106.1,106.4",",")

ArraySortNum($avArray, 1)
_ArrayDisplay( $avArray, "Sorted Desc starting at 1" )

Func ArraySortNum(ByRef $nArray, $Ascending = 0, $Start = 1)
    For $i = $Start To UBound($nArray) - 2
        Local $SE = $i
        If $Ascending = 0 Then
            For $x = $i To UBound($nArray) - 1
                If Number($nArray[$SE]) < Number($nArray[$x]) Then $SE = $x
            Next
        Else
            For $x = $i To UBound($nArray) - 1
                If Number($nArray[$SE]) > Number($nArray[$x]) Then $SE = $x
            Next
        EndIf
        Local $HLD = $nArray[$i]
        $nArray[$i] = $nArray[$SE]
        $nArray[$SE] = $HLD
    Next
EndFunc

thanks... SmOke

OR.................

; Author JdeB

#include <Array.au3>
$result = StringSplit(".125,555,011,6,72,-333", ",")
For $x = 1 To UBound($result) -1
    $result[$x] = Number($result[$x])
Next
_ArraySort($result, 1, 1)
_ArrayDisplay($result,"list")

Thanks... JdeB

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

; create a "Quick Launch" Shortcut
; Author CyberSlug

; Tested on Windows XP
$userQuickLaunchPath = @AppDataDir & "\Microsoft\Internet Explorer\Quick Launch"
$globalQuickLaunchPath = @AppDataCommonDir & "\Microsoft\Internet Explorer\Quick Launch"

$shortcutTarget = @WindowsDir & "\notepad.exe";pick whatever you want
FileCreateshortcut($shortcutTarget, $userQuickLaunchPath & "\Notepad.lnk")

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