This script put your image file to .clip and can be accessible with Hotstring.
Press Win+Alt+C after selecting image file in file explorer, a GUI will appear, put your hotstring there (inspirations taken from Hotstring helper) and press Confirm.
This will append your hotstring to the current script.
Current extension supported:
- PNG
JPG
JPEG
JFIF
ICO
Code: Select all
#SingleInstance Force
#NoEnv
SetWorkingDir %A_ScriptDir%
SetBatchLines -1
#!c:: ; Win+Alt+C
; select file and copy automatically.
SaveClip:=Clipboard
Clipboard:=
Send, ^{c}
:*:.copy::
; you need to copy the file first to use this hotstring.
If !(FileExist("Saved Image Clip"))
{
FileCreateDir, Saved Image Clip
}
;MsgBox, %Clipboard%
;If !(InStr(Clipboard, ".png") or InStr(Clipboard, ".jpg") or InStr(Clipboard, ".jpeg") or InStr(Clipboard, ".jfif") or InStr(Clipboard, ".ico"))
SplitPath, Clipboard,,, FileExt
;MsgBox, %FileExt%
If !(InStr(FileExt, "png") or InStr(FileExt, "jpg") or InStr(FileExt, "jpeg") or InStr(Clipboard, "jfif") or InStr(Clipboard, "ico"))
{
MsgBox, The selected file doesn't contain png/jpg/jpeg/jfif/ico
Return
}
Else
if (InStr(FileExist(Clipboard), "D"))
{
Return
}
Else
Gui, Destroy
Gui, +AlwaysOnTop +OwnDialogs +ToolWindow
Gui Font, s10
Gui Add, Edit, vhsOpt x15 y32 w45 h25 -VScroll, *
Gui Add, Text, x6 y8 w105 h23 +0x200, Hotstring Options
Gui Add, Edit, gupdPreview vhsTrigger x116 y32 w176 h25 -VScroll
Gui Add, Text, x117 y8 w120 h23 +0x200, Trigger String
Gui Add, Edit, gupdPreview vhsPreview x15 y63 w277 h21 +ReadOnly
Gui Add, Button, ghsOptHint x62 y31 w37 h27, ?
Gui Add, Picture, vhsImgPreview x8 y96 w425 h-1, %Clipboard%
Gui Add, Button, ghsConfirm x295 y32 w70 h26, Confirm
Gui Add, Button, ghsHelp x295 y60 w70 h26 Disabled, Help
Gui Add, Button, ghsEdit x366 y32 w70 h26, Edit Script
Gui Add, Button, ghsClose x366 y60 w70 h26, Close
Gui Show, x50 y50, IMG2HS GUI
GoSub, updPreview
TotalFile=1
Loop, Files, %A_ScriptDir%\Saved Image Clip\*.*
{
TotalFile=% A_Index + 1
;MsgBox, %TotalFile% %A_Index%
}
Return
hsConfirm:
FileAppend,
(
; === Image File %TotalFile% ===
:%hsOpt%:%hsTrigger%::
SaveClip:=ClipboardAll
Clipboard:=
FileRead, Clipboard, *c Saved Image Clip\img_%TotalFile%.clip
ClipWait, 2
Send, ^{v}
Clipboard:=SaveClip
Return
), %A_ScriptFullPath%
FileAppend, %ClipboardAll%, Saved Image Clip\img_%TotalFile%.clip
Sleep, 100
Clipboard:=
Clipboard:=SaveClip
Reload
return
hsEdit:
Run, Notepad.exe %A_ScriptFullPath%
WinWait, %A_ScriptName%
WinActivate, %A_ScriptName%
WinWaitActive, %A_Scriptname%
Send, ^{End}
Clipboard:=
Clipboard:=SaveClip
Return
hsHelp:
Return
updPreview:
Gui, Submit, NoHide
;MsgBox, %hsOpt% %hsTrigger%
GuiControl,, hsPreview, :%hsOpt%:%hsTrigger%::
Return
hsOptHint:
MsgBox,
(
* (asterisk): An ending character (e.g. Space, ., or Enter) is not required to trigger the hotstring.
? (question mark): The hotstring will be triggered even when it is inside another word; that is,
when the character typed immediately before it is alphanumeric. Use ?0 to turn this option back off.
B0 (B followed by a zero): Automatic backspacing is not done to erase the abbreviation you type.
Use a plain B to turn backspacing back on after it was previously turned off.
C: Case sensitive: When you type an abbreviation, it must exactly match the case defined in the script.
Use C0 to turn case sensitivity back off.
C1: Do not conform to typed case. Use this option to make auto-replace hotstrings case insensitive
and prevent them from conforming to the case of the characters you actually type.
C0 can be used to turn this option back off, which makes hotstrings conform again.
Kn: Key-delay: This rarely-used option sets the delay between keystrokes produced by auto-backspacing or auto-replacement.
Specify the new delay for n; for example, specify k10 to have a 10ms delay and k-1 to have no delay.
•SI (SendInput): Key-delay is ignored because a delay is not possible in this mode.
•SP (SendPlay): A delay of length zero is the default, which for SendPlay is the same as -1 (no delay).
•SE (SendEvent): A delay of length zero is the default.
O: Omit the ending character of auto-replace hotstrings when the replacement is produced.
Use O0 (the letter O followed by a zero) to turn this option back off.
Pn: The priority of the hotstring (e.g. P1). This rarely-used option has no effect on auto-replace hotstrings.
R: Send the replacement text raw; that is, without translating {Enter} to Enter, ^c to Ctrl+C, etc.
Use R0 to turn this option back off.
T [v1.1.27+]: Send the replacement text raw, without translating each character to a keystroke.
Use T0 or R0 to turn this option back off, or override it with R.
X [v1.1.28+]: Execute. Instead of replacement text, the hotstring accepts a command or expression to execute.
Z: This rarely-used option resets the hotstring recognizer after each triggering of the hotstring.
)
Return
hsClose:
GuiClose:
Gui Destroy
Clipboard:=
Clipboard:=SaveClip
Return
; === ALL THE HOTSTRING ===
GUI Appearance
Edit : Fixed wrong var in FileAppend