Jump to content

Autoit Wrappers


Valuater
 Share

Recommended Posts

@GEOSoft, MrCreatoR 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 ....with no overhead and their parameters too.... :)

Author - Valuater

; User's Script only

_FuncParamList()

Func _FuncParamList($fList = @ScriptFullPath)
    $aArray = StringSplit(FileRead($fList, FileGetSize($fList)), @LF)
    For $x = 1 To UBound($aArray) - 1
        If StringLeft($aArray[$x], 4) = "Func" Then ConsoleWrite(StringTrimLeft($aArray[$x], 4) & @LF)
    Next
EndFunc   ;==>_FuncParamListoÝ÷ Ù«­¢+ØìUÍȹ½½È±°%¹±ÕÌ´=ÁÑ¥½¸()}±±Õ¹Aɵ1¥ÍРĤ()Õ¹}±±Õ¹Aɵ1¥ÍÐ ÀÌØí%¹±ÕÌôÀ°ÀÌØí1¥ÍÐôMÉ¥ÁÑÕ±±AÑ ¤(ÀÌØíÉÉäôMÑÉ¥¹MÁ±¥Ð¡¥±I ÀÌØí1¥Íа¥±ÑM¥é ÀÌØí1¥ÍФ¤°1¤(½ÈÀÌØíàôÄQ¼U  ½Õ¹ ÀÌØíÉÉ䤴Ä(%MÑÉ¥¹1Ð ÀÌØíÉÉålÀÌØíát°Ð¤ôÅÕ½ÐíÕ¹ÅÕ½ÐìQ¡¸
½¹Í½±]ɥѡMÑÉ¥¹QÉ¥µ1Ð ÀÌØíÉÉålÀÌØíát°Ð¤µÀì1¤(%ÀÌØí%¹±Õ̱ÐìÐìÅÕ½ÐìÅÕ½Ðì¹MÑÉ¥¹1Ð ÀÌØíÉÉålÀÌØíát°à¤ôÅÕ½Ðì%¹±ÕÅÕ½ÐìQ¡¸(ÀÌØíÍ}MÑÉÐôMÑÉ¥¹%¹MÑÈ ÀÌØíÉÉålÀÌØíát°ÅÕ½Ðì±ÐìÅÕ½Ð줬Ä(ÀÌØí%¹±Õ̵ÀìôMÑÉ¥¹5¥ ÀÌØíÉÉålÀÌØíát°ÀÌØíÍ}MÑÉаMÑÉ¥¹%¹MÑÈ ÀÌØíÉÉålÀÌØíát°ÅÕ½ÐìÐìÅÕ½Ð줴ÀÌØíÍ}MÑÉФµÀìÅÕ½ÐíðÅÕ½Ðì(¹%(9áÐ(%ÀÌØí%¹±Õ̱ÐìÐìÅÕ½ÐìÅÕ½ÐìQ¡¸(ÀÌØí¥AÑ ôMÑÉ¥¹1СÕѽ%Ñá°MÑÉ¥¹%¹MÑÈ¡Õѽ%Ñá°ÅÕ½ÐìÀäÈìÅÕ½Ðì°À°´Ä¤¤µÀìÅÕ½Ðí%¹±ÕÀäÈìÅÕ½Ðì(ÀÌØí¥MÁ±¥ÐôMÑÉ¥¹MÁ±¥Ð¡MÑÉ¥¹QÉ¥µ1Ð ÀÌØí%¹±Õ̰Ĥ°ÅÕ½ÐíðÅÕ½Ðì¤(½ÈÀÌØí¤ôÄQ¼ÀÌØí¥MÁ±¥ÑlÁt´Ä(
½¹Í½±]ɥѡ
I1µÀìÅÕ½Ðì´Ðì%¹±ÕèÅÕ½ÐìµÀìÀÌØí¥AÑ µÀìÀÌØí¥MÁ±¥ÑlÀÌØí¥tµÀì1¤(}±±Õ¹Aɵ1¥ÍÐ À°ÀÌØí¥AÑ µÀìÀÌØí¥MÁ±¥ÑlÀÌØí¥t¤(9áÐ(¹%)¹Õ¹ìôôÐí}±±Õ¹Aɵ1¥Í

8)

NEWHeader1.png

Link to comment
Share on other sites

  • Moderators

^^ could have been done with 1 line of regex :) ... surprised GeoSoft didn't provide that, I know I showed him it. ...

Edit:

Oops, but not the includes too :)

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

^^ could have been done with 1 line of regex :) ... surprised GeoSoft didn't provide that, I know I showed him it. ...

Edit:

Oops, but not the includes too :)

It's one of those "I have it SOMEPLACE" days.

I also have a function that gets all the included UDFs (Standard, Local, Or both) if you remember.

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!"

Link to comment
Share on other sites

Very nice codings :) , but I need this functionality in compiled scripts, where the source is not available. :)

See my unresolved items in my signature.

I need it for a multi tasking solution. When finished, it will show up in examples scripts and in my signature. o:)

