Last active
May 7, 2018 20:44
-
-
Save blaulan/9dd56038c509ed8e91bbd4e3e63d1fb6 to your computer and use it in GitHub Desktop.
AutoHotKey snippets
This file contains hidden or 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
#SingleInstance Ignore | |
OnExit ExitSub | |
SetWorkingDir %A_ScriptDir% | |
; ----- Send Clipboard ----- | |
!v:: | |
SendInput {Raw}%clipboard% | |
Return | |
; ----- Always On Top ----- | |
!a:: | |
WinGet, CurrentWindow, ID, A | |
WinGet, ExStyle, ExStyle, ahk_id %CurrentWindow% | |
If (ExStyle & 0x8){ | |
Winset, AlwaysOnTop, off, ahk_id %CurrentWindow% | |
SplashImage, , x0 y0 b fs12, Always On Top OFF. | |
Sleep, 1500 | |
SplashImage, Off | |
} | |
Else { | |
WinSet, AlwaysOnTop, on, ahk_id %CurrentWindow% | |
SplashImage, ,x0 y0 b fs12, Always On Top ON. | |
Sleep, 1500 | |
SplashImage, Off | |
} | |
Return | |
; ----- Transparent ----- | |
#WheelUp:: | |
WinGet, CurrentWindow, ID, A | |
If Not (%CurrentWindow%){ | |
%CurrentWindow% := 255 | |
} | |
If (%CurrentWindow% != 255){ | |
%CurrentWindow% += 5 | |
WinSet, Transparent, % %CurrentWindow%, ahk_id %CurrentWindow% | |
} | |
SplashImage,,w100 x0 y0 b fs12, % %CurrentWindow% | |
SetTimer, TurnOffSI, 1000, On | |
Return | |
#WheelDown:: | |
SplashImage, Off | |
WinGet, CurrentWindow, ID, A | |
If Not (%CurrentWindow%){ | |
%CurrentWindow% := 255 | |
} | |
If (%CurrentWindow% != 5){ | |
%CurrentWindow% -= 5 | |
WinSet, Transparent, % %CurrentWindow%, ahk_id %CurrentWindow% | |
} | |
SplashImage,, w100 x0 y0 b fs12, % %CurrentWindow% | |
SetTimer, TurnOffSI, 1000, On | |
Return | |
TurnOffSI: | |
SplashImage, off | |
SetTimer, TurnOffSI, 1000, Off | |
Return | |
; ----- Resize Window ----- | |
GetMon(WinID) { | |
WinGetPos, WinX, WinY, WinWidth, WinHeight, ahk_id %WinID% | |
WinCenterX := WinX + (WinWidth / 2) | |
WinCenterY := WinY + (WinHeight / 2) | |
SysGet, MonitorCount, MonitorCount | |
Loop, %MonitorCount% { | |
SysGet, Mon, Monitor, %A_Index% | |
If (WinCenterX > MonLeft And WinCenterX < MonRight ) { | |
Return [MonLeft+75, MonRight, MonTop, MonBottom, WinWidth, WinHeight] | |
} | |
} | |
} | |
!c:: | |
WinGet, CurrentWindow, ID, A | |
Mon := GetMon(CurrentWindow) | |
WinMove, ahk_id %CurrentWindow%, , (Mon[1]+Mon[2]-Mon[5])/2, (Mon[3]+Mon[4]-Mon[6])/2 | |
Return | |
^1:: | |
WinGet, CurrentWindow, ID, A | |
Mon := GetMon(CurrentWindow) | |
WinMove, ahk_id %CurrentWindow%, , Mon[1]+20, Mon[3], (Mon[2]-Mon[1])/2-20, (Mon[4]-Mon[3])+10 | |
Return | |
^2:: | |
WinGet, CurrentWindow, ID, A | |
Mon := GetMon(CurrentWindow) | |
WinMove, ahk_id %CurrentWindow%, , (Mon[1]+Mon[2])/2-10, Mon[3], (Mon[2]-Mon[1])/2+20, (Mon[4]-Mon[3])/2 | |
Return | |
^3:: | |
WinGet, CurrentWindow, ID, A | |
Mon := GetMon(CurrentWindow) | |
WinMove, ahk_id %CurrentWindow%, , (Mon[1]+Mon[2])/2-10, (Mon[3]+Mon[4])/2, (Mon[2]-Mon[1])/2+20, (Mon[4]-Mon[3])/2+10 | |
Return | |
; ----- On Exit ----- | |
ExitSub: | |
Process, Close, %TexterPID% | |
ExitApp |
This file contains hidden or 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
#NoTrayIcon | |
#NoEnv | |
#SingleInstance Ignore | |
SetWorkingDir, %A_ScriptDir% | |
tempFile = unzip_%A_Now%.txt | |
7z = "path\to\7z.exe" | |
7zG = "path\to\7zG.exe" | |
zipFile = %1% | |
; setup variables | |
fistDividingLine := 0 | |
fistValid := 0 | |
haveMultiFile := 0 | |
haveFolder := 0 | |
tempA := 0 | |
tempB := 0 | |
tempB1 := 0 | |
tempC := 0 | |
; read archive content tp temp file | |
SplitPath, zipFile, , filePath, , fileName | |
RunWait, %comspec% /c %7z% l "%zipFile%" `> "%tempFile%", , hide | |
; loop over temp file to get file count | |
loop, read, %tempFile% | |
{ | |
If (fistDividingLine = 0) | |
{ | |
If(RegExMatch(A_LoopReadLine, "^-------------------")) | |
{ | |
fistDividingLine = 1 | |
} | |
Continue | |
} | |
Else | |
{ | |
If(RegExMatch(A_LoopReadLine, "^-------------------")) | |
{ | |
Break | |
} | |
Else | |
{ | |
StringTrimLeft, tempA, A_LoopReadLine, 53 | |
StringSplit, tempB, tempA, `\ | |
If (fistValid = 0) | |
{ | |
fistValid = 1 | |
content = %tempB1% | |
} | |
IfnotEqual, tempB1, %content% | |
{ | |
haveMultiFile = 1 | |
Break | |
} | |
StringLeft, tempC, A_LoopReadLine, 30 | |
IfInString, tempC, D | |
{ | |
haveFolder = 1 | |
} | |
} | |
} | |
} | |
FileDelete, %tempFile% | |
; unzip files | |
If(haveMultiFile = 0 && haveFolder = 0) | |
{ | |
RunWait, %7zG% x "%zipFile%" -o"%filePath%" | |
} | |
Else If(haveMultiFile = 0 && haveFolder = 1) | |
{ | |
IfExist, %filePath%\%content% | |
{ | |
RunWait, %7zG% x "%zipFile%" -o "%filePath%\%content%_%A_now%" | |
} | |
Else | |
{ | |
RunWait, %7zG% x "%zipFile%" -o "%filePath%" | |
} | |
} | |
Else | |
{ | |
IfExist %filePath%\%fileName% | |
{ | |
RunWait, %7zG% x "%zipFile%" -o "%filePath%\%fileName%_%A_now%" | |
} | |
Else | |
{ | |
RunWait, %7zG% x "%zipFile%" -o "%filePath%\%fileName%" | |
} | |
} | |
ExitApp |
This file contains hidden or 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
#NoTrayIcon | |
#NoEnv | |
#SingleInstance Ignore | |
; setup variables | |
7z = "path\to\7z.exe" | |
7zG = "path\to\7zG.exe" | |
infile = %1% | |
StringReplace, filepath, infile, ", , All | |
SplitPath, filepath, , dirpath, , , | |
SplitPath, dirpath, dir, , , , | |
; count selected files | |
filelist := "" | |
filecount := 0 | |
Loop, %0% | |
{ | |
infile := %A_Index% | |
infile = "%infile%" | |
filelist := filelist . " " . infile | |
filecount += 1 | |
} | |
; archive file(s) | |
If filecount = 1 | |
{ | |
IfExist, %filepath%.zip | |
{ | |
Run, %7zG% u "%filepath%_%A_now%.zip" %filelist% | |
} | |
Else | |
{ | |
Run, %7zG% u "%filepath%.zip" %filelist% | |
} | |
} | |
Else | |
{ | |
IfExist, %dirpath%\%dir%.zip | |
{ | |
Run, %7zG% u "%dirpath%\%dir%_%A_now%.zip" %filelist% | |
} | |
Else | |
{ | |
Run, %7zG% u "%dirpath%\%dir%.zip" %filelist% | |
} | |
} | |
ExitApp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment