Jump to content

Recommended Posts

Posted

; Move Entire Screen Across

; Author - Siao

#include <WindowsConstants.au3>
#include <WinAPI.au3>

$hScreenDC = _WinAPI_GetWindowDC(0)
$hMemDC = _WinAPI_CreateCompatibleDC($hScreenDC)
$hMemBMP = _WinAPI_CreateCompatibleBitmap($hScreenDC, @DesktopWidth*2, @DesktopHeight)
_WinAPI_DeleteObject(_WinAPI_SelectObject($hMemDC, $hMemBMP))
_WinAPI_BitBlt($hMemDC, 0, 0, @DesktopWidth, @DesktopHeight, $hScreenDC, 0, 0, $SRCCOPY)
_WinAPI_BitBlt($hMemDC, @DesktopWidth, 0, @DesktopWidth, @DesktopHeight, $hScreenDC, 0, 0, $SRCCOPY)

For $i = @DesktopWidth To 0 Step -8
    _WinAPI_BitBlt($hScreenDC, 0, 0, @DesktopWidth, @DesktopHeight, $hMemDC, $i, 0, $SRCCOPY)
    Sleep(20)
Next

_WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE+$RDW_ALLCHILDREN)
_WinAPI_ReleaseDC(0, $hScreenDC)
_WinAPI_DeleteObject($hMemBMP)
_WinAPI_DeleteDC($hMemDC)

Exit

; Edited - for up/down move - Malkey

#include <WindowsConstants.au3>
#include <WinAPI.au3>

$hScreenDC = _WinAPI_GetWindowDC(0)
$hMemDC = _WinAPI_CreateCompatibleDC($hScreenDC)
$hMemBMP = _WinAPI_CreateCompatibleBitmap($hScreenDC, @DesktopWidth, @DesktopHeight*2)
_WinAPI_DeleteObject(_WinAPI_SelectObject($hMemDC, $hMemBMP))
_WinAPI_BitBlt($hMemDC, 0, 0, @DesktopWidth, @DesktopHeight, $hScreenDC, 0, 0, $SRCCOPY)
_WinAPI_BitBlt($hMemDC, 0, @DesktopHeight,  @DesktopWidth, @DesktopHeight, $hScreenDC, 0, 0, $SRCCOPY)

For $i = 0 To @DesktopHeight  Step 8 ;scroll Up
;For $i =  @DesktopHeight To 0 Step -8 ;scroll Down
    _WinAPI_BitBlt($hScreenDC, 0, 0, @DesktopWidth, @DesktopHeight, $hMemDC, 0, $i, $SRCCOPY)
    Sleep(20)
Next

_WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE+$RDW_ALLCHILDREN)
_WinAPI_ReleaseDC(0, $hScreenDC)
_WinAPI_DeleteObject($hMemBMP)
_WinAPI_DeleteDC($hMemDC)

Exit

8)

NEWHeader1.png

Posted (edited)

; Create a system restore point, option to turn it off

; Author - arjan staring


#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$disable = True ;set True to disable system restore after creating a restore point and False to keep system restore enabled

Opt("TrayMenuMode",1)

$create = TrayCreateItem("Create")
TrayCreateItem("")
$exit = TrayCreateItem("Exit")
TraySetState()

$gui = GUICreate("Create System Restore Point",176,21,@DesktopWidth - 176,@DesktopHeight - 80,$WS_POPUP,$WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)
$input = GUICtrlCreateInput("",0,0,150,21)
$send = GUICtrlCreateButton("OK",150,0,26,21)
GUISetState(@SW_HIDE,$gui)

While 1
    $tray_msg = TrayGetMsg()
    $gui_msg = GUIGetMsg()
    Select
        Case $tray_msg = $create
            GUICtrlSetData($input,"RestorePoint " & @HOUR & ":" & @MIN & ":" & @SEC)
            GUISetState(@SW_SHOW,$gui)
        Case $tray_msg = $exit
            Exit
        Case $gui_msg = $send
            If StringLen(GUICtrlRead($input)) > 0 Then
                GUISetState(@SW_HIDE,$gui)
                _CreateSystemRestorePoint(GUICtrlRead($input),$disable)
            Else
                GUISetState(@SW_HIDE,$gui)
            EndIf      
    EndSelect