Good luck with that.

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!"

Link to comment
Share on other sites

Very nice codings :) , but I need this functionality in compiled scripts, where the source is not available. :)

See my unresolved items in my signature.

I need it for a multi tasking solution. When finished, it will show up in examples scripts and in my signature. o:)

Example.....

$input = InputBox("_Script_FuncExists", "Please type in a Function Name  ")
If @error Then Exit

If $input <> "" And _IsFunc($input) Then
    MsgBox(262144, 'With call to function', $input & " is a function.")
Else
    MsgBox(262144, 'With call to function', $input & " is NOT a function.")
EndIf

Func _IsFunc($sFunc = "")
    Local $fTemp = @TempDir & "\_IsFunc2.au3" ;MUST BE the Script/Program Name
    FileDelete($fTemp)
    FileInstall("_IsFunc2.au3", @TempDir & "\") ; 1st parameter MUST BE the Script/Program Name
    $aArray = StringSplit(FileRead($fTemp, FileGetSize($fTemp)), @LF)
    FileDelete($fTemp)
    For $x = 1 To UBound($aArray) - 1
        If StringLeft($aArray[$x], 4) = "Func" Then
            $s_Start = StringInStr($aArray[$x], " ") + 1
            $fFinal = StringMid($aArray[$x], $s_Start, StringInStr($aArray[$x], "(") - $s_Start)
            If $fFinal = $sFunc Then Return ConsoleWrite(StringTrimLeft($aArray[$x], 4) & @LF)
        EndIf
    Next
    Return 0
EndFunc   ;==>_IsFunc

Func _f1()
EndFunc   ;==>_f1
Func _f4()
EndFunc   ;==>_f4
Func _f7()
EndFunc   ;==>_f7

#cs
    Func _f2()
    EndFunc   ;==>_f2
#ce

Compiled..... works

8)

EDIT: change file to string functions from regexp()

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

Example.....

$input = InputBox("_Script_FuncExists", "Please type in a Function Name  ")
If @error Then Exit

If $input <> "" And _IsFunc($input) Then
    MsgBox(262144, 'With call to function', $input & " is a function.")
Else
    MsgBox(262144, 'With call to function', $input & " is NOT a function.")
EndIf


Func _IsFunc($sFunc = "")
    Local $fTemp = @TempDir & "\_IsFunc.au3"
    FileDelete($fTemp)
    FileInstall("_IsFunc.au3", @TempDir & "\") ; 1st parameter MUST BE the Script/Program Name
    Local $sStr = FileRead($fTemp)
    FileDelete($fTemp)
    Local $sRegEx = "(?s)(?i)(?m:^|\n)\s*Func\s+(" & $sFunc & ")\s*\("
    $aRegEx = StringRegExp($sStr, $sRegEx, 1)
    If IsArray($aRegEx) Then Return 1
    Return 0
EndFunc   ;==>_IsFunc

Func _f1()
EndFunc   ;==>_f1
Func _f4()
EndFunc   ;==>_f4
Func _f7()
EndFunc   ;==>_f7

Compiled.....

8)

I think that what he wants to do is get the functions from a compiled script, hence my previous reply. I've been wrong before though (the fact that I'm a married man is enough testimony), at least twice.

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!"

Link to comment
Share on other sites

; A Real Captcha ( hidden text for security ) ...Really Sharp!

; Author - Malkey


#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>
#include<Color.au3>

Opt("GUIOnEventMode", 1) ;0=disabled, 1=OnEvent mode enabled

