Jump to content
Valuater

Autoit Wrappers

Recommended Posts

Valuater

; add user accounts
; Author - MHz

_NetUser('Jack', 'pw_abc')
_NetUser('Jill', 'pw_def')

Func _NetUser($name, $password = '', $groupname = 'Administrators', $autologon = 0)
; Creates user accounts. Only 1 user can have autologon, if set.
    Local $key
    If Not FileExists(EnvGet('AllUsersProfile') & '\..\' & $name) Then
        RunWait(@ComSpec & ' /c ' & _
                'Net User ' & $name & ' ' & $password & ' /add &&' & _
                'Net LocalGroup ' & $groupname & ' ' & $name & ' /add &' & _
                'Net Accounts /MaxPwAge:UnLimited', '', @SW_HIDE)
        If $autologon Then
            $key = 'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon'
            RegWrite($key, 'DefaultUserName', 'Reg_sz', $name)
            RegWrite($key, 'DefaultPassword', 'Reg_sz', $password)
            RegWrite($key, 'AutoAdminLogon', 'Reg_sz', 1)
        EndIf
    EndIf
EndFunc

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Valuater

; Get ALL controls Info
; Author - CyberSlug ( dusted-off old code )

$title = "Calculator"
Run("calc.exe")
WinWait($title)
MsgBox( 0x0,"Info", _getClasses($title) )
Exit

; This function returns an @LF-separted list of controls on the specified window
Func _getClasses($title)
;Get array of each control
    Local  $buttonCount = 0, $editCount = 0, $staticCount = 0, $i
    Local $classes = StringSplit(  WinGetClassList($title) , @LF)
    Local  $classIDs[$classes[0]+1]
    $classIDs[0] = $classes[0]
    For $i = 1 to $classes[0]
      Select
      Case $classes[$i] = "Button"
         $buttonCount = $buttonCount + 1
         $classIDs[$i] = $classes[$i] & $buttonCount
      Case $classes[$i] = "Edit"
         $editCount = $editCount + 1
         $classIDs[$i] = $classes[$i] & $editCount
         $classes[$i] = "Input"
      Case $classes[$i] = "Static"
         $staticCount = $staticCount + 1
         $classIDs[$i] = $classes[$i] & $staticCount
         $classes[$i] = "Label"
     Case Else
         If $classes[$i] <> "" Then $classIDs[$i] = $classes[$i] & "?"
      EndSelect
    Next

;Display the results
    Local $output = ""
    For $i = 1 to $classIDs[0]
        $output = $output & $classIDs[$i] & @LF
    Next
    Return $output
EndFunc

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Valuater

; timer to "thousandths" of a second
; Author - Holger 

While 1
    ToolTip(@Hour & ':' & @Min & ':' & @Sec & ':' & _MSec())
    Sleep(1)
WEnd

Exit

Func _MSec()
    Local $stSystemTime = DllStructCreate('ushort;ushort;ushort;ushort;ushort;ushort;ushort;ushort')
    DllCall('kernel32.dll', 'none', 'GetSystemTime', 'ptr', DllStructGetPtr($stSystemTime))

    $sMilliSeconds = StringFormat('%03d', DllStructGetData($stSystemTime, 8))
    
    $stSystemTime = 0
    
    Return $sMilliSeconds
EndFunc

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites
jftuga

; Move Message Box
; Author - herewasplato

_MoveMsgBox(0, "testTitle", "testText", 0, 10)

Func _MoveMsgBox($MBFlag, $MBTitle, $MBText, $x, $y)
    Local $file = FileOpen(EnvGet("temp") & "\MoveMB.au3", 2)
    If $file = -1 Then Return;if error, give up on the move
    
    Local $line1 = 'AutoItSetOption(' & '"WinWaitDelay", 0' & ')'
    Local $line2 = 'WinWait("' & $MBTitle & '", "' & $MBText & '")'
    Local $line3 = 'WinMove("' & $MBTitle & '", "' & $MBText & '"' & ', ' & $x & ', ' & $y & ')'
    FileWrite($file, $line1 & @CRLF & $line2 & @CRLF & $line3)
    FileClose($file)
    
    Run(@AutoItExe & " /AutoIt3ExecuteScript " & EnvGet("temp") & "\MoveMB.au3")
    
    MsgBox($MBFlag, $MBTitle, $MBText)
    
    FileDelete(EnvGet("temp") & "\MoveMB.au3")
EndFunc;==>_MoveMsgBox
A small improvement:

local $result = MsgBox($MBFlag, $MBTitle, $MBText)
and then have the last line of the function return $result.

-John

Edited by jftuga

Share this post


Link to post
Share on other sites
JoshDB

You guys are crazy...

:)