WEnd

Func _CreateSystemRestorePoint($discription,$disable = True)
    #RequireAdmin
    $obj = ObjGet("winmgmts:{impersonationLevel=impersonate}!root/default:SystemRestore")
    $obj.Enable("")
    $obj.CreateRestorePoint($discription, 12, 100)
    If $disable Then
        $obj.Disable("")
    EndIf
EndFunc

******* NOTE - as this is set to "True" it will turn-off your system restore point *******

Thread Link

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

8)

Edited by Valuater

NEWHeader1.png

Posted

MsgBox(0,0, _getOSVersion())

Func _getOSVersion()
    Local $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
    Local $colSettings = $objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
    For $objOperatingSystem In $colSettings
        Return StringMid($objOperatingSystem.Caption, 19)
    Next
EndFunc   ;==>_getOSVersion

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

  • 1 month later...
Posted

Here's something I just came up with... It's really simple and is actually based off another wrapper by GaryFrost/Valuater:

This checkbox can easily can have it's background/text color set. It doesn't have the change of color when you hover over it but whatever...

Func _GUICtrlCreateCheckBoxEx($text, $x, $y, $w, $h)
    $XS_n = DllCall("uxtheme.dll", "int", "GetThemeAppProperties")
    DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)   

    $id = GUICtrlCreateCheckBox($text, $x, $y, $w, $h)
        
    DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", $XS_n[0])
    
    Return $id
EndFunc
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
  • 4 weeks later...
Posted

; text over icon/pic button

; author - rover

;#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GUIConstantsEx.au3>
#include <GuiButton.au3>
#include <GuiImageList.au3>

Opt("MustDeclareVars", 1)

_Main()