Global $aFonts[4] = ["MS Sans Serif", "Arial", "Times New Roman", "Lucida Console"]
Global $charList = StringSplit("abcdefghijkmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ23456789", "")
Global $aColours[4] = [0xFFFF0000, 0xFF00FF00, 0xFF0000FF, 0xFFFFFF00]
Global $ApW = 250, $ApH = 250
Global $Button[1], $Pic, $sCode, $hImage
Global Const $iPI = 3.1415926535897932384626433832795

$hGui = GUICreate("GDIPlus Graphics on Picture Control - OnEvent Mode", $ApW, $ApH)
GUISetOnEvent(-3, "_Quit")
GUISetBkColor(0xffA0A0, $hGui)

$Pic = GUICtrlCreatePic("", 20, 20, 45, 40, $SS_SUNKEN, BitOR($WS_EX_CLIENTEDGE, $WS_EX_STATICEDGE, $WS_EX_DLGMODALFRAME))
GUICtrlSetState(-1, $GUI_DISABLE)

$Captcha_Input = GUICtrlCreateInput("", 20, 170, 70, 20)
$Generate_Button = GUICtrlCreateButton("Generate", 20, 200, 70, 20)
GUICtrlSetOnEvent($Generate_Button, "PicSetGraphics")
$SaveCaptcha_Button = GUICtrlCreateButton("Save to file...", 120, 200, 120, 20)
GUICtrlSetOnEvent($SaveCaptcha_Button, "Save")

_GDIPlus_Startup()
PicSetGraphics(); <-- Draw GDIPlus graphics on Picture control.

GUISetState(@SW_SHOW, $hGui)

While 1
    Sleep(10)
WEnd
_GDIPlus_Shutdown()

Func PicSetGraphics()
    Local Const $STM_SETIMAGE = 0x0172
    Local Const $IMAGE_BITMAP = 0
    Local $hWnd, $hBitmap, $hGraphic, $hBrush, $hBrush1, $hbmp, $aBmp
    Local $iW = 150, $iH = 100, $sCode = ""
   
    $hWnd = GUICtrlGetHandle($Pic)
    If $hImage > 0 Then _GDIPlus_ImageDispose($hImage)
   
    ;Buffer
    $hBitmap = _WinAPI_CreateSolidBitmap($hGui, 0x8FAAAAAA, $iW, $iH) ;
    $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)
    $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage)
   
    ;----->  All Graphics Here
   
    ;Rainbow background
    For $x = 0 To $iW
        $hue = Color_SetHSL(Int($x / 2))
        $hPen1 = _GDIPlus_PenCreate("0x80" & Hex($hue, 6), 1) ; Slightly transparent
        _GDIPlus_GraphicsDrawLine($hGraphic, $x, 0, $x, $ApH, $hPen1)
        _GDIPlus_PenDispose($hPen1)
    Next
   
    For $x = 0 To 3
       
        ;Draw random Lines 
        $hPen1 = _GDIPlus_PenCreate("0x" & Hex($aColours[Random(0, 3, 1)], 8), Random(1, 3, 1))
        _GDIPlus_GraphicsDrawLine($hGraphic, Random(0, $iW, 1), Random(0, 5, 1), Random(0, $iW, 1), _
                                                                    Random($iH - 5, $iH, 1), $hPen1)
        $hPen1 = _GDIPlus_PenCreate("0x" & Hex($aColours[Random(0, 3, 1)], 8), Random(1, 3, 1))
        _GDIPlus_GraphicsDrawLine($hGraphic, Random(0, 5, 1), Random(0, $iH, 1), Random($iW - 5, $iW, 1), _
                                                                                Random(0, $iH, 1), $hPen1)
        _GDIPlus_PenDispose($hPen1)
       
        ; Draw a character
        $sLetter = $charList[Random(1, $charList[0], 1)]
        GUISetFont(Random(14, 26, 1), 400, 0, $aFonts[Random(0, UBound($aFonts) - 1, 1)])
        $iBy = $x * ($iW / 4)
        GDIPlus_SetAngledText($hGraphic, $sLetter, Random($iBy + 15, $iBy + ($iW / 4) - 15, 1), _
        Random(($iH / 2) - 15, ($iH / 2) + 5, 1), Random(-30, 30, 1), "", 16, "0x" & Hex($aColours[Random(0, 3, 1)], 8))
        $sCode &= $sLetter
       
    Next
   
    ; -----> End of all Graphics
   
    GUICtrlSetData($Captcha_Input, $sCode) 
   
    ; Keeps all GDIPlus graphics visible
    $hbmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    $aBmp = DllCall("user32.dll", "hwnd", "SendMessage", "hwnd", $hWnd, "int", $STM_SETIMAGE, "int", $IMAGE_BITMAP, "int", $hbmp)
    _WinAPI_RedrawWindow($hGui, "", "", BitOR($RDW_INVALIDATE, $RDW_UPDATENOW, $RDW_FRAME))
   
    If $aBmp[0] <> 0 Then _WinAPI_DeleteObject($aBmp[0])
   
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PenDispose($hPen1)
    _GDIPlus_GraphicsDispose($hGraphic)
    _WinAPI_DeleteObject($hbmp)
    _WinAPI_DeleteObject($hBitmap) 