Ha, I haven't been on these forums since... 2006, almost. Behold, my legacy signature:My AutoIt idol is Valuater. You know you love him, too.My Stuff: D&D AGoT Tools Suite

Share this post


Link to post
Share on other sites
ConsultingJoe

Great job guys. these should be all included UDFs and this should be a sticky

Thanks


[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]

Share this post


Link to post
Share on other sites
SmOke_N

A small improvement:

local $result = MsgBox($MBFlag, $MBTitle, $MBText)
and then have the last line of the function return $result.

-John

I knew I had seen this post somewhere, I updated it even more differently lol... take a look: http://www.autoitscript.com/forum/index.ph...ndpost&p=185158

Of course, I don't know if you would call it an "improvement" :)


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.

Share this post


Link to post
Share on other sites
Valuater

; Windows - copy with progress
; Author - JdeB

;~ 4 Do not display a progress dialog box.  
;~ 8 Give the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exists.  
;~ 16 Respond with "Yes to All" for any dialog box that is displayed.  
;~ 64 Preserve undo information, if possible. 
;~ 128 Perform the operation on files only if a wildcard file name (*.*) is specified.  
;~ 256 Display a progress dialog box but do not show the file names.  
;~ 512 Do not confirm the creation of a new directory if the operation requires one to be created.  
;~ 1024 Do not display a user interface if an error occurs.  
;~ 2048 Version 4.71. Do not copy the security attributes of the file. 
;~ 4096 Only operate in the local directory. Don't operate recursively into subdirectories. 
;~ 8192 Version 5.0. Do not copy connected files as a group. Only copy the specified files.  

_FileCopy("C:\Installed Apps\Patches\WindowsXP-KB835935-SP2-ENU.exe","C:\temp")

Func _FileCopy($fromFile,$tofile) 
    Local $FOF_RESPOND_YES = 16
    Local $FOF_SIMPLEPROGRESS = 256
    $winShell = ObjCreate("shell.application")
    $winShell.namespace($tofile).CopyHere($fromFile,$FOF_RESPOND_YES)
EndFunc

MSDN Documentation

http://msdn.microsoft.com/en-us/library/ms723207(VS.85).aspx

; to copy a directory

; the destination directory must exist

_FileCopy("C:\Installed Apps\Patches\*.*","C:\temp\test")

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites
ptrex
nocow

If any finds the source you will have free contents running all over. Also if you make the the encrypt password to some like the username then it will work diffence on each computer and nobody can just "Copy/past" the regedit and get free contents

Hope it help :)

Regards

Share this post


Link to post
Share on other sites
SmOke_N

If any finds the source you will have free contents running all over. Also if you make the the encrypt password to some like the username then it will work diffence on each computer and nobody can just "Copy/past" the regedit and get free contents

Hope it help :D

Regards

That doesn't point to any thread here (with a quote) and IMHO makes absolutely no sense :):(

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.

Share this post


Link to post
Share on other sites
JoshDB

I think he's talking about my post...


Ha, I haven't been on these forums since... 2006, almost. Behold, my legacy signature:My AutoIt idol is Valuater. You know you love him, too.My Stuff: D&D AGoT Tools Suite

Share this post


Link to post
Share on other sites
Neoborn