Func _Main()
    Local $sBMPNormal = @WindowsDir & "\pchealth\helpctr\System\images\24x24\arrow_green_normal.bmp"
    Local $sBMPHot = @WindowsDir & "\pchealth\helpctr\System\images\24x24\arrow_green_mouseover.bmp"
    Local $sBMPPress = @WindowsDir & "\pchealth\helpctr\System\images\24x24\arrow_green_mousedown.bmp"
    Local $sBMPImage = @WindowsDir & "\pchealth\helpctr\System\blurbs\watermark_300x.bmp"
    Local $btn1, $btn2, $btn3, $btn4, $msg
    Local $hImagebtn1, $hImagebtn2, $hImagebtn3 ,$hImagebtn4

    ;Caveat: Minimum Operating Systems: Windows XP.

    ;Image list with multiple images will only show the images
    ;other than the 1st image when Themes are used.

    Local $hGUI = GUICreate("Button Imagelists - Minimum OS: Windows XP",400,300)
   
    GUICtrlCreatePic(@WindowsDir & "\Web\Wallpaper\Windows XP.jpg", 0, 0, 400, 300)
    GUICtrlSetState(-1, $GUI_DISABLE)
   
    ;multi state image Bitmap
    $btn1 = GUICtrlCreateButton("This Way", 30, 30, 90, 32)
    GUICtrlSetTip(-1, "Multi state bitmap imagelist")
    $hImagebtn1 = _GUIImageList_Create(24, 24, 5, 5)
    _GUIImageList_AddBitmap($hImagebtn1, $sBMPNormal);1 - Normal
    _GUIImageList_AddBitmap($hImagebtn1, $sBMPHot)   ;2 - Hot
    _GUIImageList_AddBitmap($hImagebtn1, $sBMPPress) ;3 - Pressed
    _GUIImageList_AddBitmap($hImagebtn1, $sBMPPress);4 - Disabled
    _GUIImageList_AddBitmap($hImagebtn1, $sBMPNormal);5 - Defaulted
    _GUIImageList_AddBitmap($hImagebtn1, $sBMPNormal);6 - Stylus Hot (tablet computers only)
    _GUICtrlButton_SetImageList($btn1, $hImagebtn1)

    ;single state image Bitmap
    $btn2 = GUICtrlCreateButton("This Way", 30, 70, 90, 32)
    GUICtrlSetTip(-1, "Single bitmap imagelist")
    $hImagebtn2 = _GUIImageList_Create(24, 24, 5, 3)
    _GUIImageList_AddBitmap($hImagebtn2, $sBMPNormal);1 - Normal
    _GUICtrlButton_SetImageList($btn2, $hImagebtn2)

    ;single state image Icon
    $btn3 = GUICtrlCreateButton("Unlock", 30, 110, 90, 40)
    GUICtrlSetTip(-1, "Single icon imagelist")
    $hImagebtn3 = _GUIImageList_Create(32, 32, 5, 3)
    _GUIImageList_AddIcon($hImagebtn3, "shell32.dll", 47, True)
    _GUICtrlButton_SetImageList($btn3, $hImagebtn3)

    ;single state image Bitmap with overlayed text
    $btn4 = GUICtrlCreateButton("Help", 30, 160, 90, 90)
    GUICtrlSetTip(-1, "Single bitmap imagelist with overlayed text")
    GUICtrlSetFont(-1, 14, 800, -1, "Comic Sans MS")
    $hImagebtn4 = _GUIImageList_Create(80, 80, 5, 3)
    _GUIImageList_AddBitmap($hImagebtn4, $sBMPImage)
    _GUICtrlButton_SetImageList($btn4, $hImagebtn4, 4)

    GUISetState()

    While 1
        $msg = GUIGetMsg()
        Switch $msg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $btn1
            Case $btn2
                GUICtrlSetState($btn1, $GUI_DISABLE)
            Case $btn3
                GUICtrlSetState($btn1, $GUI_ENABLE)
            Case $btn4
        EndSwitch
    WEnd
EndFunc   ;==>_Main

a great mix example!!

8)

NEWHeader1.png

Posted

; 30 Day Trial
; Author MSLx Fanboy

#include<date.au3>
#include<string.au3>

If RegRead("HKCU\Software\Microsoft\Windows\Current Version", "XPClean Menu") = "" Then
    RegWrite("HKCU\Software\Microsoft\Windows\Current Version", "XPClean Menu", "REG_SZ", _StringEncrypt(1, _NowCalc(), @ComputerName))
    SetError(0)
EndIf
$startdate = _StringEncrypt(0, RegRead("HKCU\Software\Microsoft\Windows\Current Version", "XPClean Menu"), @ComputerName)

If _DateDiff("D", $startdate, _NowCalc()) > 30 Then
    MsgBox(0, "*XPClean Menu*", "You're registration period has expired.")
    Exit
EndIf

8)

how can i extend the trial version Period to 3Months ?
Website: www.cerescode.comForum: www.forum.cerescode.comIRC: irc.freenode.net , Channel: #Ceres--------------------Autoit Wrappers, Great additions to your script (Must See) (By: Valuater)Read It Befor Asking Question Click Here...--------------------Join Monoceres's Forums http://www.monoceres.se--------------------There are three kinds of people: Those who make things happen, those who watch things happen, and those who ask, ‘What happened?’” –Casey Stengel
  • 1 month later...
Posted

Thought I already had this one...

; _WinGetCtrlInfo()

; Author - SmOke_N


; Return:
;[N][0] = ClassNameNN
;[N][1] = Control ID of the same control