EndFunc   ;==>PicSetGraphics


Func Save()
    $sCaptcha_File = FileSaveDialog("Save Captcha as...", "", "Image Files (*.png;*.jpg;*.bmp)", 18, "Captcha.jpg", $hGui)
    If @error Then Return
   
    If Not StringRegExp($sCaptcha_File, ".*\.png|\.jpg|\.bmp$") Then $sCaptcha_File &= ".jpg"
    ConsoleWrite(" Saved  " & $sCaptcha_File & @CRLF)
    _GDIPlus_ImageSaveToFile($hImage, $sCaptcha_File)
    _GDIPlus_ImageDispose($hImage)
EndFunc   ;==>Save

; #FUNCTION# ================================================================
; Name...........: GDIPlus_SetAngledText
; Description ...: Adds text to a graphic object at any angle.
; Syntax.........: GDIPlus_SetAngledText($hGraphic, $nText, [$iCentreX, [$iCentreY, [$iAngle , [$nFontName , _
;                              [$nFontSize, [$iARGB, [$iAnchor]]]]]]] )
; Parameters ....: $hGraphic   - The Graphics object to receive the added text.
;               $nText      - Text string to be displayed
;                  $iCentreX       - Horizontal coordinate of horixontal centre of the text rectangle        (default =  0 )
;                  $iCentreY        - Vertical coordinate of vertical centre of the text rectangle             (default = 0 )
;                  $iAngle     - The angle which the text will be place in degrees.         (default = "" or blank = 0 )
;                  $nFontName  - The name of the font to be used                      (default = "" or Blank = "Arial" )
;                  $nFontSize  - The font size to be used                                  (default = "" or Blank = 12 )
;                  $iARGB      - Alpha(Transparency), Red, Green and Blue color (0xAARRGGBB) (Default= "" = random color
;                                                                                      or Default = Blank = 0xFFFF00FF )
;               $iAnchor    - If zero (default) positioning $iCentreX, $iCentreY values refer to centre of text string.
;                                If not zero positioning $iCentreX, $iCentreY values refer to top left corner of text string.
; Return values .: 1
; Author ........: Malkey
; Modified.......:
; Remarks .......: Call _GDIPlus_Startup() before starting this function, and call _GDIPlus_Shutdown()after function ends.
;                  Can enter calculation for Angle Eg. For incline, -ATan($iVDist / $iHDist) * 180 / $iPI , where
;               $iVDist is Vertical Distance,  $iHDist is Horizontal Distance, and, $iPI is Pi, (an added Global Const).
;               When used with other graphics, call this function last. The MatrixRotate() may affect following graphics.
; Related .......: _GDIPlus_Startup(), _GDIPlus_Shutdown(), _GDIPlus_GraphicsDispose($hGraphic)
; Link ..........;
; Example .......; Yes
; ========================================================================================
Func GDIPlus_SetAngledText($hGraphic, $nText, $iCentreX = 0, $iCentreY = 0, $iAngle = 0, $nFontName = "Arial", _
        $nFontSize = 12, $iARGB = 0xFFFF00FF, $iAnchor = 0)
    Local $x, $y, $iX, $iY, $iWidth, $iHeight
    Local $hMatrix, $iXt, $iYt, $hBrush, $hFormat, $hFamily, $hFont, $tLayout
   
    ; Default values
    If $iAngle = "" Then $iAngle = 0
    If $nFontName = "" Or $nFontName = -1 Then $nFontName = "Arial" ; "Microsoft Sans Serif"
    If $nFontSize = "" Then $nFontSize = 12
    If $iARGB = "" Then ; Randomize ARGB color
        $iARGB = "0xFF" & Hex(Random(0, 255, 1), 2) & Hex(Random(0, 255, 1), 2) & Hex(Random(0, 255, 1), 2)
    EndIf
   
    $hFormat = _GDIPlus_StringFormatCreate(0)
    $hFamily = _GDIPlus_FontFamilyCreate($nFontName)
    $hFont = _GDIPlus_FontCreate($hFamily, $nFontSize, 1, 3)
    $tLayout = _GDIPlus_RectFCreate($iCentreX, $iCentreY, 0, 0)
    $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $nText, $hFont, $tLayout, $hFormat)
    $iWidth = Ceiling(DllStructGetData($aInfo[0], "Width"))
    $iHeight = Ceiling(DllStructGetData($aInfo[0], "Height"))
   
    ;Later calculations based on centre of Text rectangle.
    If $iAnchor = 0 Then ; Reference to middle of Text rectangle
        $iX = $iCentreX
        $iY = $iCentreY
    Else ; Referenced centre point moved to top left corner of text string.
        $iX = $iCentreX + (($iWidth - Abs($iHeight * Sin($iAngle * $iPI / 180))) / 2)
        $iY = $iCentreY + (($iHeight + Abs($iWidth * Sin($iAngle * $iPI / 180))) / 2)
    EndIf
   
    ;Rotation Matrix
    $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixRotate($hMatrix, $iAngle, 1)
    _GDIPlus_GraphicsSetTransform($hGraphic, $hMatrix)
   
    ;x, y are display coordinates of center of width and height of the rectanglular text box.
    ;Top left corner coordinates rotate in a circular path with radius = (width of text box)/2.
    ;Parametric equations for a circle, and adjustments for centre of text box
    $x = ($iWidth / 2) * Cos($iAngle * $iPI / 180) - ($iHeight / 2) * Sin($iAngle * $iPI / 180)
    $y = ($iWidth / 2) * Sin($iAngle * $iPI / 180) + ($iHeight / 2) * Cos($iAngle * $iPI / 180)
   
    ;Rotation of Coordinate Axes formulae - To display at x and y after rotation, we need to enter the
    ;x an y position values of where they rotated from. This is done by rotating the coordinate axes.
    ;Use $iXt, $iYt in  _GDIPlus_RectFCreate. These x, y values is the position of the rectangular
    ;text box point before rotation. (before translation of the matrix)
    $iXt = ($iX - $x) * Cos($iAngle * $iPI / 180) + ($iY - $y) * Sin($iAngle * $iPI / 180)
    $iYt = -($iX - $x) * Sin($iAngle * $iPI / 180) + ($iY - $y) * Cos($iAngle * $iPI / 180)
   
    $hBrush = _GDIPlus_BrushCreateSolid($iARGB)
    $tLayout = _GDIPlus_RectFCreate($iXt, $iYt, $iWidth, $iHeight)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $nText, $hFont, $tLayout, $hFormat, $hBrush)
   
    ; Clean up resources
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    $tLayout = ""
    Return 1
