Created
April 5, 2017 09:41
-
-
Save VarunAgw/806c6d466d9aa5179722fce09d57f4d0 to your computer and use it in GitHub Desktop.
AHK Scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SetLineEnding(text, line_ending:="`n") { | |
text := StrReplace(text, "`r`n", "`n") | |
text := StrReplace(text, "`r", "`n") | |
if ("`n" != line_ending) { | |
text := StrReplace(text, "`n", line_ending) | |
} | |
return %text% | |
} | |
StrCount( ByRef Haystack , Needle = "" ) { | |
StringReplace, Haystack, Haystack, %Needle%, %Needle%, UseErrorLevel | |
Return ErrorLevel | |
} | |
PasteText(text, sleep:=200) { | |
BlockInput, Send | |
cb := ClipBoardAll | |
ClipBoard := text | |
Sleep %sleep% | |
Send ^v | |
Sleep %sleep% | |
ClipBoard := cb | |
BlockInput, Off | |
} | |
#r:: | |
if (WinExist("Run ahk_exe explorer.exe")) { | |
WinActivate Run ahk_exe explorer.exe | |
} else if (WinExist("Program Manager")) { | |
Run, "%userprofile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\System Tools\Run" | |
;shell:=ComObjCreate("Shell.Application") | |
;shell.FileRun() | |
} else if (WinExist("Run ahk_exe rundll32.exe")) { | |
WinActivate Run ahk_exe rundll32.exe | |
} else { | |
Run RunDll32.exe shell32.dll`,#61,,,PID | |
WinWaitActive Run ahk_exe rundll32.exe | |
WinMove, ahk_pid %PID%,, 10, 475 | |
} | |
Return | |
#IfWinActive Run ahk_class #32770 ahk_exe explorer.exe | |
+Delete:: | |
ControlGetText, path, Edit1, A | |
path := path . "\1" | |
Loop, Reg, HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RunMRU | |
{ | |
RegRead, RegValue | |
if (RegValue == path) { | |
RegDelete, %A_LoopRegKey%, %A_LoopRegSubKey%, %A_LoopRegName% | |
Break | |
} | |
} | |
Return | |
^d:: | |
Send {Escape} | |
Run notepad.exe | |
Return | |
^v:: | |
cb := ClipBoard | |
newCb := SetLineEnding(cb, "`n") | |
if (StrCount(newCb, "`n") > 1) { | |
Send {Escape} | |
Run notepad.exe | |
WinWaitActive ahk_exe notepad.exe | |
Send ^v | |
Return | |
} | |
newCb := SetLineEnding(cb, " ") | |
if (cb == newCb) { | |
Send ^v | |
} else { | |
PasteText(cb) | |
} | |
Return | |
!a:: | |
WinGetTitle, Title, A | |
if (!InStr(Title, "admin")) { | |
WinSetTitle, Run (as admin) | |
} else { | |
WinSetTitle, Run | |
} | |
Return | |
Enter:: | |
WinGetTitle, Title, A | |
if (!InStr(Title, "admin")) { | |
Send {Enter} | |
} else { | |
ControlGetText, path, Edit1, A | |
Send {Escape} | |
Run %path% | |
} | |
Return | |
^Enter:: | |
ControlGetText, path, Edit1, A | |
Send {Escape} | |
Run %path% | |
Return | |
#IfWinActive |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment