Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/05/2013 in all areas

  1. It works. I did, but felt a bit silly giving a thumbs up to my monitor.
    3 points
  2. I haven't posted anything in the examples section for about 6-7 weeks, so felt it was that time again. This shows how to use the string functions of AutoIt and regular exp<b></b>ressi&#111;ns. The header pretty much explains what the function(s) do. #include <MsgBoxConstants.au3> #include <StringConstants.au3> MsgBox($MB_SYSTEMMODAL, '', _FilePrefix(@ScriptFullPath)) ; Append _ thus creating C:\Example\Test_.exe MsgBox($MB_SYSTEMMODAL, '', _FilePrefixSRE(@ScriptFullPath & '.text')) ; Append _ thus creating C:\Example\Test_.exe ; #FUNCTION# ==================================================================================================================== ; Name ..........: _FilePrefixSRE ; Description ...: Append a prefix before the file extension. ; Syntax ........: _FilePrefixSRE($sFilePath[, $sPrefix = Default]) ; Parameters ....: $sFilePath - Filepath or name to append a prefix before the file extension. ; $sPrefix - [optional] A string value. Default is '_'. ; Return values .: Success - Filepath with the intended prefix. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _FilePrefixSRE($sFilePath, $sPrefix = Default) If $sPrefix = Default Or StringStripWS($sPrefix, $STR_STRIPALL) == '' Then $sPrefix = '_' Return StringRegExpReplace($sFilePath, '^(.+?)(\.\w+)?$', '${1}' & $sPrefix & '${2}') EndFunc ;==>_FilePrefixSRE ; #FUNCTION# ==================================================================================================================== ; Name ..........: _FilePrefix ; Description ...: Append a prefix before the file extension. ; Syntax ........: _FilePrefix($sFilePath[, $sPrefix = Default]) ; Parameters ....: $sFilePath - Filepath or name to append a prefix before the file extension. ; $sPrefix - [optional] A string value. Default is '_'. ; Return values .: Success - Filepath with the intended prefix. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _FilePrefix($sFilePath, $sPrefix = Default) If $sPrefix = Default Or StringStripWS($sPrefix, $STR_STRIPALL) == '' Then $sPrefix = '_' Local $iDot = StringInStr($sFilePath, '.', Default, -1) - 1 If $iDot <= 0 Then $iDot = StringLen($sFilePath) Return StringLeft($sFilePath, $iDot) & $sPrefix & StringTrimLeft($sFilePath, $iDot) EndFunc ;==>_FilePrefix
    1 point
  3. I hope you like it. #Region _GuiCtrlSetFont.au3 ;Copyrights to funkey !! #include <WinAPI.au3> OnAutoItExitRegister("_FontCleanUp") Global $ahFontEx[1] = [0] Func _GuiCtrlSetFont($controlID, $size, $weight = 400, $attribute = 0, $rotation = 0, $fontname= "", $quality = 2) Local $fdwItalic = BitAND($attribute, 1) Local $fdwUnderline = BitAND($attribute, 2) Local $fdwStrikeOut = BitAND($attribute, 4) ReDim $ahFontEx[UBound($ahFontEx) + 1] $ahFontEx[0] += 1 $ahFontEx[$ahFontEx[0]] = _WinAPI_CreateFont($size, 0, $rotation * 10, $rotation, $weight, _ $fdwItalic, $fdwUnderline, $fdwStrikeOut, -1, 0, 0, $quality, 0, $fontname) GUICtrlSendMsg($controlID, 48, $ahFontEx[$ahFontEx[0]], 1) EndFunc Func _FontCleanUp() For $i = 1 To $ahFontEx[0] _WinAPI_DeleteObject($ahFontEx[$i]) Next EndFunc #EndRegion Global $hGui1 = GuiCreate("AutoIt Main-GUI", 300, 340, 100, 100, -1, 0); For $i = 0 To 350 Step 30 GUICtrlCreateLabel("This is rotating", 50, 0, 300, 220, 0x201) _GuiCtrlSetFont(-1, 15, 1000, 1, $i) GUICtrlSetBkColor(-1, -2) Next GUICtrlCreateLabel("This is a vertical label", 10, 30,200, 200, 0x001) _GuiCtrlSetFont(-1, 15, 400, 1, -90) GUICtrlSetBkColor(-1, -2) GUICtrlCreateLabel("This too!!", 130, 50, 200, 200, 0x202) _GuiCtrlSetFont(-1, 15, 400, 1, 90) GUICtrlSetBkColor(-1, -2) GuiCtrlCreateButton("This is a cool button text", 10, 220, 275, 60, 0x0800); _GuiCtrlSetFont(-1, 20, 1000, 1, 8) GuiCtrlCreateCombo("Hello", 10, 290, 275, 80, 0x3, -1); _GuiCtrlSetFont(-1, 15, 1000, 1, -3) GUICtrlSetData(-1, "Item2|Item3") GuiSetState(@SW_SHOW, $hGui1); Do Until GUIGetMsg() = -3
    1 point
  4. jchd

    Another RE problem

    Exactly. I've been there before and severly bitten at the same spot
    1 point
  5. jdelaney

    Another RE problem

    _IEAttach $oImgCol=_IEImgGetCollection OR _IELinkGetCollection For $oImg In $oImgCol consolewrite($oImg.href & " " & $oImg.href @crlf) next no need to do regexp on html
    1 point
  6. Here what I did so far using the GUICtrlSetGraphic() stuff: ;coded by UEZ 2013-04-05 #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> Global Const $iW = 256, $iH = $iW, $iCenterX = $iW / 2, $iCenterY = $iH / 2, $fD2R = ACos(-1) / 180, _ $iRadiusH = Int($iW * 0.2), $iRadiusM = Int($iW * 0.3), $iRadiusS = Int($iW * 0.4), $iPenSize = 2, _ $iBGColor = 0x585858, $iSecColor = 0x0080FF, $iMinColor = 0xFF00FF, $iHrColor = 0x00FF00 Global $hGUI = GUICreate("Puristic Clock by UEZ", $iW, $iH, -1, -1, -1, $WS_EX_COMPOSITED) GUISetBkColor($iBGColor) Global $iGraphic = GUICtrlCreateGraphic(0, 0, $iW, $iH) GUISetState() DrawClock() AdlibRegister("DrawClock", 500) Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE AdlibUnRegister("DrawClock") GUIDelete() Exit EndSwitch Until False Func DrawClock() ;erase background GUICtrlSetGraphic($iGraphic, $GUI_GR_PENSIZE, $iW) GUICtrlSetGraphic($iGraphic, $GUI_GR_COLOR, $iBGColor) GUICtrlSetGraphic($iGraphic, $GUI_GR_MOVE, $iCenterX, $iCenterY) GUICtrlSetGraphic($iGraphic, $GUI_GR_LINE, $iCenterX + Cos((-90 + 6 * (@SEC - 1)) * $fD2R) * $iRadiusS, $iCenterY + Sin((-90 + 6 * (@SEC - 1)) * $fD2R) * $iRadiusS) ;draw hour GUICtrlSetGraphic($iGraphic, $GUI_GR_PENSIZE, $iPenSize) GUICtrlSetGraphic($iGraphic, $GUI_GR_MOVE, $iCenterX, $iCenterY) GUICtrlSetGraphic($iGraphic, $GUI_GR_COLOR, $iHrColor) GUICtrlSetGraphic($iGraphic, $GUI_GR_LINE, $iCenterX + Cos((-90 + 30 * Mod(@HOUR, 12) + @MIN / 2) * $fD2R) * $iRadiusH, $iCenterY + Sin((-90 + 30 * Mod(@HOUR, 12) + @MIN / 2) * $fD2R) * $iRadiusH) ;draw minute GUICtrlSetGraphic($iGraphic, $GUI_GR_MOVE, $iCenterX, $iCenterY) GUICtrlSetGraphic($iGraphic, $GUI_GR_COLOR, $iMinColor) GUICtrlSetGraphic($iGraphic, $GUI_GR_LINE, $iCenterX + Cos((-90 + 6 * @MIN) * $fD2R) * $iRadiusM, $iCenterY + Sin((-90 + 6 * @MIN) * $fD2R) * $iRadiusM) ;draw seconds GUICtrlSetGraphic($iGraphic, $GUI_GR_MOVE, $iCenterX, $iCenterY) GUICtrlSetGraphic($iGraphic, $GUI_GR_COLOR, $iSecColor) GUICtrlSetGraphic($iGraphic, $GUI_GR_LINE, $iCenterX + Cos((-90 + 6 * @SEC) * $fD2R) * $iRadiusS, $iCenterY + Sin((-90 + 6 * @SEC) * $fD2R) * $iRadiusS) GUICtrlSetGraphic($iGraphic, $GUI_GR_REFRESH) EndFunc Not fully tested... Br, UEZ
    1 point
  7. #include <GUIConstantsEx.au3> Global $PI = 3.1415926535897932384626433832795 Global $Sec = @SEC, $Min = @MIN, $Hour = @HOUR Global $Radius = 170, $Radius_Element_Sec[$Radius], $Radius_Element_Min[$Radius], $Radius_Element_Hour[$Radius] Global $Color_Sec = 0xFF0000, $Color_Min = 0x0000FF, $Color_Hour = 0x00000 Global $width = 400, $height = 400 GUICreate("Johnmcloud Test Version", $width, $height, -1, -1) GUISetBkColor(0xFFFFFF) ;~ GUICtrlCreatePic("Test.bmp", 0, 0, $width, $height) ;~ GUICtrlSetState(-1, $GUI_DISABLE) _onstart() GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch _Clock() WEnd Func _Clock() If $Sec <> @SEC Then $Sec = @SEC For $i = 0 To $Radius - 1 $curX = $width / 2 + Cos($PI / 2 - ($Radius * $Sec / 60 * $PI / ($Radius / 2))) * $i $curY = $width / 2 - Sin($PI / 2 - ($Radius * $Sec / 60 * $PI / ($Radius / 2))) * $i GUICtrlSetPos($Radius_Element_Sec[$i], $curX, $curY) Next EndIf If $Min <> @MIN Then $Min = @MIN For $i = 0 To $Radius - 1 $curX = $width / 2 + Cos($PI / 2 - ($Radius * ($Min + $Sec / 60) / 60 * $PI / ($Radius / 2))) * $i $curY = $width / 2 - Sin($PI / 2 - ($Radius * ($Min + $Sec / 60) / 60 * $PI / ($Radius / 2))) * $i GUICtrlSetPos($Radius_Element_Min[$i], $curX, $curY) Next EndIf If $Hour <> @HOUR Then $Hour = @HOUR For $i = 0 To $Radius - 1 $curX = $width / 2 + Cos($PI / 2 - ($Radius * ($Hour + $Min / 60) / 12 * $PI / ($Radius / 2))) * $i $curY = $width / 2 - Sin($PI / 2 - ($Radius * ($Hour + $Min / 60) / 12 * $PI / ($Radius / 2))) * $i GUICtrlSetPos($Radius_Element_Hour[$i], $curX, $curY) Next EndIf Sleep(10) EndFunc ;==>_Clock Func _onstart() For $i = 0 To $Radius - 1 $Sec = @SEC $curX = $width / 2 + Cos($PI / 2 - ($Radius * $Sec / 60 * $PI / ($Radius / 2))) * $i $curY = $width / 2 - Sin($PI / 2 - ($Radius * $Sec / 60 * $PI / ($Radius / 2))) * $i $Radius_Element_Sec[$i] = GUICtrlCreateLabel("", $curX, $curY, 1, 1) GUICtrlSetBkColor(-1, $Color_Sec) $Min = @MIN $curX = $width / 2 + Cos($PI / 2 - ($Radius * ($Min + $Sec / 60) / 60 * $PI / ($Radius / 2))) * $i $curY = $width / 2 - Sin($PI / 2 - ($Radius * ($Min + $Sec / 60) / 60 * $PI / ($Radius / 2))) * $i $Radius_Element_Min[$i] = GUICtrlCreateLabel("", $curX, $curY, 4, 4) GUICtrlSetBkColor(-1, $Color_Min) $Hour = @HOUR $curX = $width / 2 + Cos($PI / 2 - ($Radius * ($Hour + $Min / 60) / 12 * $PI / ($Radius / 2))) * $i $curY = $width / 2 - Sin($PI / 2 - ($Radius * ($Hour + $Min / 60) / 12 * $PI / ($Radius / 2))) * $i $Radius_Element_Hour[$i] = GUICtrlCreateLabel("", $curX, $curY, 5, 5) GUICtrlSetBkColor(-1, $Color_Hour) Next Sleep(10) EndFunc ;==>_Start First, i don't know GDI+ but this is the best i can do, i'm not a good coder Second, don't ask me about the resize method based on the GUI size, i don't have idea how to do it but Phoneix i think can help you Third, There is a little bug, the second needle is under the hour/minute and not over it, i don't know why
    1 point
  8. Check if it fits your needs #include <Array.au3> $String = FileRead(@ScriptFullPath) $hFile = FileOpen(@ScriptFullPath, 2 ) FileWrite( $hFile, SortFunctions($String)) FileClose( $hFile ) Func SortFunctions($Source, $iDescending = 0, $fDebug = False) ;Get the Array of Array of Functions $aFunc = StringRegExp($Source, '(?ism)(^\h*Func\h+\w+.+?^\h*EndFunc.*?$)', 3) $aTemp = $aFunc ;For the Original Position of the Functions ;Sort The Functions _ArraySort($aFunc, $iDescending) ;Lets Replace the Functions If $fDebug Then _ArrayDisplay( $aTemp, "Original Func" ) If $fDebug Then _ArrayDisplay( $aFunc, "Sorted Func") For $i = 0 To UBound($aFunc) - 1 $Source = StringReplace($Source, $aTemp[$i], $aFunc[$i], -1) Next Return $Source EndFunc ;==>SortFunctions Func Y() ; EndFunc ;==>X Func X() ; EndFunc ;==>Y Func A() ; EndFunc ;==>AThumbs if it helped Regards
    1 point
  9. DucViet FileGetEncoding
    1 point
  10. BrewManNH

    SciTE Toolbar

    I saw that ToolBarForAny, it's really nice, but this one had source code available, and allowed me to play with it. It was more of a learning experience to try out some new programming techniques I've learned, better coding practices etc. Plus it allowed me to modify things to more of my likes. This script is great for using as a base for something more extensive, such as making it easier to configure than hacking around in INI files to change the tools it connects to, different icon files, different commands that can be added that run external processes (like TBFA does).
    1 point
  11. Mechaflash

    Help in coding?

    On a side note, requests for assistance with your code should be directed to the General Help and Support forum, as the developer forum is a space for AutoIt developers to speak of witchcraft, wizardry, hello kitty, and all that jazz.
    1 point
  12. Where to start? ByCode122 was given a short posting holiday - but decided to reappear as KACAON which lead to a permament ban. Now we find ProShow, Nikoli12 and grawmaly - whose style of English and choice of question seems strangely similar (togehter with other indications).....and so they get added to the list as well. Remember that by evading bans you just make our system stronger - you might last a few days, but we will get you in the end. M23
    1 point
  13. can you try this before calling objects ? $COINIT_APARTMENTTHREADED = 0x02 DllCall('ole32.dll', 'long', 'CoInitializeEx', 'ptr', 0, 'dword', $COINIT_APARTMENTTHREADED)
    1 point
×
×
  • Create New...