Leaderboard
Popular Content
Showing content with the highest reputation on 02/16/2013 in all areas
-
Few years ago Microsoft introduced new UI feature that they named Ribbon. With the release of Windows 7 they added it as standard system feature. Windows Ribbon framework. You could say it's a new technology waiting to be fully embraced. Considering AutoIt is currently in some shitty stage Ribbons are not expected to be supported natively. Which is actually good thing because otherwise some developer could have GUICtrlCreateRibbon idiotic idea. Ribbons are beautiful things. In order to work with them you have to master objects. It's COM based technology. Some people will stop reading now, but really their shame. Anyway, this example is based on work by Mr. Michael Chourdakis. Guy really took deeper dive to ribbon thematic and made few very interesting articles. All is available on internet naturally, just google Michael Chourdakis Ribbon or something like that. So, the main thing to do is create so called Ribbon Framework Object. After that you have to initialize event handlers (two callback objects made with ObjectFromTag function) and load your Ribbon. Ribbon is loaded from resource, either one of your app or some other. I have compiled resource dll for this example so that scripts could be run non-compiled and still use ribbon command bar. Example shown here is not completely dummy, it uses all of the ribbon controls. Only it doesn't do anything smart besides that. ZIP: Ribbon.zip Inside the zip there is folder called Ribbon with two files RibbonExample_NEW.au3 and RibRes.dll. Extract that folder somewhere, run RibbonExample_NEW.au3 and enjoy the Ribbon beauty. There are few comments inline for easier comprehension of the overall script code. Thanks Andreik for asking for more.1 point
-
I would agree with that, don't use them when not needed, but don't not use them just because some said "globals are bad". Also, using the Local declaration in a Global scope is gilding the lily and serves no purpose from the way AutoIt actually sees them.1 point
-
Good coding practices in AutoIt
jaberwacky reacted to czardas for a topic
I don't believe Valik would just simply regurgitate information without scrutiny. The less resources you have floating around, the less chance of something breaking. In the case in question, global variables are more likely to cause conflicts and this may take more time to fix if the variables are accessed frequently throughout the script. So we have several objections to using globals when not needed. I think the first statement says it all though: 'variables should always be declared in the smallest scope possible'.1 point -
Valik said that because, it is the optimal memory usage for a program? Simpler to read, better design. Not the easiest to correctly conceive? I'm not entirely sure, but I think that is the idea.1 point
-
If you are like me it's an afternoon thing. Mornings roughly halve my IQ.1 point
-
Detecting any running autoit processes
harryspier reacted to JohnOne for a topic
Not compiled, yes. ProcessList() @AutoItPID Loop Compiled, I doubt it.1 point -
No guys, StringLen counts the number of Unicode codepoints, not bytes. Once again, all AutoIt strings use UTF-16 (in fact and more precisely UCS-2) encoding.1 point
-
1 point
-
Crazy crypt
ActualAkshay reacted to guinness for a topic
If you did want 500 and "500" to return the same encryption string, then look at StringIsDigit, IsNumber and Number. #include <Constants.au3> #include <Crypt.au3> _Crypt_Startup() Local $sString = '500' If StringIsDigit($sString) Or IsNumber($sString) Then $sString = Number($sString) EndIf Local $bHash = _Crypt_HashData($sString, $CALG_MD5) MsgBox($MB_SYSTEMMODAL, '', $bHash) Local $iNumber = 500 If StringIsDigit($iNumber) Or IsNumber($iNumber) Then $iNumber = Number($iNumber) EndIf $bHash = _Crypt_HashData($iNumber, $CALG_MD5) MsgBox($MB_SYSTEMMODAL, '', $bHash) _Crypt_Shutdown()1 point -
thanks JohnOne here's the modified code after this. Note - requires image attachement to be downloaded in images folder of Auto it install directory ("InstallDir"\Examples\GUI\Advanced\Images") #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ;#include <Array.au3> ; No longer needed ;#include <ButtonConstants.au3> ; No longer needed Example() HotKeySet("{ESC}","_Exit") Func _Exit() Exit EndFunc Func Example() Local $msg Local $btn, $chk, $rdo, $msg Local $Wow64 = "" If @AutoItX64 Then $Wow64 = "\Wow6432Node" Local $sPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $Wow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\Advanced\Images" GUICreate("Guitar Notes Memorizer", 1302, 146, Default, Default,$WS_POPUP) GUICtrlCreatePic($sPath & "\images.bmp", 0, 0, 1302, 146) GUICtrlSetState(-1, $GUI_DISABLE) Local $iLeft = 10, $iTop = 6, $aFretButton[150] = _ ["0e", "1e", "2e", "3e", "4e", "5e", "6e", "7e", "8e", "9e", "10e", "11e", "12e", "13e", "14e", "15e", "16e", "17e", "18e", "19e", "20e", "21e", "22e", "23e", "24e", "0B", "1B", "2B", "3B", "4B", "5B", "6B", "7B", "8B", "9B", "10B", "11B", "12B", "13B", "14B", "15B", "16B", "17B", "18B", "19B", "20B", "21B", "22B", "23B", "24B", "0G", "1G", "2G", "3G", "4G", "5G", "6G", "7G", "8G", "9G", "10G", "11G", "12G", "13G", "14G", "15G", "16G", "17G", "18G", "19G", "20G", "21G", "22G", "23G", "24G", "0D", "1D", "2D", "3D", "4D", "5D", "6D", "7D", "8D", "9D", "10D", "11D", "12D", "13D", "14D", "15D", "16D", "17D", "18D", "19D", "20D", "21D", "22D", "23D", "24D", "0A", "1A", "2A", "3A", "4A", "5A", "6A", "7A", "8A", "9A", "10A", "11A", "12A", "13A", "14A", "15A", "16A", "17A", "18A", "19A", "20A", "21A", "22A", "23A", "24A", "0E", "1E", "2E", "3E", "4E", "5E", "6E", "7E", "8E", "9E", "10E", "11E", "12E", "13E", "14E", "15E", "16E", "17E", "18E", "19E", "20E", "21E", "22E", "23E", "24E"] For $i = 0 To 149 ; Look at this code for laying out controls in a grid $aFretButton[$i] = GUICtrlCreateButton($aFretButton[$i], $iLeft, $iTop, 40, 20) GUICtrlSetBkColor($aFretButton[$i], 0xCDAA7D) Switch $i Case 0, 12, 24, 25, 37, 49, 50, 62, 74, 75, 87, 99, 100, 112, 124, 125, 137, 149 GUICtrlSetColor($aFretButton[$i], 0xFF0000) Case 3, 5, 7, 9, 15, 17, 19, 21, 28, 30, 32, 34, 40, 42, 44, 46, 53, 55, 57, 59, 65, 67, 69, 71, 78, 80, 82, 84, 90, 92, 94, 96, 103, 105, 107, 109, 115, 117, 119, 121, 128, 130, 132, 134, 140, 142, 144, 146 ; THIS IS UNFINISHED GUICtrlSetColor($aFretButton[$i], 0x0000FF) EndSwitch If Mod($i + 1, 25) <> 0 Then $iLeft += 52 Else $iLeft = 10 $iTop += 23 EndIf Next GUISetState() ; will display the GUI Local $msg Local $j Local $myarr[4] ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg <> $myarr[0] And $msg <> $myarr[1] And $msg <> $myarr[2] Then ; Check the button isn't highlighted already Switch $msg Case $aFretButton[0] To $aFretButton[149] $j = $msg - $aFretButton[0] + 1 $myarr[3] = $myarr[2] $myarr[2] = $myarr[1] $myarr[1] = $myarr[0] $myarr[0] = $msg ;GUICtrlSetStyle($myarr[0], Default, $WS_EX_CLIENTEDGE) GUICtrlSetBkColor($myarr[0], 0x66CD00) ; Give a bit more highlight GUICtrlSetStyle($myarr[3], Default, $WS_EX_TRANSPARENT) GUICtrlSetBkColor($myarr[3], 0xCDAA7D) Case $GUI_EVENT_CLOSE ExitLoop EndSwitch EndIf WEnd EndFunc ;==>Exampleimages.bmp1 point
-
It's a pleasure. I hope you keep us informed of your progress. There are a few guitarists on the forum, including admin and AutoIt creator Jon.1 point
-
Ah, that's when you know the actual name of the function. No problem then, at least you learnt something.1 point
-
my bad .. i searched under index...1 point
-
Variables should always be declared in the smallest scope possible in any language (for languages that support it). For example, don't front-load your functions with all the variable declarations. Declare variables right before they are used. If a variable doesn't need to exist in global scope then use it in local scope. Prefer function return values and function parameters to pass data around rather than global variables. Keep variables in existence no more than necessary.1 point
-
I changed the function, so now it can install more then one font (if passing wildcard as file name)... InstallFont("\\server.local\Software\_Install\_Default\1\CORPORATE FONT\*.*") Func InstallFont($sSourceFile, $sFontDescript="", $sFontsPath="") Local Const $HWND_BROADCAST = 0xFFFF Local Const $WM_FONTCHANGE = 0x1D If $sFontsPath = "" Then $sFontsPath = @WindowsDir & "\fonts" Local $sFontName = StringRegExpReplace($sSourceFile, "^.*\\", "") If Not FileCopy($sSourceFile, $sFontsPath & "\" & $sFontName, 1) Then Return SetError(1, 0, 0) Local $hSearch = FileFindFirstFile($sSourceFile) Local $iFontIsWildcard = StringRegExp($sFontName, "\*|\?") Local $aRet, $hGdi32_DllOpen = DllOpen("gdi32.dll") If $hSearch = -1 Then Return SetError(2, 0, 0) If $hGdi32_DllOpen = -1 Then Return SetError(3, 0, 0) While 1 $sFontName = FileFindNextFile($hSearch) If @error Then ExitLoop If $iFontIsWildcard Then $sFontDescript = StringRegExpReplace($sFontName, "\.[^\.]*$", "") $aRet = DllCall($hGdi32_DllOpen, "Int", "AddFontResource", "str", $sFontsPath & "\" & $sFontName) If IsArray($aRet) And $aRet[0] > 0 Then RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts", _ $sFontDescript, "REG_SZ", $sFontsPath & "\" & $sFontName) EndIf WEnd DllClose($hGdi32_DllOpen) DllCall("user32.dll", "Int", "SendMessage", "hwnd", $HWND_BROADCAST, "int", $WM_FONTCHANGE, "int", 0, "int", 0) Return 1 EndFunc Edit: changed to DllOpen mode. Edit 2: Added full path writing (to registry), in case that we want to install font to other path then @WindowsDir\fonts.1 point