EndFunc   ;==>GDIPlus_SetAngledText


Func Color_SetHSL($iHue, $Saturation = 180, $Brightness = 160)
    If IsArray($iHue) Then
        $aInput = $iHue
    Else
        Local $aInput[3] = [$iHue, $Saturation, $Brightness]
    EndIf
    Local $aiRGB = _ColorConvertHSLtoRGB($aInput)
    Return "0x" & Hex(Round($aiRGB[0]), 2) & Hex(Round($aiRGB[1]), 2) & Hex(Round($aiRGB[2]), 2)
EndFunc   ;==>Color_SetHSL


Func _Quit()
    If $hImage > 0 Then _GDIPlus_ImageDispose($hImage)
    _GDIPlus_Shutdown()
    Exit
EndFunc   ;==>_Quit

Other Great Graphics from Malkey...

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

8)

NEWHeader1.png

Link to comment
Share on other sites

Here are a couple of simple functions I developed to map network shares.

;===============================================================================
; Author(s):        Roger Osborne 
; Version:             1.0.0
; AutoItVer:          3.0.102.+
; Created              2008-12-2
;
; Description:    Maps a network drive using the CURRENTLY LOGGED ON user's credentials
;
; Syntax:          _MapDrive ($driveletter, $servername, $servershare, $reporterror)
;
; Parameter(s):      $driveletter = Drive letter to assign for network share
;                       $servername = Name of server 
;                      $servershare = Share name on server ($servername)
;                       $reporterror = Should the function return a MsgBox if the drive mapping is not successful ("yes" or "no")
;
; Requirement(s):   None
;
; Example:              _MapDrive("X","Server1","Public", "no")
;
;===============================================================================