Func _WinGetCtrlInfo($hWin)
    If IsString($hWin) Then $hWin = WinGetHandle($hWin)
    Local $sClassList = WinGetClassList($hWin), $iAdd = 1, $aDLL, $sHold
    Local $aSplitClass = StringSplit(StringTrimRight($sClassList, 1), @LF), $aReturn[1][2]
    For $iCount = $aSplitClass[0] To 1 Step - 1
        Local $nCount = 0
        While 1
            $nCount += 1
            If ControlGetHandle($hWin, '', $aSplitClass[$iCount] & $nCount) = '' Then ExitLoop
            If Not StringInStr(Chr(1) & $sHold, Chr(1) & $aSplitClass[$iCount] & $nCount & Chr(1)) Then
                $sHold &= $aSplitClass[$iCount] & $nCount & Chr(1)
                $iAdd += 1
                ReDim $aReturn[$iAdd][2]
                $aReturn[$iAdd - 1][0] = $aSplitClass[$iCount] & $nCount
                $aDLL = DllCall('User32.dll', 'int', 'GetDlgCtrlID', 'hwnd', _
                    ControlGetHandle($hWin, '', $aSplitClass[$iCount] & $nCount))
                If @error = 0 Then
                    $aReturn[$iAdd - 1][1] = $aDLL[0]
                Else
                    $aReturn[$iAdd - 1][1] = ''
                EndIf
            EndIf
        WEnd
    Next
    $aReturn[0][0] = $iAdd - 1
    Return $aReturn
EndFunc

Example of use...

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

NEWHeader1.png

Posted

; Run a timed program daily

; Author - Valuater

; #NoTrayIcon ; for testing 

Dim $Minutes = 30 
Dim $Title = "My Window Title" 

; settings
Dim $Show_Clock = 1 ; 0 = no show
Dim $Clock_Title = $Minutes & "  Minute Time Machine"

If WinExists($Clock_Title) Then Exit
AutoItWinSetTitle($Clock_Title)

; ***** for testing only ******
HotKeySet("{F9}", "Runner")
Func Runner()
    Run("notepad.exe")
EndFunc   ;==>Runner
$Minutes = 3 ; for testing
$Title = "Untitled" ; for testing
; *****************************

While 1
    If WinExists($Title) Then Clockit()
    Sleep(100)
WEnd

Func Clockit()
    Local $log = @WindowsDir & "\temp\"
    Local $log_file = $log & @YDAY & ".pak"
    If Not FileExists($log_file) Then 
        FileDelete($log & "*.pak")
        FileWriteLine($log_file, $Minutes)
    EndIf
    Local $M_Minutes = FileReadLine($log_file, 1)
    Local $begin = TimerInit(), $60Count = 0
    If $M_Minutes <= 0 Then
        WinClose($Title)
        MsgBox(64, $Clock_Title,  "Time-Up!! ...Your daily time usage has passed.    ", 5)
        Return
    EndIf
    While $M_Minutes > 0 And WinExists($Title)
        $dif = TimerDiff($begin)
        $Count = Int($dif / 1000)
        If $Count >= 60 Then
            $60Count += 1
            $M_Minutes -= 1
            $begin = TimerInit()
        EndIf
        If $Show_Clock Then ToolTip("Minutes Remaining = " & $M_Minutes & @CRLF & "Minutes Past = " & $60Count & @CRLF & "Seconds Count = " & $Count, 20, 20, $Clock_Title, 1)
        Sleep(100)
    WEnd
    ToolTip("")
    FileDelete($log_file)
    Sleep(300)
    If $Count >= 20 And $M_Minutes > 0 Then $M_Minutes -= 1
    FileWriteLine($log_file, $M_Minutes)    
EndFunc   ;==>Clockit

8)

any more description and information about it?
Enjoy the complexity.Feel the power of simplicity.
Posted (edited)

Heres a Characters generator (could be used as a password generator)

MSgBox(0, "", _Random(50))