That doesn't point to any thread here (with a quote) and IMHO makes absolutely no sense :):D

I love roast chicken! :(


~Projects~1. iPod Ejector 1.0 - Tool Used To Eject iPod in Windows - Uses DevEject.exe :P2. SmartFTP Close Popup Tool - Closes reminders from freeware SmartFTP.~Helpful Links For New Users~1. LXP's Learning AutoIT PDF Guide - <<< Go here for a PDF Guide on learning AutoIT from the ground up!<<<2. AutoIt 1-2-3 <<<Want to learn more about AutoIT quickly? Go Here<<<3. How To Install The Beta And Production Versions Of AutoIT / SciteAutoIT

Share this post


Link to post
Share on other sites
JoshDB

I love roast chicken! :)

Roast Llllllllllama is for me :(


Ha, I haven't been on these forums since... 2006, almost. Behold, my legacy signature:My AutoIt idol is Valuater. You know you love him, too.My Stuff: D&D AGoT Tools Suite

Share this post


Link to post
Share on other sites
Valuater

** new

; finding a "hung" process
; author gafrost

$v_ret = DllCall("user32.dll","int","IsHungAppWindow", "hwnd", $hwnd)
If $v_ret[0] Then MsgBox(0,"HungApp", "Application is Hung")
 
;.... need to know the handle ( $hwnd )

; finding if an application is hung
; neogia


If _NotResponding("TITLE HERE", "TEXT HERE[OPTIONAL]", 1) Then; The last parameter indicates whether you want to close the hung app or not.
    MsgBox(0,"", "Hung Application, closing app now.")
Else
    MsgBox(0,"", "Application running as intended.")
EndIf

Func _NotResponding($title, $text, $closeIfHung = 0)
    $hWnd = WinGetHandle($title, $text)
    If $hWnd == "" Then
        MsgBox(0,"Error","Could not find window")
        Exit
    EndIf
    $retArr = DllCall("user32.dll", "int", "IsHungAppWindow", "hwnd", $hWnd)
    If @error == 0 Then
        If $retArr[0] == 1 Then
            If $closeIfHung Then
                ProcessClose(WinGetProcess($title, $text))
            EndIf
            Return 1
        EndIf
    Else
        Return 0
    EndIf
EndFunc

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites
Valuater

; terminate a script right [i]before[/i] a user shuts
; VicTT

Global $WM_QUERYENDSESSION = 0x0011
Func InterceptShutdown($hWnd, $msg, $w, $l)
    MsgBox(0, "", "Shutting down")
EndFunc  ;==>InterceptShutdown
GUIRegisterMsg($WM_QUERYENDSESSION, "InterceptShutdown")
While 1
    Sleep(10)
WEnd

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
BigDod

I think that This one by GaFrost should be added.



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

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

Share this post


Link to post
Share on other sites
JoshDB

I use that one all the time :)


Ha, I haven't been on these forums since... 2006, almost. Behold, my legacy signature:My AutoIt idol is Valuater. You know you love him, too.My Stuff: D&D AGoT Tools Suite

Share this post


Link to post
Share on other sites
Valuater

; Round GUI Corners

; Author - gafrost

Test Script

#include <GuiConstants.au3>

$my_gui = GuiCreate("MyGUI", 392, 323)

_GuiRoundCorners($my_gui, 0, 0, 50, 50)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
   ;;;
    EndSelect
WEnd
Exit

Function to round the corners of a window:

Func _GuiRoundCorners($h_win, $i_x1, $i_y1, $i_x3, $i_y3)
   Dim $pos, $ret, $ret2
   $pos = WinGetPos($h_win)
    $ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long",  $i_x1, "long", $i_y1, "long", $pos[2], "long", $pos[3], "long", $i_x3,  "long", $i_y3)
   If $ret[0] Then
      $ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $ret[0], "int", 1)
      If $ret2[0] Then
         Return 1
      Else
         Return 0
      EndIf
   Else
      Return 0
   EndIf
EndFunc ;==>_GuiRoundCorners

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×