;Func _MapDrive($driveletter, $servername, $servershare, $reporterror)

Func _MapDrive($driveletter, $servername, $servershare, $reporterror) 

            If DriveMapGet($driveletter & ":") <> "\\" & $servername & "\" & $servershare Then
               DriveMapDel($driveletter & ":")
               sleep(250)
            EndIf
           
            DriveMapAdd($driveletter & ":", "\\" & $servername & "\" & $servershare)

            If $reporterror = "yes" Then
                If DriveMapGet($driveletter & ":") <> "\\" & $servername & "\" & $servershare Then
                    MsgBox(16, "Error Mapping Drive", "There was an error mapping drive " & StringUpper($driveletter) & ": to the following UNC path: " & "\\" & $servername & "\" & $servershare)
                EndIf
            EndIf

            If $reporterror = "no" Then
            ; Do nothing
            EndIf
            
EndFunc  ;==>_MapDrive

;===============================================================================
; Author(s):        Roger Osborne
; Version:             1.0.0
; AutoItVer:          3.0.102.+
; Created              2008-12-2
;
; Description:    Maps a network drive using a specified username and password
; 
; IMPORTANT NOTE:   This function will NOT allow you to map to a server -- using different credentials -- if you already have mapped drives
;                  to the SAME server (with a different credential). 
;                  In other words, ONLY ONE user credential can be used for EACH server you are connecting to.
;
; Syntax:          _MapDriveDiffUser ($driveletter, $servername, $servershare, $serverusrname, $serverusrpasswd, $reporterror)
;
; Parameter(s):      $driveletter = Drive letter to assign for network share
;                       $servername = Name of server 
;                      $servershare = Share name on server ($servername)
;                       $serverusrname = User name to use for mapping drive
;                       $serverusrpasswd = Password to use for mapping drive
;                       $reporterror = Should the function return a MsgBox if the drive mapping is not successful ("yes" or "no")
;
; Requirement(s):   None
;
; Example:              _MapDriveDiffUser("X","ServerNameHere","ShareNameHere", "DomainName\administrator", "AdministratorPasswordHere", "yes")
;
;===============================================================================

Func _MapDriveDiffUser($driveletter, $servername, $servershare, $serverusrname, $serverusrpasswd, $reporterror) 

            If DriveMapGet($driveletter & ":") <> "\\" & $servername & "\" & $servershare Then
               DriveMapDel($driveletter & ":")
               sleep(250)
            EndIf

            DriveMapAdd($driveletter & ":", "\\" & $servername & "\" & $servershare, 0, $serverusrname, $serverusrpasswd)

            If $reporterror = "yes" Then
                If DriveMapGet($driveletter & ":") <> "\\" & $servername & "\" & $servershare Then
                    MsgBox(16, "Error Mapping Drive", "There was an error mapping drive " & StringUpper($driveletter) & ": to the following UNC path: " & "\\" & $servername & "\" & $servershare)
                EndIf
            EndIf

            If $reporterror = "no" Then
        ; Do nothing
            EndIf
            
EndFunc ;==>_MapDriveDiffUser

Enjoy! :)

Edited by rogerd2u

Roger O."When people show you who they are, believe them.” --Mark Twain

Link to comment
Share on other sites

Make a window unmovable, based on this code:

#include <GUIConstants.au3>

Global Const $WM_WINDOWPOSCHANGING = 0x0046

Global $nConstXpos = @DesktopWidth/2        ;define the constant x position
Global $nConstYpos = @DesktopHeight/2   ;define the constant y position

$hGUI = GUICreate("Unmovable window", 300, 200, $nConstXpos, $nConstYpos)

GUIRegisterMsg($WM_WINDOWPOSCHANGING, "MY_WM_WINDOWPOSCHANGING")

GUISetState()

While 1
    $GUIMsg = GUIGetMsg()
   
    Switch $GUIMsg
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd


Func MY_WM_WINDOWPOSCHANGING($hWnd, $Msg, $wParam, $lParam)
    Local $stWinPos = DllStructCreate("uint hwnd;uint hwndInsertAfter;int x;int y;int cx;int cy;uint flags", $lParam)

    DllStructSetData($stWinPos, "x", $nConstXpos)
    DllStructSetData($stWinPos, "y", $nConstYpos)
    Return 0
EndFunc
Edited by Kastout
Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
Link to comment
Share on other sites

This thread STILL isn't a sticky. Gets so hard to find it that I have to use a link from the 404 page on my own site.

Quick and dirty. Just the way Valuater likes it.

I got tired of having to write code like this.

If ($aCursor[0] >= $vPos[0] AND $aCursor[0] <= $vPos[2]) AND _
      ($aCursor[1] >= $vPos[1] AND $aCursor[1] <= $vPos[3]) Then _
       $Set = 1

So I wrote a quickie to find out if a value was within a given range and now all I type for the same as above is

If _IsBetween($aCursor[0], $vPos[0], $vPos[2]) AND _
    _IsBetween($aCursor[1], $vPos[1], $vPos[3]) Then $Set = 1

Here is the simple function.

Func _IsBetween($iNum, $iCeil, $iFloor)
   If (NOT IsNumber($iNum )) OR (NOT IsNumber($iNum )) OR (NOT IsNumber($iNum )) Then Return SetError(1, 1, "Only Integers and float values are allowed");
   If $iFloor > $iCeil Then
      Local $iHold = $iFloor
      $iFloor = $iCeil
      $iCeil = $iHold
   EndIf
   If $iNum <= $iCeil AND $iNum >= $iFloor Then Return 1
EndFunc

Where $iNum is the number to check $iCeil is the max and $iFloor is the min. Don't worry if you mix up $iCeil and $iFloor, the function will correct it anyway.

There are probably better methods but like I said, quick and dirty. I needed it for an image swapper function I just finished.

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!"

Link to comment
Share on other sites

Thanks for the kudos!

I do like the idea, however, I really think switching the floor and ceiling for the user is going a little far....

Also, you might want to look this over again

If (NOT IsNumber($iNum )) OR (NOT IsNumber($iNum )) OR (NOT IsNumber($iNum )) Then Return SetError(1, 1, "Only Integers are allowed");

:)

thx

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

Thanks for the kudos!

I do like the idea, however, I really think switching the floor and ceiling for the user is going a little far....

Also, you might want to look this over again

If (NOT IsNumber($iNum )) OR (NOT IsNumber($iNum )) OR (NOT IsNumber($iNum )) Then Return SetError(1, 1, "Only Integers are allowed");

:)

thx

8)