Func _Random($iLength)
    Local $sReturn
    Local $aChars[62] = [ _
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', _
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', _
    0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    
    For $i = 0 To $iLength
        $sReturn &= $aChars[Random(0, 61)]
    Next
    Return $sReturn
EndFunc
Edited by Marlo
Click here for the best AutoIt help possible.Currently Working on: Autoit RAT
Posted

MsgBox(0,0, _getOSVersion())

Func _getOSVersion()
    Local $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
    Local $colSettings = $objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
    For $objOperatingSystem In $colSettings
        Return StringMid($objOperatingSystem.Caption, 19)
    Next
EndFunc   ;==>_getOSVersion

Nice! Way more informative than @OSVersion

Posted

; mixed colored List View

; Author - Siao

#Include <GuiConstantsEx.au3>
#Include <GuiListView.au3>
#include <WindowsConstants.au3>


;fonts for custom draw example
;bold
Global $aFont1 = DLLCall("gdi32.dll","int","CreateFont", "int", 14, "int", 0, "int", 0, "int", 0, "int", 700, _
                        "dword", 0, "dword", 0, "dword", 0, "dword", 0, "dword", 0, "dword", 0, "dword", 0, _
                        "dword", 0, "str", "")
;italic
Global $aFont2 = DLLCall("gdi32.dll","int","CreateFont", "int", 14, "int", 0, "int", 0, "int", 0, "int", 400, _
                        "dword", 1, "dword", 0, "dword", 0, "dword", 0, "dword", 0, "dword", 0, "dword", 0, _
                        "dword", 0, "str", "")
                        


$GUI = GUICreate("Listview Custom Draw", 400, 300)

$cListView = GUICtrlCreateListView("", 2, 2, 394, 268)
$hListView = GUICtrlGetHandle($cListView)
;or
;~ $hListView = _GUICtrlListView_Create($GUI, "", 2, 2, 394, 268)

_GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))

_GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 100)
_GUICtrlListView_InsertColumn($hListView, 1, "Column 2", 100)
_GUICtrlListView_InsertColumn($hListView, 2, "Column 3", 100)

; Add items
For $i = 1 To 30
    _GUICtrlListView_AddItem($hListView, "Row" & $i & ": Col 1", $i-1)
    For $j = 1 To 2
        _GUICtrlListView_AddSubItem ($hListView, $i-1, "Row" & $i & ": Col " & $j+1, $j)
    Next
