Online Function Library
ahkuser:ahkuser
It'd be nice for users if u categorize your functions.
CleanNews.in : Bite sized latest news headlines from India with zero bloat
ControlGetHWND
=====================
DecToHex(In_Val) here
RGBtoHex(R,G, here
GetRelPos(In_X,In_Y,In_Angle,In_Radius,Byref Tx, Byref Ty) here
LeapYear(In_Year) here
StringDelete(In_String,In_Start,In_Count) here
StringFlip(In_String) here
StringGetChar(In_String,In_Posi,Param3) here
StringInsert(In_String,In_Posi,In_Insert) here
StringReplaceChar(ByRef In_String,In_Posi,New_Char) here
Swap_Values(Byref val1, ByRef Val2) here
DegToRad(In_Deg) here
RadToDeg(In_Rad) here
=====================
Pixel Matrix Search here
Simple function, returns path of default browser so you can open links in new windows (with the system's default browser ofcourse).
; The next line is an example (function below) Run, % Web() "http://www.google.com/ig" Web() { RegRead, htmlOpenPath, HKCR, htmlfile\shell\open\command Return, %htmlOpenPath% }--------------------------------------------------
I posted this somewhere else but for anybody who needs it...
This makes vars you might've got from FileRead/RegRead/IniRead that have escaped variables into real variables, see the example in the script.
Download
--------------------------------------------------
Commands Function Collection - functionized all comands that have an outputvar
--------------------------------------------------
WinFX! - Some gui window effects/animations.
Download Functions
Download Example
--------------------------------------------------
CleanNews.in : Bite sized latest news headlines from India with zero bloat
Should I bump this topic everytime I post a new function :?:
Factorial(number) { sum=%number% loop { if ((number-a_index) <= 1) break sum:=sum*(number-a_index) } return sum }
Converts Hexadecimal to Decimal-
(positive and negative is not taken into account as I wrote it for colour conversion.)
HEXtoDEC(HEX) { StringUpper, HEX, HEX loop, % StrLen(HEX) { StringMid, Col, HEX, % (StrLen(HEX)+1)-a_index, 1 if Col is integer DEC1:=Col*16**(a_index-1) Else DEC1:=(Asc(Col)-55)*16**(a_index-1) DEC+=%DEC1% } return DEC }
Converts Hexadecimal to Decimal-
To convert an integer from decimal to hexadecimal, use this example (the converse can be used to convert in the opposite direction):
SetFormat, integer, hex
VariableContainingAnInteger += 0
SetFormat, integer, d
autohotkey.com/net Site Manager
Contact me by email (polyethene at autohotkey.net) or message tidbit
I wondered why I couldn't find an existing function to do it
Hex2Dec(_hex) { local intFormat, dec intFormat = %A_FormatInteger% SetFormat Integer, D dec += "0x" . _hex SetFormat Integer, %intFormat% Return dec }The function may be used if you are not sure if the SetFormat was set to hex before calling the function... Actually, no need for function if you never set it:
d := 0
d += "0x" . hexDigits
The topic is old, but I believe such useful list should go to the Wiki, easier to maintain than a list of messages.
MsgBox % "0!="Factorial(0)", 1!="Factorial(1)", 2!="Factorial(2)", 5!="Factorial(5) Factorial(n) { f = 1 loop %n% f *= A_Index return f }As PhiLho said, if your current integer format is decimal (the default), you don't need a function to convert a hex number to decimal form. Just add 0 to the hex number and AHK converts it to decimal:
hex = 0xFF dec := hex+0 ; dec = hex converted to decimal MsgBox % hex+0 ; can be used in output w/o assigning to vars
I'm curious as to why you define the local variables when there is no need to:local intFormat, dec
Functions[/url]":3kqwhcnk]All variables referenced or created inside a function are local by default (except built-in variables such as Clipboard, ErrorLevel, and A_TimeIdle).
You can use A_FormatInteger and A_FormatFloat.The function may be used if you are not sure if the SetFormat was set to hex before calling the function...
autohotkey.com/net Site Manager
Contact me by email (polyethene at autohotkey.net) or message tidbit
dec := hex+0 ; dec = hex converted to decimal
I didn't expect it to be that simple :shock:
Strictly speaking, the Factorial function is not correct, because it returns 0 for 0!, but the right value is 1. Here it is corrected:
I didn't notice that. Thanks for the amended version.
I was actually using that function for a Permutation script that I was writing yesterday (just to see if I could write one). After a couple hours of writing it, I found one you had written already that worked a hundred times faster :oops:
Thanks for your comments and corrections.