Thanks. I originally wrote it with IsInt() and then changed it to handle floats as well although in my use it would only be integers only. What do you mean switching Floor and Ceiling for the user? I switched them for me !! That way even in a confuzzled state I would get what I wanted.

I'll edit the return Msg and then it should be fine. I'm using it to switch images on hover and I jsut had to make sure that the mouse was within the proper bounds. If it was then change to image B otherwise switch back to image A.

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!"

Link to comment
Share on other sites

Similar anyway, but this one was for Images which are being used as buttons on one of my new GUIs I used a Popup style so even the Min and Xit buttons has to be done and I have several otheres where I won't be using standard buttons.. I can use the same code that I have above to know when to do image resizing to make an image appear to respond as a button on hover.

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!"

Link to comment
Share on other sites

The first function for a possible Grammar.au3 UDF.

Warning. Where the (non)word ain't is involved, it may make an improper correction because so far I have now way of checking sentence context. Example "who ain't" will change to "who is" however depending on context it may be that it would be better changed to "who are not".

;===============================================================================
Func _Grammar_RemoveContractions($sStr, $iShall = 0)
   If StringRight(@OSLang, 2) <> 9 Then
      If MsgBox(262180, "Warning", "Your system language is not English" & @CRLF & @CRLF & _
      "Are you sure you wish to continue") = 7 Then Return SetError(1,0)
   EndIf
   If FileExists($sStr) Then $sStr = FileRead($sStr)
   If NOT $sStr Then Return SetError(2,0)
   Local $iCount = 0
   Local $sShall = "will"
   If $iShall <> 0 Then $sShall = "shall"
   If StringRegExp($sStr, "(?i)\bain'?t\b") Then _Grammar_AintRight($sStr)
   $sStr = StringReplace($sStr, "'tis", "it is")
   $iCount += @Extended
   $sStr = StringRegExpReplace($sStr, "(?i)\b(can)'t\b", "$1 not")
   $iCount += @Extended
   $sStr = StringReplace($sStr, "'twas", "it was")
   $iCount += @Extended
   $sStr = StringRegExpReplace($sStr, "(?i)\b(i)'m\b", "$1 am")
   $iCount += @Extended
   $sStr = StringRegExpReplace($sStr, "(?i)\b([a-z]+)'re\b", "$1 are")
   $iCount += @Extended
   $sStr = StringRegExpReplace($sStr, "(?i)\b(s)han't\b", "$1hall not")
   $iCount += @Extended
   $sStr = StringRegExpReplace($sStr, "(?i)\b([a-z]+)'?ll\b", "$1 "& $sShall)
   $iCount += @Extended
   $sStr = StringRegExpReplace($sStr, "(?i)\b([a-z]+)'d\b", "$1 would")
   $iCount += @Extended
   $sStr = StringRegExpReplace($sStr, "(?i)\b([a-z]+)n'?t\b", "$1 not")
   $iCount += @Extended
   $sStr = StringRegExpReplace($sStr, "(?i)\b([a-z]+)'?ve\b", "$1 have")
   $iCount += @Extended
   $sStr = StringRegExpReplace($sStr, "(?i)\b([a-z]+)'?s\b", "$1 is")
   $iCount += @Extended
   SetExtended($iCount)
   Return $sStr
