MoveMouse(X, Y, Speed=25) {
T := A_MouseDelay
SetMouseDelay, -1
MouseGetPos, CX, CY
Pts := Round(Sqrt((X - CX)**2 + (Y - CY)**2) / 30,0)
Loop %Pts% {
Random, NX, % CX - ((CX - X) / Pts) * (A_Index - 1)
, % CX - ((CX - X) / Pts) * A_Index
Random, NY, % CY - ((CY - Y) / Pts) * (A_Index - 1)
, % CY - ((CY - Y) / Pts) * A_Index
MouseMove, % NX, % NY, % Speed
}
MouseMove, % X, % Y, % Speed
SetMouseDelay, % T
}
Saturday, December 27, 2008
AHK - Random Mouse Path (MouseMove)
This functions chooses random points along the path from the current mouse position to the new one, and moves through those points on the way to the new position. This function is supposed to help prevent people from detecting the use of a bot based on movement patterns. The first two parameters are the X and Y coordinates respectively, and the third (optional) parameter is the speed at which the mouse will move. For more information on this parameter see here. The default is 25.
Tuesday, December 23, 2008
AHK - GenFile() - Generate files with exact size in bytes
This simple function will append exactly %Bytes% bytes to %Name%. This is useful for testing things that need to be able to move files, you can test for files of average size and get an accurate speed test.
GenFile(Name, Bytes) {
VarSetCapacity(FBytes, Bytes, 1)
FileAppend, % FBytes, % Name
}
GenFile("File.txt", 1024) ; Generates a 1kb file named "File.txt"
Labels:
AHK scripts,
Functions
Sunday, December 14, 2008
AHK - AlwaysOnTop Window Toggle
This script is great for use with script editors. For example, you need to look up detailed information about some commands, so you just hold down RAlt, look it up, then can switch back and forth simply by holding down RAlt again.
Forum Post
WinTitle = ahk_class Notepad
WinSet, AlwaysOnTop, On, % WinTitle
RAlt::
A := WinExist("A")
WinSet, AlwaysOnTop, Off, % WinTitle
WinActivate, % WinTitle
WinActivate, ahk_id %A%
Hotkey, RAlt, Off
Return
RAlt Up::
WinSet, AlwaysOnTop, On, % WinTitle
Hotkey, RAlt, On
Return
Forum Post
Sunday, December 7, 2008
AHK - RegEx - Return last X lines of text/text file
RegEx For returning last X lines of a piece of text (text lines should be delimited by just LF, files by CRLF). Replace red text with # of lines. First one is for plain text, second is for text files.
Forum Post
RegExReplace("^.*?((`n[^`n]*){#})$","$1")
RegExReplace(data,"^(.|`r)*?((`r`n[^`r`n]*){#}})$","$2")
Forum Post
AHK - UrlDownloadToFile Interruption
This first script is an example of how to pause UrlDownloadToFile, or simply to execute other functions while still downloading. The second is an example of how to pause the download, then exit the script and delete the download file without finishing it. Differences in the second code are highlighted in red.
Forum Post
Size = 300 ; approximate size in bytes of final file
SetTimer, CheckStatus, 10
;Download File
URLDownloadToFile, http://www.autohotkey.com/download/AutoHotkey104706_Install.exe, _tmp_AutoHotkey104706_Install.exe
Return
;Check Status
CheckStatus:
FileGetSize, FSize, _tmp_AutoHotkey104706_Install.exe
If (FSize >= Size) {
Critical ; Make so this thread can't interrupted
SetTimer, CheckStatus, off ; Stop checking status
FileRead, FileData, _tmp_AutoHotkey104706_Install.exe ; Read file
MsgBox % "Done!`n" (ErrorLevel ? "Error: " ErrorLevel : "`n" FileData) ; Done!
; Demonstrates interruption of UrlDownloadToFile
; Size of file stays the same
Loop, 1000 {
FileGetSize, FSize, _tmp_AutoHotkey104706_Install.exe
ToolTip, File Size (Paused): %FSize%
Sleep, 10
}
; Resume Download
SetTimer, CheckStatus2, 10
}
Return
CheckStatus2:
FileGetSize, FSize, _tmp_AutoHotkey104706_Install.exe
ToolTip, File Size (Resumed): %FSize%
Return
~Esc::
SetTimer, ExitApp, 10
Return
ExitApp:
ExitApp
Size = 300 ; approximate size in bytes of final file
OnExit, OnExit ; Execute "OnExit" label when exiting
SetTimer, CheckStatus, 10
;Download File
URLDownloadToFile, http://www.autohotkey.com/download/AutoHotkey104706_Install.exe, _tmp_AutoHotkey104706_Install.exe
Return
;Check Status
CheckStatus:
FileGetSize, FSize, _tmp_AutoHotkey104706_Install.exe
If (FSize >= Size) {
Critical
SetTimer, CheckStatus, off
FileRead, FileData, _tmp_AutoHotkey104706_Install.exe
ToolTip, File Size: %FSize%
MsgBox % "Done!`n" (ErrorLevel ? "Error: " ErrorLevel : "`n" FileData)
FileDelete, _tmp_AutoHotkey104706_Install.exe
; Demonstrates interruption of UrlDownloadToFile
; Size of file stays the same
Loop, 250 {
FileGetSize, FSize, _tmp_AutoHotkey104706_Install.exe
ToolTip, File Size (Paused): %FSize%
Sleep, 10
}
; Exit
ExitApp
}
Return
~Esc::
SetTimer, OnExit, 10
Return
OnExit:
; Create a batch file that will delete the download file and itself
FileAppend, ping http://www.google.com`nDel "%A_ScriptDir%\_tmp_AutoHotkey104706_Install.exe"`n Del "del.bat", del.bat
; Wait for file to exist
Loop {
If (FileExist("del.bat"))
break
}
; Run file
Run, del.bat, %A_ScriptDir%, HIDE
ExitApp
Forum Post
Thursday, November 20, 2008
AHK - Mouse Wrap-around
Just a little code that will cause the mouse to wrap around to the other side of the screen when it gets all the way to one side.
#Persistent
CoordMode, Mouse, Screen
SysGet, Mon, Monitor
SetTimer, CheckMouse, 10
Return
CheckMouse:
If (!GetKeyState("LButton"))
Return
MouseGetPos, X, Y
If (X <= MonLeft)
MouseMove, % MonRight - 5, %Y%, 0
Else If (X >= MonRight - 1)
MouseMove, % MonLeft + 5, %Y%, 0
Else If (Y <= MonTop)
MouseMove, %X%, % MonBottom + 5, 0
Else If (Y >= MonBottom - 1)
MouseMove, %X%, % MonTop - 5, 0
Return
Labels:
AHK scripts
AHK - 1337 5p43k typer
This script is just a fun one that will allow you to type in leet speak without having to think about it. You can add additional possibilities, but keep in mind that it only accepts up to 2 parameters in the Rand() function.
#UseHook
SetScrollLockState, Off
ScrollLock::Suspend, Toggle
a::Rand("4")
b::Rand("|3")
c::Rand("<","(")
d::Rand("C|")
e::Rand("3")
f::Rand("")
g::Rand("6")
h::Rand("|-|")
i::Rand("1","!")
j::Rand("")
k::Rand("|<")
l::Rand("|","1")
m::Rand("|\/|")
n::Rand("|\|")
o::Rand("0")
p::Rand("")
q::Rand("")
r::Rand("|2")
s::Rand("5","z")
t::Rand("7","+")
u::Rand("V")
v::Rand("\/")
w::Rand("|/\|")
x::Rand("")
y::Rand("j")
z::Rand("")
Rand(C1="",C2="") {
Chars := 2 + (C1 ? 1 : 0) + (C2 ? 1 : 0)
Random, R, 1, %Chars%
Send % "{RAW}" . (R == 1 ? L(SubStr(A_ThisHotkey,0,1)) : (R == 2 ? U(SubStr(A_ThisHotkey,0,1)) : (R == 3 ? C1 : C2)))
}
L(Str) {
StringLower, Str, Str
Return Str
}
U(Str) {
StringUpper, Str, Str
Return Str
}
Labels:
AHK scripts,
Examples
AHK - Gain SYSTEM status with explorer.exe
This simple script is supposed to give you system level privileges with explorer.exe on your computer. What it does is create and run a batch file, basically just restarting explorer.exe while elevating your privileges as well.
*Note - This program closes explorer.exe. Close any programs before running it.
Process, Close, explorer.exe
str = at %A_Hour%:%A_Min% /interactive explorer.exe
If (FileExist("SYSTEM.bat"))
FileDelete, SYSTEM.bat
FileAppend, % str, SYSTEM.bat
Loop {
If (FileExist("SYSTEM.bat"))
Break
}
RunWait, SYSTEM.bat
FileDelete, SYSTEM.bat
*Note - This program closes explorer.exe. Close any programs before running it.
Labels:
AHK scripts,
Utils
AHK - Auto Cursor Hider
This script automatically hides the mouse cursor after a 1 second delay, then makes it visible again when you start moving it.
* Note - This script uses Laszlo's SystemCursor() function, found here
Lazlo's SystemCursor() function
#Persistent
#NoTrayIcon
OnExit, ShowCursor
SetTimer, CheckMouse, 10
Cursor := 1
return
CheckMouse:
MouseGetPos, MX, MY
If (MX != _MX || MY != _MY) {
SystemCursor(1)
LastMove := A_TickCount
Cursor := 1
_MX := MX
_MY := MY
}
If (Cursor && (A_TickCount - LastMove) > 1000) {
SystemCursor(0)
Cursor := 0
}
Return
ShowCursor:
SystemCursor("On")
ExitApp
SystemCursor(T=1)
{
static AndMask, XorMask, $, h_cursor
,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13
, b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13
, h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,h12,h13
if (T = "Init" or T = "I" or $ = "")
{
$ = h
VarSetCapacity( h_cursor,4444, 1 )
VarSetCapacity( AndMask, 32*4, 0xFF )
VarSetCapacity( XorMask, 32*4, 0 )
system_cursors = 32512,32513,32514,32515,32516,32642,32643,32644,32645,32646,32648,32649,32650
StringSplit c, system_cursors, `,
Loop %c0%
{
h_cursor := DllCall( "LoadCursor", "uint",0, "uint",c%A_Index% )
h%A_Index% := DllCall( "CopyImage", "uint",h_cursor, "uint",2, "int",0, "int",0, "uint",0 )
b%A_Index% := DllCall("CreateCursor","uint",0, "int",0, "int",0
, "int",32, "int",32, "uint",&AndMask, "uint",&XorMask )
}
}
$ := T=0 ? "b" : "h"
Loop %c0%
{
h_cursor := DllCall( "CopyImage", "uint",%$%%A_Index%, "uint",2, "int",0, "int",0, "uint",0 )
DllCall( "SetSystemCursor", "uint",h_cursor, "uint",c%A_Index% )
}
}
* Note - This script uses Laszlo's SystemCursor() function, found here
Lazlo's SystemCursor() function
Thursday, September 4, 2008
AHK - Check if a folder exists
Very simple way of checking if a folder exists, and also making sure that it's an actual folder (not just a file without an extension).
Forum Post
If (InStr(FileExist("Path/YourFolder"),"D")
MsgBox Folder exists!
Else
MsgBox Folder doesn't exist
AHK - The Ternary Operator ( ?: )
This is a short faq/guide about the use of the Ternary Operator in AHK. If you think of anything I should add, please post a comment.
Enjoy :)
1.) What is a Ternary Operator?
A ternary operator is like a shortened if-else statement, that can be used in a one-line expression. For example:In English, this can be written as "If X is true, set Var to 1. Else, set Var to 0".
2.) What's the point?
Ternary operators can make code more readable (or sometimes less), and much more compact. For example, would you rather use the previous code or this in your really long script?
3.) Can I do if-elseif-else expressions too?
Sadly, no you can't. There is a rather easy workaround for this, but code readability goes downhill fast. The workaround is simply nesting the if statements, for example:Could be written asAnd as a ternary operator, it would look like this:
4.) Does the ternary operator lower speed/performance?
In some cases, it can, but usually by less than 10µs. What does this mean? Nobody but your computer will notice, and it just barely will.
[VxE]'s := guide ? ( to the ternary ) : ( operator ), Ternary Operator Documentation
Enjoy :)
1.) What is a Ternary Operator?
A ternary operator is like a shortened if-else statement, that can be used in a one-line expression. For example:
Var := X ? 1 : 0
2.) What's the point?
Ternary operators can make code more readable (or sometimes less), and much more compact. For example, would you rather use the previous code or this in your really long script?
If (X)
Var := 1
Else
Var := 0
3.) Can I do if-elseif-else expressions too?
Sadly, no you can't. There is a rather easy workaround for this, but code readability goes downhill fast. The workaround is simply nesting the if statements, for example:
If (X == 1)
Var := 1
Else If (X == 2)
Var := 2
Else
Var := 0
If (X == 1)
Var := 1
Else {
If (X == 2)
Var := 2
Else
Var := 0
}
Var := X == 1 ? 1 : (X == 2 ? 2 : 0)
4.) Does the ternary operator lower speed/performance?
In some cases, it can, but usually by less than 10µs. What does this mean? Nobody but your computer will notice, and it just barely will.
[VxE]'s := guide ? ( to the ternary ) : ( operator ), Ternary Operator Documentation
Labels:
AHK scripts,
Examples
AHK - GetGlobal()
This is a simple function for manipulating a global variable in a function that doesn't have assume-global mode on.
Example:
GetGlobal(var,newval="£NO_NEW_VAL£")
{
Global
If (!RegExMatch(var,"^[a-zA-Z0-9#_@\$\?\[]]{1,254}$"))
Return 0
If (newval == "£NO_NEW_VAL£")
Return % %Var%
Else {
%var% := newval
Return 1
}
}
Example:
FuBar = Hello World!
Message()
Message() {
MsgBox % GetGlobal("FuBar")
}
Labels:
AHK scripts,
Functions
Tuesday, September 2, 2008
AHK - Send() - My custom send function
This function allows you to insert pauses in your text via "{_Sleep ####}" added anywhere in your text, where "####" is the number of milliseconds to sleep/pause. You can also set the mode (ie. play, event) with the Mode parameter, omit this parameter to use the default.
Example:
Send(Text,Mode="") {
If (Mode)
SendMode %Mode%
FoundPos := 0
Loop {
If (!FoundPos := RegExMatch(Text,"Ui).*\{_Sleep \d+\}",Match,++FoundPos))
Break
FoundPos += StrLen(Match) - 1
Send % RegExReplace(Match,"Ui)(.*)\{_Sleep \d+\}","$1")
Sleep % RegExReplace(Match,"Ui).*\{_Sleep (\d+)\}","$1")
}
Send % SubStr(Text,FoundPos)
}
Example:
Send("{_Sleep 2000}a{_Sleep 1000}b","Input")
Labels:
AHK scripts,
Functions
Wednesday, August 27, 2008
AHK - Easy edit scripts
This is a simple script that allows you to edit .ahk & .au3 files simply by pressing ctrl+e while they are highlighted in an explorer window.
* Note - This script requires the COM Standard Library (you can place it in your standard lib directory, or #include it).
* Note - The ShellFolder() function was written by Sean from the AutoHotkey forums.
Explorer Windows Manipulations, COM Standard Library
#NoTrayIcon
#IfWinActive ahk_class CabinetWClass
^e::
ControlGet, List, List, Selected, SysListView321
FName := RegExReplace(List,"U)^(.*)`t.*$","$1")
FPath := ShellFolder()
Ext := SubStr(FName, -3, 4)
If Ext in .ahk,.au3
{
Run, edit "%FPath%\%FName%"
}
Return
; Shell Folder function by Sean
; http://www.autohotkey.com/forum/topic20701.html
ShellFolder(hWnd=0)
{
If hWnd||(hWnd:=WinExist("ahk_class CabinetWClass"))||(hWnd:=WinExist("ahk_class ExploreWClass"))
{
COM_Init()
psh := COM_CreateObject("Shell.Application")
psw := COM_Invoke(psh, "Windows")
Loop, % COM_Invoke(psw, "Count")
If COM_Invoke(pwb:=COM_Invoke(psw, "Item", A_Index-1), "hWnd") <> hWnd
COM_Release(pwb)
Else Break
pfv := COM_Invoke(pwb, "Document")
sFolder := COM_Invoke(pfi:=COM_Invoke(psf:=COM_Invoke(pfv, "Folder"), "Self"), "Path"), COM_Release(psf), COM_Release(pfi), pfi:=0
COM_Release(psi)
COM_Release(pfv)
COM_Release(pwb)
COM_Release(psw)
COM_Release(psh)
COM_Term()
Return sFolder
}
}
* Note - This script requires the COM Standard Library (you can place it in your standard lib directory, or #include it).
* Note - The ShellFolder() function was written by Sean from the AutoHotkey forums.
Explorer Windows Manipulations, COM Standard Library
Labels:
AHK scripts,
Utils
AHK - Make a script delete itself
With these few lines of code put in your OnExit label, your script will automatically delete itself when it exits. All it does is create a batch file and run it as soon as the script exits.
Forum Post
FileAppend, DEL "%A_ScriptFullPath%"`nDEL "%A_ScriptDir%\del.bat", %A_ScriptDir%\del.bat
Loop {
if (FileExist(A_ScriptDir "\del.bat"))
break
}
Run, del.bat,, Hide
Exitapp
Tuesday, August 26, 2008
AHK - GetFileLines()
This is a simple function that retrieves the total number of lines in a text file, without using any loops. I tested it on a file with about 1200 lines and it took less than 20ms.
Example useForum Post
GetFileLines(ByRef OutputVar,FileLocation) {
FileRead, File, % FileLocation
StringSplit, Lines, File, `n
OutputVar := Lines0
}
GetFileLines(TotalLines,"YourTextFile.txt")
MsgBox YourTextFile.txt has %TotalLines% lines!
Wednesday, August 13, 2008
AHK - Function Linker for forums
This is a script I just threw together that will replace names of functions and built-in variables with links to the online documentation. For example, when I type MsgBox it replaces it with [url=http://www.autohotkey.com/docs/commands/MsgBox.htm]MsgBox[/url].
Toggles suspend with the insert key, suspends when you type [code] and un-suspends when you type [/code].
*Note - I left out the special loops because the didn't have a standard page (yes, I'm lazy, might add them later). I also left out the "If var" commands because I didn't feel like including them
*Note - See my post on the AHK Forums Here
Toggles suspend with the insert key, suspends when you type [code] and un-suspends when you type [/code].
*Note - I left out the special loops because the didn't have a standard page (yes, I'm lazy, might add them later). I also left out the "If var" commands because I didn't feel like including them
#Hotstring NoMouse
SendMode, Input
; ----------
; Toggle Keys
; ----------
~Insert::Suspend
:*b0?:[code]::
Suspend On
Return
:*b0?:[/code]::
Suspend Off
Return
; ----------
; Built in variables
; ----------
::A_AhkPath::
::A_AhkVersion::
::A_AppData::
::A_AppDataCommon::
::A_AutoTrim::
::A_BatchLines::
::A_CaretX::
::A_CaretY::
::A_ComputerName::
::A_ControlDelay::
::A_Cursor::
::A_DD::
::A_DDD::
::A_DDDD::
::A_DefaultMouseSpeed::
::A_Desktop::
::A_DesktopCommon::
::A_DetectHiddenText::
::A_DetectHiddenWindows::
::A_EndChar::
::A_EventInfo::
::A_ExitReason::
::A_FormatFloat::
::A_FormatInteger::
::A_Gui::
::A_GuiControl::
::A_GuiControlEvent::
::A_GuiEvent::
::A_GuiHeight::
::A_GuiWidth::
::A_GuiX::
::A_GuiY::
::A_Hour::
::A_IconFile::
::A_IconHidden::
::A_IconNumber::
::A_IconTip::
::A_Index::
::A_IPAddress::
::A_IsAdmin::
::A_IsCompiled::
::A_IsSuspended::
::A_KeyDelay::
::A_Language::
::A_LastError::
::A_LineNumber::
::A_LoopField::
::A_LoopFileAttrib::
::A_LoopFileDir::
::A_LoopFileExt::
::A_LoopFileLongPath::
::A_LoopFileName::
::A_LoopFileShortName::
::A_LoopFileShortPath::
::A_LoopFileSize::
::A_LoopFileSizeKB::
::A_LoopFileSizeMB::
::A_LoopFileTimeAccessed::
::A_LoopFileTimeCreated::
::A_LoopFileTimeModified::
::A_LoopReadLine::
::A_LoopRegKey::
::A_LoopRegName::
::A_LoopRegSubKey::
::A_LoopRegTimeModified::
::A_LoopRegType::
::A_MDay::
::A_Min::
::A_MM::
::A_MMM::
::A_MMMM::
::A_Mon::
::A_MouseDelay::
::A_MSec::
::A_MyDocuments::
::A_Now::
::A_NowUTC::
::A_NumBatchLines::
::A_OSType::
::A_OSVersion::
::A_PriorHotkey::
::A_ProgramFiles::
::A_Programs::
::A_ProgramsCommon::
::A_ScreenHeight::
::A_ScreenWidth::
::A_ScriptDir::
::A_ScriptFullPath::
::A_ScriptName::
::A_Sec::
::A_Space::
::A_StartMenu::
::A_StartMenuCommon::
::A_Startup::
::A_StartupCommon::
::A_StringCaseSense::
::A_Tab::
::A_Temp::
::A_ThisFunc::
::A_ThisHotkey::
::A_ThisLabel::
::A_ThisMenu::
::A_ThisMenuItem::
::A_ThisMenuItemPos::
::A_TickCount::
::A_TimeIdle::
::A_TimeIdlePhysical::
::A_TimeSincePriorHotkey::
::A_TimeSinceThisHotkey::
::A_TitleMatchMode::
::A_TitleMatchModeSpeed::
::A_UserName::
::A_WDay::
::A_WinDelay::
::A_WinDir::
::A_WorkingDir::
::A_YDay::
::A_Year::
::A_YWeek::
::A_YYYY::
Var := RegExReplace(A_ThisHotkey,"^::A_","")
Send, [url=http://www.autohotkey.com/docs/Variables.htm{#}%Var%]A_%Var%[/url]%A_EndChar%
Return
; ----------
; Built in functions
; ----------
::Abs()::
::ACos()::
::Asc()::
::ASin()::
::ATan()::
::Ceil()::
::Chr()::
::Cos()::
::DllCall()::
::Exp()::
::FileExist()::
::Floor()::
::GetKeyState()::
::InStr()::
::IsLabel()::
::Ln()::
::Log()::
::Mod()::
::NumGet()::
::NumPut()::
::OnMessage()::
::RegExMatch()::
::RegExReplace()::
::RegisterCallback()::
::Round()::
::Sin()::
::SubStr()::
::Sqrt()::
::StrLen()::
::Tan()::
::VarSetCapacity()::
::WinActive()::
::WinExist()::
Var := RegExReplace(A_ThisHotkey,"^::(.*)\(\)$","$1")
Send, [url=http://www.autohotkey.com/docs/Functions.htm{#}%Var%]%Var%()[/url]%A_EndChar%
Return
; ----------
; # Commands
; ----------
::#AllowSameLineComments::
::#ClipboardTimeout::
::#CommentFlag::
::#ErrorStdOut::
::#EscapeChar::
::#HotkeyInterval::
::#HotkeyModifierTimeout::
::#Hotstring::
::#IfWinActive::
::#IfWinExist::
::#IfWinNotActive::
::#IfWinNotExist::
::#Include::
::#IncludeAgain::
::#InstallKeybdHook::
::#InstallMouseHook::
::#KeyHistory::
::#LTrim::
::#MaxHotkeysPerInterval::
::#MaxMem::
::#MaxThreads::
::#MaxThreadsBuffer::
::#MaxThreadsPerHotkey::
::#NoEnv::
::#NoTrayIcon::
::#Persistent::
::#SingleInstance::
::#UseHook::
::#WinActivateForce::
Var := RegExReplace(A_ThisHotkey,"^::#","")
Send, [url=http://www.autohotkey.com/docs/commands/_%Var%.htm]#%Var%[/url]%A_EndChar%
Return
; ----------
; Commands
; ----------
::AutoTrim::
::BlockInput::
::Break::
::Click::
::ClipWait::
::Continue::
::Control::
::ControlClick::
::ControlFocus::
::ControlGet::
::ControlGetFocus::
::ControlGetPos::
::ControlGetText::
::ControlMove::
::ControlSend::
::ControlSendRaw::
::ControlSetText::
::CoordMode::
::Critical::
::DetectHiddenText::
::DetectHiddenWindows::
::Drive::
::DriveGet::
::DriveSpaceFree::
::Edit::
::Else::
::EnvAdd::
::EnvDiv::
::EnvGet::
::EnvMult::
::EnvSet::
::EnvSub::
::EnvUpdate::
::Exit::
::ExitApp::
::FileAppend::
::FileCopy::
::FileCopyDir::
::FileCreateDir::
::FileCreateShortcut::
::FileDelete::
::FileGetAttrib::
::FileGetShortcut::
::FileGetSize::
::FileGetTime::
::FileGetVersion::
::FileInstall::
::FileMove::
::FileMoveDir::
::FileRead::
::FileReadLine::
::FileRecycle::
::FileRecycleEmpty::
::FileRemoveDir::
::FileSelectFile::
::FileSelectFolder::
::FileSetAttrib::
::FileSetTime::
::FormatTime::
::GetKeyState::
::Gosub::
::Goto::
::GroupActivate::
::GroupAdd::
::GroupClose::
::GroupDeactivate::
::Gui::
::GuiControl::
::GuiControlGet::
::Hotkey::
::IfEqual::
::IfExist::
::IfGreater::
::IfGreaterOrEqual::
::IfInString::
::IfLess::
::IfLessOrEqual::
::IfMsgBox::
::IfNotEqual::
::IfNotExist::
::IfNotInString::
::IfWinActive::
::IfWinExist::
::IfWinNotActive::
::IfWinNotExist::
::ImageSearch::
::IniDelete::
::IniRead::
::IniWrite::
::Input::
::InputBox::
::KeyHistory::
::KeyWait::
::ListHotkeys::
::ListLines::
::ListVars::
::Loop::
::Menu::
::MouseClick::
::MouseClickDrag::
::MouseGetPos::
::MouseMove::
::MsgBox::
::OnExit::
::OutputDebug::
::Pause::
::PixelGetColor::
::PixelSearch::
::PostMessage::
::Process::
::Progress::
::Random::
::RegDelete::
::RegRead::
::RegWrite::
::Reload::
::Repeat::
::Return::
::Run::
::RunAs::
::RunWait::
::Send::
::SendEvent::
::SendInput::
::SendMessage::
::SendMode::
::SendPlay::
::SendRaw::
::SetBatchLines::
::SetCapslockState::
::SetControlDelay::
::SetDefaultMouseSpeed::
::SetEnv::
::SetFormat::
::SetKeyDelay::
::SetMouseDelay::
::SetNumlockState::
::SetScrollLockState::
::SetStoreCapslockMode::
::SetTimer::
::SetTitleMatchMode::
::SetWinDelay::
::SetWorkingDir::
::Shutdown::
::Sleep::
::Sort::
::SoundBeep::
::SoundGet::
::SoundGetWaveVolume::
::SoundPlay::
::SoundSet::
::SoundSetWaveVolume::
::SplashImage::
::SplashTextOff::
::SplashTextOn::
::SplitPath::
::StatusBarGetText::
::StatusBarWait::
::StringCaseSense::
::StringGetPos::
::StringLeft::
::StringLen::
::StringLower::
::StringMid::
::StringReplace::
::StringRight::
::StringSplit::
::StringTrimLeft::
::StringTrimRight::
::StringUpper::
::Suspend::
::SysGet::
::Thread::
::ToolTip::
::Transform::
::TrayTip::
::URLDownloadToFile::
::WinActivate::
::WinActivateBottom::
::WinClose::
::WinGet::
::WinGetActiveStats::
::WinGetActiveTitle::
::WinGetClass::
::WinGetPos::
::WinGetText::
::WinGetTitle::
::WinHide::
::WinKill::
::WinMaximize::
::WinMenuSelectItem::
::WinMinimize::
::WinMinimizeAll::
::WinMinimizeAllUndo::
::WinMove::
::WinRestore::
::WinSet::
::WinSetTitle::
::WinShow::
::WinWait::
::WinWaitActive::
::WinWaitClose::
::WinWaitNotActive::
Var := RegExReplace(A_ThisHotkey,"^::","")
Send, [url=http://www.autohotkey.com/docs/commands/%Var%.htm]%Var%[/url]%A_EndChar%
Return
*Note - See my post on the AHK Forums Here
Labels:
AHK scripts,
Hotstrings,
Utils
Sunday, August 10, 2008
AHK - ASCII to HEX converter
This is a simple function that converts ASCII into HEX For example, "Hello World!" becomes
AscToHex(str)
{
NStr =
Tmp := A_FormatInteger
SetFormat, Integer, H
Loop, Parse, str
NStr .= RegExReplace(asc(A_LoopField),"^0x")
SetFormat, Integer, %Tmp%
Return NStr
}
48656C6C6F20576F726C6421
Labels:
AHK scripts,
Functions
Wednesday, August 6, 2008
AHK - SendDelay()
This function will have a script send "key" only once every "delay" milliseconds. For example, the following script will send the "a" key once every 1.5 seconds. For a better example, see the post AHK - World of Warcraft - Shaman ES/SS spam
SendDelay(key,delay) {
Global
If (lastSent_%key% = "" || lastSent_%key% < A_TickCount - delay)
{
Send %key%
lastSent_%key% := A_TickCount
Return 1
}
Return 0
}
Loop
SendDelay("a",1500)
Labels:
AHK scripts,
Functions
AHK - MultiPress()
This is a function I wrote that allows you to press a hotkey multiple times and have different things happen for the number of presses. An example of use for this function is
MultiPress(Max=-1)
{
Presses := 1
KeyWait, %A_ThisHotkey%
Loop
{
KeyWait, %A_ThisHotkey%, D T0.25
If (ErrorLevel || (Presses >= Max && Max > 0))
Break
Presses++
KeyWait, %A_ThisHotkey%
}
Return Presses
}
a::
P := MultiPress()
MsgBox Pressed %A_ThisHotkey% %P% times!
Return
Labels:
AHK scripts,
Functions
AHK - World of Warcraft - Shaman ES/SS spam
This is a script that will make you spam Earth Shock/Stormstrike repeatedly when you press the F5 key, until the F5 key is pressed again. To use, set earth shock to hotkey 2 and stormstrike to hotkey 1.
*Note - The use of this script violates World of Warcraft's Terms of Service, and can get you banned. It is meant as an example. I do not recommend or advocate the use of this script on live servers. If you are stupid enough to use it, I take no responsibility for the consequences.
GoGoShammySpam = 1
WinWaitActive, Untitled
Time := A_TickCount
Loop {
If (GoGoShammySpam) {
If (SendDelay("1",10000)) ; Stormstrike
sleep, 1500 ; GCD
If (SendDelay("2",6000)) ; Earth Shock
sleep, 1500 ; GCD
}
}
f5::GoGoShammySpam:=!GoGoShammySpam
SendDelay(key,delay) {
Global
If (lastSent_%key% = "" || lastSent_%key% < A_TickCount - delay)
{
Send %key%
lastSent_%key% := A_TickCount
Return 1
}
Return 0
}
*Note - The use of this script violates World of Warcraft's Terms of Service, and can get you banned. It is meant as an example. I do not recommend or advocate the use of this script on live servers. If you are stupid enough to use it, I take no responsibility for the consequences.
Labels:
AHK scripts,
Examples,
World of Warcraft
Tuesday, August 5, 2008
AU3 - Dynamic Variable Example
Here's an example of how to create a dynamic variable in AU3.In this example, $Fubar is set to "Hello World!"
Here's a function that will convert all variables and macros in a string into their stored values. For example, using the variables from the first code, this will evaluate to "Hello World!" I find this useful for scripts where you need to store dynamic strings in a text file, because you can just use something like ParseMacros(FileRead("File.txt")) and you get a nice dynamic string to play with.
$Fu = "World!"
$Bar = "Fu"
$Fubar = "Hello " & Execute("$"&$Bar)
Here's a function that will convert all variables and macros in a string into their stored values.
Func ParseMacros($Str)
Global
Local $Macros = StringRegExp($Str,"([\$\@]\w+)",3)
If Not @error Then
For $i=0 to UBound($Macros) - 1 step 1
$Str = StringRegExpReplace($Str,"\"&$Macros[$i],StringReplace(Execute($Macros[$i]),"\","\\"))
Next
EndIf
Return $Str
EndFunc
ParseMacros("Hello $Fu")
Labels:
AU3 Scripts,
Examples,
Functions
AHK - Scan Code Finder
A short script that creates a listview that will record the scan codes of the keys you press. Credits to Krogdor for creating this method of finding the scan code of pressed keys.
#InstallKeybdhook
#NoTrayIcon
Gui, Add, ListView, r20 w150 h125 NoSort Readonly, SC
Gui, Show, Autosize
Loop 9
OnMessage( 255+A_Index, "ScanCode" ) ; 0x100 to 0x108
Return
ScanCode( wParam, lParam ) {
Static Prev := 0
If (Prev != SubStr((((lParam>>16) & 0xFF)+0xF000),-2)) {
LV_Insert(1,"Focus Select","SC" SubStr((((lParam>>16) & 0xFF)+0xF000),-2))
LV_Modify(2,"-Select")
}
Prev := SubStr((((lParam>>16) & 0xFF)+0xF000),-2)
}
GuiClose:
ExitApp
Labels:
AHK scripts,
Utils
AHK - Notepad Indent
This is a simple key replacement I use for notepad that replaces the TAB character with 3 spaces. Just my personal preference for indenting nested ifs, loops, etc.
#NoTrayIcon
#IfWinActive ahk_class Notepad
:*:`t::{SPACE 3}
Labels:
AHK scripts,
Hotstrings
Sunday, August 3, 2008
AHK - A simple auto-clicker
Simply auto-clicks when the left mouse button is held down. Insert toggles the auto-clicker on and off.
Insert::
Hotkey, LButton, Toggle
Hotkey, LButton Up, Toggle
Return
LButton::
Loop
{
If (Stop)
Break
Send {lbutton}
}
Stop := 0
Return
LButton Up::Stop := 1
Labels:
AHK scripts
Subscribe to:
Posts (Atom)