Next

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUISetState()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
DLLCall("gdi32.dll","int","DeleteObject", "hwnd", $aFont1[0])
DLLCall("gdi32.dll","int","DeleteObject", "hwnd", $aFont2[0])
Exit

Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hListView
            Switch $iCode
                Case $NM_CUSTOMDRAW
                    If Not _GUICtrlListView_GetViewDetails($hWndFrom) Then Return $GUI_RUNDEFMSG
                     Local $tCustDraw = DllStructCreate('hwnd hwndFrom;int idFrom;int code;' & _
                                        'dword DrawStage;hwnd hdc;long rect[4];dword ItemSpec;int ItemState;dword Itemlparam;' & _
                                        'dword clrText;dword clrTextBk;int SubItem;' & _
                                        'dword ItemType;dword clrFace;int IconEffect;int IconPhase;int PartID;int StateID;long rectText[4];int Align', _ ;winxp or later
                                        $lParam), $iDrawStage, $iItem, $iSubitem, $hDC, $iColor1, $iColor2, $iColor3
                    $iDrawStage = DllStructGetData($tCustDraw, 'DrawStage')
                    If $iDrawStage = $CDDS_PREPAINT Then Return $CDRF_NOTIFYITEMDRAW ;request custom drawing of items
                    If $iDrawStage = $CDDS_ITEMPREPAINT Then Return $CDRF_NOTIFYSUBITEMDRAW ;request drawing each cell separately
                    If Not BitAND($iDrawStage, $CDDS_SUBITEM) Then Return $CDRF_DODEFAULT
                    $iItem = DllStructGetData($tCustDraw, 'ItemSpec')
                    $iSubitem = DllStructGetData($tCustDraw, 'SubItem')
                    Switch $iItem
                        Case 0 To 9 ;for rows 1-10 lets do this
                            $iColor1 = RGB2BGR(0xFBFFD8)
                            $iColor2 = RGB2BGR(-1)
                            $iColor3 = RGB2BGR(0xFF0000)
                            If Mod($iSubitem, 2) Then ;odd columns
                                DllStructSetData($tCustDraw, 'clrTextBk', $iColor1)
                                DllStructSetData($tCustDraw, 'clrText', 0)
                            Else ;even columns
                                DllStructSetData($tCustDraw, 'clrTextBk', $iColor2)
                                DllStructSetData($tCustDraw, 'clrText', $iColor3)
                            EndIf
                        Case 10 To 19 ;for rows 11-20 lets do this
                            $iColor1 = RGB2BGR(0xFBFFD8)
                            $iColor2 = RGB2BGR(0x3DF8FF)
                            $hDC = DllStructGetData($tCustDraw, 'hdc')
                            If Mod($iItem, 2) Then
                                If Mod($iSubitem, 2) Then
                                    DllStructSetData($tCustDraw, 'clrTextBk', $iColor1)
                                Else
                                    DllStructSetData($tCustDraw, 'clrTextBk', $iColor2)
                                EndIf
                                DLLCall("gdi32.dll","hwnd","SelectObject", "hwnd", $hDC, "hwnd", $aFont1[0]) ;select our chosen font into DC
                            Else
                                If Mod($iSubitem, 2) Then
                                    DllStructSetData($tCustDraw, 'clrTextBk', $iColor2)
                                Else
                                    DllStructSetData($tCustDraw, 'clrTextBk', $iColor1)
                                EndIf
                                DLLCall("gdi32.dll","hwnd","SelectObject", "hwnd", $hDC, "hwnd", $aFont2[0])
                            EndIf
                        Case 20 To 29 ;for rows 21-30 lets do this
                            $iColor1 = RGB2BGR(0xFBFFD8)
                            $iColor2 = RGB2BGR(-1)
                            If Mod($iItem, 2) Then ;odd rows
                                DllStructSetData($tCustDraw, 'clrTextBk', $iColor2)
                            Else
                                DllStructSetData($tCustDraw, 'clrTextBk', $iColor1)
                            EndIf                     
                    EndSwitch
                    Return $CDRF_NEWFONT
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func RGB2BGR($iColor)
    Return BitAND(BitShift(String(Binary($iColor)), 8), 0xFFFFFF)
EndFunc

8)

NEWHeader1.png

Posted (edited)

Return a time string using the local settings format. 2 examples are run in this script but any format can be used as long as there are at least 6 digits. Milliseconds are ignored.

;
MsgBox(262208, "TIME", _TimeFormatLocal(@Hour & @Min & @Sec))
MsgBox(262208, "TIME", _TimeFormatLocal(@Hour & "h" & @Min & ":" & @Sec))

Func _TimeFormatLocal($sTime);; Use Local time format settings
   $sFormat = RegRead("HKCU\Control Panel\International", "sTimeFormat")
   If @Error Then $sFormat = "h:mm:ss tt"
   $aFormat = StringRegExp($sFormat,"\w*(.)\w*(.).*", 3)
   Return StringRegExpReplace($sTime, "(\d{2}).?(\d{2}).?(\d{2})", "\1" & $aFormat[0] & "\2" & $aFormat[1] & "\3")
EndFunc
;
Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Posted

Val, quote from MSDN: "When you no longer need the HRGN object call the DeleteObject function to delete it." Found here: http://msdn.microsoft.com/en-us/library/ms536690(VS.85).aspx

I did it like so, but feel free to do otherwise:

#include <GuiConstants.au3>
#include <WinAPI.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

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)
      
      _WinAPI_DeleteObject($ret[0])
      
      If $ret2[0] Then
         Return 1
      Else
         Return 0
      EndIf
   Else
      Return 0
   EndIf
EndFunc ;==>_GuiRoundCorners
Posted (edited)

This function automatically writes default values to an INI file if they don't exist.

With this feature, your script will automatically create an INI file with default values so you don't have to add special code to create a default INI. Also, if support for new INI keys is later added to your script, the new keys will automatically be added to the existing INI so they can be edited by the user.