EndFunc  ;<==> _Grammar_RemoveContractions()

Enjoy

Next comes proper sentence structure.

Edit: Took the "ain't code out and made it a separate function which will also be called when removing contractions

New function is below

;
;===============================================================================
; Function Name:   _Grammar_AintRight()
; Description:   Rids the world of the (non)word Ain't
; Syntax:         _Grammar_AintRight($sStr)
; Parameter(s): $sStr - String or file to test
; Requirement(s):  
; Return Value(s): - Success = Corrected string, @Extended contains the number of changes made
;                 - Failure = Sets @Error to 2 if $sStr is not valid
;                             returns the string ($sStr) if aint or ain't are not found in the string
; Author(s):       GEOSoft
; Modification(s): 
; Note(s):  
; Example(s):   
#cs

#ce
;===============================================================================

Func _Grammar_AintRight($sStr)
   If FileExists($sStr) Then $sStr = FileRead($sStr)
   If NOT $sStr Then Return SetError(2,0)
   If Not StringRegExp($sStr, "(?i)\bain'?t\b") Then Return $sStr
   Local $iCount - 0
   $sStr = StringRegExpReplace($sStr, "(?i)\b(he|she|it|that|mine|what|one|" & _
   "here|whom?|someone|something|other)\sain'?t\b", "$1 is not")
   $iCount += @Extended
   $sStr = StringRegExpReplace($sStr, "\bus\sain'?t\b", "we are not")
   $iCount += @Extended
   $sStr = StringRegExpReplace($sStr, "(?i)\b(th)em\sain'?t\b", "$1ose are not")
   $iCount += @Extended
      $sStr = StringRegExpReplace($sStr, "(?i)\b(they|we|you|those|ours|many|others)\b\s\bain'?t\b", "$1 are not")
   $iCount += @Extended
   $sStr = StringRegExpReplace($sStr, "(?i)\b(i)\sain'?t\b", "$1 am not")
   $iCount += @Extended
   SetExtended($iCount)
   Return $sStr
EndFunc  ;<==> _Grammar_AintRight()
;
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!"

Link to comment
Share on other sites

Great Idea!, A couple of errors noted

ReturnSetError(1,0)

If FileExists($sStr) Then $sStr = FileRead($sFile)

... and can you use "shorter length strings" & _

"use this for a long string that goes off the edge in the above post "

8)

Hmmmm Missed one when I changed the variable names. Did that after testing and before posting. Darn!! Guess it never hit the conditional to trip the error while I was testing either.

Thanks @Val. I fix those and shorten the example right away.

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!"

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