Leaderboard
Popular Content
Showing content with the highest reputation on 05/24/2012 in all areas
-
Ever had the need to pick a hex value for a color for a GUI or a control? Ever tried to figure out how to get those numbers into your script once you've picked the perfect color? I have come up with an extremely small script, that when compiled and placed in a folder inside the SciTE folder will allow you to quickly select the color you want using the _ChooseColor dialog. It will then paste this color code into your script where you cursor is currently placed. It works with Scite only for now, mainly because it uses ControlSend to paste the value into SciTE's editor window, but can easily be modified to work with any editor by changing the window title and control ID it's sending to. This code will work when compiled and placed into the "Autoit3\Scite\ColorChooser" folder, or wherever you have your installation of SciTE, but has to be in the folder named ColorChooser for the tool code to work, or you'll have to change that yourself. Here's the code for the colorchooser: #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_Run_Tidy=y #Tidy_Parameters=/rel #AutoIt3Wrapper_Run_Obfuscator=y #Obfuscator_Parameters=/so #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <Misc.au3> #include <SendMessage.au3> Opt("WinTitleMatchMode", 2) Global $sDefaultColor = 0 Global $iMode = 1 Global Const $WM_COPYDATA = 0x004A If $cmdline[0] > 0 Then $sDefaultColor = $cmdline[1] EndIf If StringLeft($sDefaultColor, 2) <> "0x" Then $iMode = 0 $sDefaultColor = "0x" & $sDefaultColor EndIf $sReturn = _ChooseColor(2, $sDefaultColor, 2) If $sReturn = -1 Then Exit (1) If Not $iMode Then $sReturn = StringMid($sReturn, 3) EndIf _SciTE_InsertText($sReturn) Func _SciTE_InsertText($sString) Return _SciTE_Send_Command(0, WinGetHandle("DirectorExtension"), "insert:" & $sString) EndFunc ;==>_SciTE_InsertText Func _SciTE_Send_Command($hHandle, $hSciTE, $sString) Local $ilParam, $tData If StringStripWS($sString, 8) = "" Then Return SetError(2, 0, 0) ; String is blank. EndIf $sString = ":" & Dec(StringTrimLeft($hHandle, 2)) & ":" & $sString $tData = DllStructCreate("char[" & StringLen($sString) + 1 & "]") ; wchar DllStructSetData($tData, 1, $sString) $ilParam = DllStructCreate("ptr;dword;ptr") ; ulong_ptr;dword;ptr DllStructSetData($ilParam, 1, 1) ; $ilParam, 1, 1 DllStructSetData($ilParam, 2, DllStructGetSize($tData)) DllStructSetData($ilParam, 3, DllStructGetPtr($tData)) _SendMessage($hSciTE, $WM_COPYDATA, $hHandle, DllStructGetPtr($ilParam)) Return Number(Not @error) EndFunc ;==>_SciTE_Send_Command As you can see, there's not a whole lot to it. It just pops open the color chooser dialog, copies the results to the clipboard and then pastes it into SciTE using the ControlSend command. You will also notice, that if you don't choose a color, by hitting cancel in the Color Chooser dialog, it will also exit without pasting anything, so you shouldn't need to worry about pasting something you don't want in your scripts. This code should be added to your SciTEUser.properties file so that you can call it from within SciTE by hitting Ctrl-Alt-C, this can be changed if you already have a hot key set to that combination. # 43 Color Chooser command.name.43.*=Color Chooser command.43.*="$(SciteDefaultHome)\ColorChooser\ColorChooser.exe" $(CurrentSelection) command.shortcut.43.*=Ctrl+Alt+C That's all there is to it, enjoy. EDIT: I have updated the script and the SciTEUser.properties code so that if you have a color code that's currently selected when this is called, it will send that to the _ChooseColor dialog now as the starting color. UPDATED: 31-May-12 I've updated the script so that it now uses the "DirectorExtension" as suggested by guinness instead of copying the data to the clipboard and pasting it into SciTE, which might cause problems with what you have on the clipboard currently. I have also updated it so that if you send the script a color in the format "FFFFFF" without the preceeding "0x", it will return the color code in the same format. This is useful if, for example, you're changing a color in one of SciTE's properties files, which don't start with "0x". I've also changed the command.43.* line, I've moved the quote from the end of the line to the end of the command because I've noticed that a lot of times it causes issues if the color code is inside the quotes.1 point
-
Tweaks Firefox #include-once #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #include <File.au3> ; Only Needed if $TemporaryDirectory parameter is omitted. If File.au3 is included already in your main script then remove this line and specify the temporary directory parameter when calling the _Tweak_FF Function. #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.7.23 (beta) Author: Decipher Script Function: Tweak All Mozilla Firefox Profiles Prefs.js File for Network & Miscellanous Optimization. Functions: _Tweak_FF() Requires FFConfig.txt in script directory with correctly formatted configuration entries. Usage: _Tweak_FF($PromptTitle, $BackupLocation, $TemporaryDirectory, $PromptUser) $PromptTitle is Optional, Defaults to "" $BackupLocation is Optional, Defaults to Current User's Desktop Directory Name of Profile Directory, will create directory structure if it does not exist. $TemporaryDirectory is Optional, Defaults to temporary file. The file is guaranteed not to exist yet $PromptUser is Optional, Defaults to 1 = Yes Prompt User to Close Firefox, 0 = No Terminate Process Automatically Return 1 if no error occurred otherwise Returns 0 and sets @error and @extended macros. @extended: 1 = Error reading FFConfig.txt. 2 = User canceled prompt to close firefox. 3 = Error locating profile directories. 4 = Could not read profiles prefs.js file. 5 = Error opening temporary prefs.js file for writing. 6 = Error configuration entry in FFConfig.txt is incorrectly formatted. 7 = Error overwriting prefs.js file with the newly generated configuration file. 8 = Error a profile directory exists but does not contain a prefs.js file. 9 = Temporary files were not deleted. 10 = Some other error occured. Example: _Tweak_FF("Tweaking Firefox", @DesktopDir) Configuration Entries inside FFConfig.txt: user_pref("nglayout.initialpaint.delay", 0); user_pref("network.http.pipelining", true); user_pref("network.http.proxy.pipelining", true); user_pref("network.http.pipelining.maxrequests", 10); user_pref("network.dns.disableIPv6", false); user_pref("content.notify.backoffcount", 5); user_pref("plugin.expose_full_path", true); user_pref("ui.submenuDelay", 0); user_pref("config.trim_on_minimize", false); user_pref("browser.chrome.favicons", false); user_pref("browser.blink_allowed", false); user_pref("network.dns.disableIPv6", true); user_pref("network.dnsCacheEntries", 200); user_pref("network.dnsCacheExpiration", 240); user_pref("network.http.connect.timeout", 60); user_pref("network.http.keep-alive.timeout", 300); user_pref("network.http.max-connections-per-server", 16); user_pref("network.http.max-persistent-connections-per-proxy", 12); user_pref("layout.spellcheckDefault", 0); user_pref("browser.startup.homepage", "https://www.google.com/"); #ce ---------------------------------------------------------------------------- _Tweak_FF("Test", @DesktopDir & "BackupDirectory", "", 0) If @error Then MsgBox(0,"Test", @extended) Func _Tweak_FF($PromptTitle = "Tweaking Firefox", $BackupLocation = @DesktopDir, $TemporaryDirectory = "", $PromptUser = 1) If $TemporaryDirectory = "" Then $TemporaryDirectory = _TempFile() DirCreate($TemporaryDirectory) EndIf Local $FileWrite, $FileLine, $PrefsString, $FileContents, $ProfileDirectory, $PrefsFile, $ComparisonString, $Option, $StrPosition, $StrChars, $CharsDiff $FileContents = FileRead(@ScriptDir & "FFConfig.txt") If $FileContents = "" Then Return SetError(1, 1, 0) Local $FFTweak = StringSplit($FileContents, @CRLF, 3) $FileContents = "" If $PromptUser = 1 Then $Option = MsgBox(1 + 48 + 262144, $PromptTitle, "Firefox must be closed to apply tweaks correctly. You can close it manually or forcibly close Firefox's process by selecting continue. Firefox will be terminated automatically in 30 seconds.", 30) If $Option = 2 Then Return SetError(1, 2, 0) EndIf FileChangeDir(@AppDataDir & "MozillaFirefoxProfiles") Local $Profiles = FileFindFirstFile("*.*") If $Profiles = -1 Then Return SetError(1, 3, 0) While 1 $ProfileDirectory = FileFindNextFile($Profiles) If @error Then ExitLoop If $ProfileDirectory <> "" And FileExists(@AppDataDir & "MozillaFirefoxProfiles" & $ProfileDirectory & "prefs.js") Then Local $User_Prefs_File_Location = @AppDataDir & "MozillaFirefoxProfiles" & $ProfileDirectory & "prefs.js" If FileCopy($User_Prefs_File_Location, $BackupLocation & "" & $ProfileDirectory & "prefs.js", 9) Then $FileContents = FileRead($User_Prefs_File_Location) If $FileContents = "" Then Return SetError(1, 4, 0) $PrefsFile = FileOpen($TemporaryDirectory & "prefs.js", 10) If $PrefsFile = -1 Then Return SetError(1, 5, 0) $FileLine = StringSplit($FileContents, ";") For $i = 1 To $FileLine[0] $FileWrite = True For $index2 = 0 To UBound($FFTweak, 1) - 1 Step 1 $StrPosition = StringInStr($FFTweak[$index2], ",", 2, -1) If $StrPosition = 0 And StringIsSpace($FFTweak[$index2]) <> 0 Then Return SetError(1, 6, 0) $StrChars = StringLen($FFTweak[$index2]) $CharsDiff = $StrChars - $StrPosition $ComparisonString = StringTrimRight($FFTweak[$index2], $CharsDiff) If StringInStr($FileLine[$i], $ComparisonString, 2) Then $FileWrite = False ElseIf StringIsSpace($FileLine[$i]) Then $FileWrite = False EndIf Next $PrefsString = StringStripWS($FileLine[$i], 2) If $FileWrite = True Then FileWrite($PrefsFile, $PrefsString & ";") Next FileWrite($PrefsFile, @CRLF) For $i = 0 To UBound($FFTweak, 1) - 1 Step 1 If StringIsSpace($FileLine[$i]) = 0 Then FileWrite($PrefsFile, $FFTweak[$i] & @CRLF) Next FileClose($PrefsFile) While ProcessExists("firefox.exe") Or ProcessExists("plugin-container.exe") If ProcessClose("firefox.exe") <> 1 Then ProcessClose("plugin-container.exe") Sleep(50) WEnd If FileCopy($TemporaryDirectory & "prefs.js", $User_Prefs_File_Location, 9) <> 1 Then If DirRemove($TemporaryDirectory, 1) <> 1 Then Return SetError(1, 9, 0) Return SetError(1, 7, 1) EndIf Else If DirRemove($TemporaryDirectory, 1) <> 1 Then Return SetError(1, 9, 0) Return SetError(1, 8, 0) EndIf EndIf WEnd If DirRemove($TemporaryDirectory, 1) <> 1 Then Return SetError(1, 9, 0) If @error Then Return SetError(1, 10, 0) Return 1 EndFunc ;==>_Tweak_FFFFConfig.txt _Tweak_FF.au31 point
-
techno81, Before you make a carreer changing mistake, seek advice from these people kylomas1 point
-
What I do when I'm not 100% sure of where I put the quotes in a line like that is to highlight the whole line (the part inside the parentheses) in Scite and then hit ALT-D which will give you a consolewrite line containing the data and the variables, so you can see exactly how it is going to look in the command line. You can even copy that consolewrite to another script and just run it to see if you've done it right.1 point