;===============================================================================
; Description:     Reads values from INI or creates INI with initial values.
;                  Intended to ensure all available INI settings are exposed
;                  and editable.
;                  Parameters are identical to IniRead()
; Parameter(s):    $filename  = filename of INI
;                  $section  = section name of INI
;                  $key      = key name in section
;                  $default  = default value (written to INI if not exists)
; Requirement(s):  None
; Return Value(s): Returns value from INI (or default if not defined)
; Note(s):         Chr(127) used to detect non-existing value since won't normally exist in a text file
;===============================================================================
Func _IniReadInit($filename, $section, $key, $default)
  Local $value = IniRead($filename, $section, $key, Chr(127))
    If $value = Chr(127) Then
      IniWrite($filename, $section, $key, $default)
      $value = $default
    EndIf
    Return $value
EndFunc
Edited by mlowery
Posted

Check to see if a function exists.

MsgBox(0, "TEST", "Function Exists = " & _FuncExists("_FuncExists", @ScriptFullPath))

Func _FuncExists($sFunc, $sPath)
   If NOT FileExists($sPath) Then Return SetError(1)
   Local $sStr = FileRead($sPath)
   Local $sRegEx = "(?i)(?m:^|\n)\s*Func\s+(" & $sFunc & ")\s*\("
   $aRegEx = StringRegExp($sStr, $sRegEx, 1)
   If IsArray($aRegEx) Then Return 1
   Return 0
EndFunc

Create an array of all the functions in a script

$aFlist = _FuncListToArray(@ScriptFullPath)
If NOT @Error Then
   For $i = 0 To Ubound($aFlist) -1
      MsgBox(0, "TEST", $aFlist[$i], 2)
   Next
EndIf

Func _FuncListToArray($sStr)
   If FileExists($sStr) Then $sStr = FileRead($sStr)
   Local $sRegEx = "(?i)(?m:^|\n)\s*Func\s+(\w+)\s*\("
   $aRegEx = StringRegExp($sStr, $sRegEx, 3)
   If IsArray($aRegEx) Then Return $aRegEx
   Return SetError(1)
EndFunc

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Posted (edited)

@GEOSoft and @All

About the array with functions. Here is an UDFs that will return not only one-level functions, but also all functions found in the #includes :)

Author: amel27

#include <Array.au3>

Global $aGetAllLibs[1]
_AU3_GetAllLibUDF(FileRead(@ScriptFullPath), $aGetAllLibs)

For $i = 1 To $aGetAllLibs[0][0]
    ConsoleWrite($aGetAllLibs[$i][0] & ":" & $aGetAllLibs[$i][2] & @CRLF)
    
    $aGetUDFs = $aGetAllLibs[$i][3]
    
    If IsArray($aGetUDFs) Then
        For $j = 0 To UBound($aGetUDFs)-1
            ConsoleWrite(@TAB & $aGetUDFs[$j] & @CRLF)
        Next
    EndIf
Next

Func _AU3_GetAllLibUDF($sScript_Content, ByRef $aIncludes_Arr)
    Local Const $rFile = '(?i)(?:^|[\n\r])[ \t]*#include[ \t]+((?:\<|")[^\n\r\"\>]+(?:\>|"))'
    Local Const $rUDFs = '(?i)(?:^|[\n\r])[ \t]*Func[ \t]+([\w\d]+)'
    
; Инициализация массива при первом входе / сохранение списка UDF
    If UBound($aIncludes_Arr, 2) <> 4 Then Dim $aIncludes_Arr[2][4] = [[1, 0, 0], [0, "", 0]]
    $aIncludes_Arr[$aIncludes_Arr[0][0]][3] = StringRegExp($sScript_Content, $rUDFs, 3)
   
; Инициализация переменных / Получение списка библиотечных файлов
    Local $sPath, $iType, $sName, $sText
    Local $aFile = StringRegExp($sScript_Content, $rFile, 3)
   
; Пофайловая обработка списка библиотек
    If IsArray($aFile) Then
        For $i = 0 To UBound($aFile)-1
            $sPath = _AU3_LibIncToPath($aFile[$i])                   ; полное имя файла
            If @error Then ContinueLoop                             ; файл не найден
           
            $iType = @extended                                       ; тип библиотеки
            $sName = StringRegExpReplace($sPath, "(?:[^\\]+\\)+", "")  ; краткое имя файла
            
        ; Исключение повторной обработки / Чтение файла
            For $j = 1 To $aIncludes_Arr[0][0]
                If $aIncludes_Arr[$j][0] == $iType And $aIncludes_Arr[$j][2] == $sName Then ContinueLoop 2
            Next
            
            $sText = FileRead($sPath)
            If @error Then ContinueLoop
            
        ; При успешном чтении добавляем файл в выходной массив
            $aIncludes_Arr[0][0] += 1
            ReDim $aIncludes_Arr[$aIncludes_Arr[0][0]+1][4]
           
            $aIncludes_Arr[$aIncludes_Arr[0][0]][0] = $iType
            $aIncludes_Arr[$aIncludes_Arr[0][0]][1] = $sPath
            $aIncludes_Arr[$aIncludes_Arr[0][0]][2] = $sName
            
           ; Рекурсивный вызов на обработку текста библиотеки
            _AU3_GetAllLibUDF($sText, $aIncludes_Arr)
        Next
    EndIf
EndFunc; ==> _AU3_GetAllLibUDF

Func _AU3_LibIncToPath($sInclude)
    Local $aRegExp = StringRegExp($sInclude, '^(<|")([^>"]+)(?:>|")$', 3)
    
; Проверка на корректность формата строки
    If Not IsArray($aRegExp) Then Return SetError(1, 0, "")
    $sInclude = $aRegExp[1]

    If StringInStr($sInclude, "\") = 0 Then
        Local $sSYS, $sUDL, $aUDL, $sAU3 = @ScriptDir & "\" & $sInclude
        
    ; Определение каталога системных библиотек
        $sSYS = StringRegExpReplace(@AutoItExe, "\\[^\\]+$", "")
        $sSYS &= "\Include\"& $sInclude
        
    ; Чтение списка каталогов пользовательских библиотек
        $sUDL = RegRead("HKCU\Software\AutoIt v3\AutoIt", "Include")
        $aUDL = StringRegExp($sUDL, "([^;]+)(?:;|$)", 3)
        
    ; Проверка типов 1 и 2 (до пользовательских библиотек)
        If $aRegExp[0] == '<' Then
            If FileExists($sSYS) Then Return SetError(0, 1, $sSYS)
        ElseIf $aRegExp[0] == '"' Then
            If FileExists($sAU3) Then Return SetError(0, 2, $sAU3)
        EndIf
        
    ; Проверка типа 3 (поиск среди пользовательских библиотек)
        If IsArray($aUDL) Then
            For $i = 0 To UBound($aUDL)-1
                $aUDL[$i] &= "\" & $sInclude
                If FileExists($aUDL[$i]) Then Return SetError(0, 3, $aUDL[$i])
            Next
        EndIf
        
    ; Проверка типов 1 и 2 (после пользовательских библиотек)
        If $aRegExp[0] == '<' Then
            If FileExists($sAU3) Then Return SetError(0, 2, $sAU3)
        ElseIf $aRegExp[0] == '"' Then
            If FileExists($sSYS) Then Return SetError(0, 1, $sSYS)
        EndIf
    Else
       ; Проверка типа 4 (файл с указанием полного пути)
        If FileExists($sInclude) Then Return SetError(0, 4, $sInclude)
    EndIf
    
   ; ОШИБКА: файл не найден
    Return SetError(2, 0, "")
EndFunc; ==>  _AU3_LibIncToPath

P.S

The comments are on russian, but i think the function's code is understandable without them (if neccessary, i will translate the comments).

Edited by MrCreatoR

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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