Save the file in Unicode or UTF-8 with signature (not in UTF-8 as it is chosen with the download feature here - it messes up unicode characters).
First. Quick Notes from the old forum.
Code: Select all
; Quick Notes by Drozdman
; save file in Unicode
/*
• Script for AutoHotkey_L. Save file in Unicode.
• Eight notes/tabs with customizable names stored in separate files with backup.
• Borderless movable window.
• Always on top button.
• F1 - previous tab, F2 - next tab
• Switch small/bigger window.
• Letter and word count on any key press or button press (plus reverse text).
• No taskbar button. Press F4 or click on the script's tray icon to bring window to the front.
• save on exit
• 'Find in text' with RegEx switch on/off
• Help - help button
*/
SetBatchLines, -1
SetWinDelay, -1
SetControlDelay, -1
Width_B:=765 , Height_B:=592
#SingleInstance force
Menu, Tray, Icon, shell32.dll,71
;Menu, Tray, Icon, C:\Program Files\Misc\AutoHotkey Scripts\icons\Documents-icon.ico
Menu, Tray, Add, Settings, GoSettings
Menu, Tray, Add, Show Notes, Show_Notes ; double click tray icon to show
Menu, Tray, Default, Show Notes
Menu, Tray, Default, Settings
Menu, ContextMenu, Add, Settings, GoSettings
Menu, ContextMenu, Add, Open folder, Open_folder
Menu, ContextMenu, Add, Exit, Close
Menu, Tray, NoStandard
Menu, Tray, Add , E&xit, Close
;=======================================
FileEncoding, UTF-8
;ico:=InStr(A_OSVersion,"WIN_VISTA") ? 25: 18
FileGetVersion, ver, wmploc.DLL ;C:\WINDOWS\System32\wmploc.DLL
RegExMatch(ver,"(\d+)\.\d+\.(\d+)", out) ;new 12.0.10240.16384
new_wmploc:=(out1>=10 && out2>=8000)
sett_ico:=new_wmploc ? 18 : 25
onTop_ico:=new_wmploc ? 13 : 17
;A_WorkingDir
WorkingDir :=A_ScriptDir
folder_path := WorkingDir . "\notes_files\"
If !FileExist(WorkingDir "\notes_files")
FileCreateDir , % WorkingDir "\notes_files"
global settings_ini := folder_path . "Quick_Notes_settings.ini"
global Find_from_sel
IfNotExist, %settings_ini%
{
IniWrite, %folder_path% , %settings_ini%, WorkingDir, Folder
Loop, 8 {
if (A_Index < 2 ){
IniWrite, Note%A_Index%, %settings_ini%, Note%A_Index%, Name
IniWrite, Segoe UI, %settings_ini%, Note%A_Index%, Font
IniWrite, 10, %settings_ini%, Note%A_Index%, Size
IniWrite, Default, %settings_ini%, Note%A_Index%, Color
IniWrite, Segoe UI, %settings_ini%, Note%A_Index%, Font_Big
IniWrite, 11, %settings_ini%, Note%A_Index%, Size_Big
}else if (A_Index = 2 ) {
IniWrite, Note%A_Index%, %settings_ini%, Note%A_Index%, Name
IniWrite, Segoe UI Semibold, %settings_ini%, Note%A_Index%, Font
IniWrite, 9, %settings_ini%, Note%A_Index%, Size
IniWrite, 900000, %settings_ini%, Note%A_Index%, Color
IniWrite, Segoe UI Semibold, %settings_ini%, Note%A_Index%, Font_Big
IniWrite, 10, %settings_ini%, Note%A_Index%, Size_Big
}else if (A_Index = 3 ) {
IniWrite, Note%A_Index%, %settings_ini%, Note%A_Index%, Name
IniWrite, Lucida Console , %settings_ini%, Note%A_Index%, Font
IniWrite, 9, %settings_ini%, Note%A_Index%, Size
IniWrite, 009000, %settings_ini%, Note%A_Index%, Color
IniWrite, Lucida Console , %settings_ini%, Note%A_Index%, Font_Big
IniWrite, 10, %settings_ini%, Note%A_Index%, Size_Big
}else if (A_Index = 4 ) {
IniWrite, Note%A_Index%, %settings_ini%, Note%A_Index%, Name
IniWrite, Tahoma , %settings_ini%, Note%A_Index%, Font
IniWrite, 10, %settings_ini%, Note%A_Index%, Size
IniWrite, 000090, %settings_ini%, Note%A_Index%, Color
IniWrite, Tahoma , %settings_ini%, Note%A_Index%, Font_Big
IniWrite, 11, %settings_ini%, Note%A_Index%, Size_Big
}else if (A_Index <= 6 ) {
IniWrite, Note%A_Index%, %settings_ini%, Note%A_Index%, Name
IniWrite, Times New Roman, %settings_ini%, Note%A_Index%, Font
IniWrite, 10, %settings_ini%, Note%A_Index%, Size
IniWrite, Default, %settings_ini%, Note%A_Index%, Color
IniWrite, Times New Roman, %settings_ini%, Note%A_Index%, Font_Big
IniWrite, 11, %settings_ini%, Note%A_Index%, Size_Big
}else if (A_Index = 7 ) {
IniWrite, Note%A_Index%, %settings_ini%, Note%A_Index%, Name
IniWrite, Segoe UI Semibold, %settings_ini%, Note%A_Index%, Font
IniWrite, 9, %settings_ini%, Note%A_Index%, Size
IniWrite, Default, %settings_ini%, Note%A_Index%, Color
IniWrite, Segoe UI Semibold, %settings_ini%, Note%A_Index%, Font_Big
IniWrite, 10, %settings_ini%, Note%A_Index%, Size_Big
}else{
IniWrite, Note%A_Index%, %settings_ini%, Note%A_Index%, Name
IniWrite, Segoe Print, %settings_ini%, Note%A_Index%, Font
IniWrite, 9, %settings_ini%, Note%A_Index%, Size
IniWrite, Default, %settings_ini%, Note%A_Index%, Color
IniWrite, Segoe Print, %settings_ini%, Note%A_Index%, Font_Big
IniWrite, 10, %settings_ini%, Note%A_Index%, Size_Big
}
}
IniWrite, 0, %settings_ini%, Misc, Search Option
}
Sleep 60
load_vars(){
global
Loop, 8 {
IniRead, n%A_Index%, %settings_ini%, Note%A_Index%, Name
IniRead, font_%A_Index%, %settings_ini%, Note%A_Index%, Font
IniRead, f_size_%A_Index%, %settings_ini%, Note%A_Index%, Size
IniRead, font_B_%A_Index%, %settings_ini%, Note%A_Index%, Font_Big
IniRead, f_size_B_%A_Index%, %settings_ini%, Note%A_Index%, Size_Big
IniRead, font_color_%A_Index%, %settings_ini%, Note%A_Index%, Color
}
IniRead, Find_from_sel, %settings_ini%, Misc, Search Option
}
load_vars()
;=======================================
Gui,1: +ToolWindow
Gui,1: -border +Resize +Minsize400x330
Gui,1: +hwndthis_id1
Gui,1:Color, 0B4761 ; DCE8ED ; 78BBE5 ; dark 8BAFBE 6B8590
Gui,1:Font, S10 CDefault , Segoe UI
Gui,1: Add, Picture, x10 y4 w16 h16 gLoad Icon71 AltSubmit, shell32.dll ;
Gui,1: Add, Picture, x35 y4 w16 h16 gSave Icon259 AltSubmit, shell32.dll ;
Gui,1: Add, Picture, x62 y4 w16 h16 vRec Icon28 AltSubmit, shell32.dll ; Icon145 Icon28
Gui,1: Add, Picture, x60 y4 w16 h16 vGet Icon147 AltSubmit, shell32.dll ; Icon44
Gui,1: Add, Picture, x210 y4 w16 h16 vonTop1 gonTop Icon%onTop_ico% AltSubmit, wmploc.dll
;Gui,1: Add, Picture, x240 y4 w16 h16 vonTop1 gonTop Icon248 AltSubmit, shell32.dll ;
Gui,1: Add, Picture, x210 y4 w16 h16 vonTop2 gonTop Icon247 AltSubmit, shell32.dll ;
Gui,1: Add, Picture, x286 y4 w16 h16 gBig Icon269 AltSubmit, shell32.dll ;
Gui,1: Add, Picture, x313 y3 w16 h16 vBac gBackup Icon32 AltSubmit, shell32.dll ; Icon41
;Gui,1: Add, Picture, x335 y4 w16 h16 gGoSettings Icon25 AltSubmit, wmploc.dll ; ,imageres.dll, 64 109
;Gui,1: Add, Picture, x335 y4 w16 h16 gGoSettings Icon18 AltSubmit, wmploc.dll ; Win8
Gui,1: Add, Picture, x335 y4 w16 h16 gGoSettings Icon%sett_ico% AltSubmit, wmploc.dll
Gui,1: Add, Picture, x355 y4 w16 h16 gHelp_popup Icon24 AltSubmit, shell32.dll ;
Gui,1: Add, Picture, x381 y4 w16 h16 gClose Icon132 AltSubmit, shell32.dll ;
Gui,1:Font, S8 W700 , Verdana ; Arial
Gui,1: Add, Text, x90 y4 w40 cCE2640 vRESULT gNumber_of_letters , % Chr(9632) ;■ ; x120 y4
Gui,1:Font, S8 W400 , Verdana
Gui,1: Add, Text, x150 y4 w36 c5C7DE2 vRESULT2 gNumber_of_words , % Chr(9632) ;■ ; x185 y4
;Gui,1: Add, Picture, x410 y4 w16 h16 gOpen_folder Icon206 AltSubmit, shell32.dll ; x335 y4 ; Icon4
;Gui,1: Add, Text, x520 y4 cC8C8C8 gReverse , ツ ;x220 y4
;Gui,1: Add, Text, x335 y4 cC8C8C8 gReverse , ツ ;x220 y4
GuiControl, Hide, Rec
GuiControl, Hide, Get
GuiControl, Hide, onTop1
;============= Tabs =======================
/*
; change tabs names
n1:="Note1" ,n2:="Note2" ,n3:="Note3", n4:="Note4" , n5:="Note5", n6:="Note6", n7:="Note7", n8:="Note8"
*/
;n1:="Note Note Note1" ,n2:="Note Note Note2" ,n3:="Note Note Note3", n4:="Note Note Note4" , n5:="Note Note Note5", n6:="Note Note Note6", n7:="Note Note Note7", n8:="Note Note Note8"
;GuiSize:
Gui,1:Font, S8 , Segoe UI Bold
/* ; new Tab3
;Gui,1: Add, Tab3, x0 y25 -Wrap -Background vTabName gChange , %n1%|%n2%|%n3%|%n4%|%n5%|%n6%|%n7%|%n8%
Gui,1: Add, Tab3, x0 y25 -Background vTabName gChange , %n1%|%n2%|%n3%|%n4%|%n5%|%n6%|%n7%|%n8%
w:=Width_B ,h:=Height_B
loop 8 {
Gui,1: Tab, %A_Index%
f_size:=f_size_%A_Index%, font_color:=font_color_%A_Index% , font_:=font_%A_Index%
Gui,1: Font , S%f_size% c%font_color% , %font_%
Gui,1: Add, Edit, x0 y+0 w%w% h%h% 0x100 vNOTE%A_Index% , %text% ; 0x100 for ES_NOHIDESEL style ; set selection without focus
}
*/
; old Tab2
Gui,1: Add, Tab2, x0 y25 w403 -wrap +Theme -Background vTabName gChange , %n1%|%n2%|%n3%|%n4%|%n5%|%n6%|%n7%|%n8%
loop 8 {
Gui,1: Tab, %A_Index%
f_size:=f_size_%A_Index%, font_color:=font_color_%A_Index% , font_:=font_%A_Index%
Gui,1: Font , S%f_size% c%font_color% , %font_%
Gui,1: Add, Edit, x0 y45 w400 h290 0x100 vNOTE%A_Index% , %text% ; 0x100 for ES_NOHIDESEL style ; set selection without focus
}
;=======================================
ShowBig:=0
Gui 1:Show, w400 h330 , Quick Notes - Drozd
/* ShowBig:=1
Gui 1:Show, w%Width_B% h%Height_B% , Quick Notes - Drozd
*/
Gosub, Load_All
Gosub,Big
ShowBig:=1
OnMessage(0x404, "AHK_NOTIFYICON")
OnMessage(0x100, "WM_KEYDOWN")
OnMessage(0x0101, "WM_KEYUP") ; WM_KEYUP
OnMessage(0x201, "WM_LBUTTONDOWN")
OnMessage(0x03, "WM_MOVE")
Gosub, Find_toolbar
return
;=======================================
GuiContextMenu:
Menu, ContextMenu, Show, %A_GuiX%, %A_GuiY%
Return
Help_popup:
Gui,2: +ToolWindow
; Gui,2:Color,AAB9C3
Gui,2: +hwndthis_id2
Gui,2: Margin, 10, 10
Gui,2:Font, S7 w700 CDefault , Segoe UI
Gui,2:-border
h_pos:=help_pos()
x1:= h_pos[1]
y1:= h_pos[2]
Gui,2:Show, x%x1% y%y1% h285 w170 , Help_popup - Drozd
Gui,2: Add, Picture, x10 y6 w16 h16 BackgroundTrans Icon71 AltSubmit, shell32.dll ;
Gui,2: Add, Text, x50 y7 BackgroundTrans , Load note from file
Gui,2: Add, Picture, x10 y31 w16 h16 BackgroundTrans Icon259 AltSubmit, shell32.dll ;
Gui,2: Add, Text, x50 y33 BackgroundTrans , Save note to file
Gui,2: Add, Picture, x10 y56 w16 h16 BackgroundTrans Icon269 AltSubmit, shell32.dll
Gui,2: Add, Text, x50 y58 BackgroundTrans , Window size
;Gui,2: Add, Picture, x10 y81 w16 h16 Icon206 AltSubmit, shell32.dll ; Icon4
;Gui,2: Add, Text, x50 y81 BackgroundTrans , Open folder with files
Gui,2: Add, Picture, x10 y81 w16 h16 Icon%sett_ico% AltSubmit, wmploc.dll
Gui,2: Add, Text, x50 y81 BackgroundTrans , Settings
Gui,2: Add, Picture, x10 y104 w16 h16 Icon32 AltSubmit, shell32.dll ; Icon41
Gui,2: Add, Text, x50 y104 BackgroundTrans , Load from backup file
Gui,2: Add, Picture, x10 y128 w16 h16 Icon247 AltSubmit, shell32.dll
Gui,2: Add, Text, x50 y128 BackgroundTrans , AlwaysOnTop toggle
Gui,2: Add, Text, x0 y152 w170 0x10 ; separator
Gui,2:Font, w400
Gui,2: Add, Text, x10 y160 BackgroundTrans , ` - Click on tray icon or press F4 `n to bring window to the front
Gui,2: Add, Text, x10 y188 BackgroundTrans , ` - Number of characters shown in red, `n number of words shown in blue
;Gui,2: Add, Text, x10 y216 BackgroundTrans , ` - Choose custom names for tabs `n inside the script
Gui,2: Add, Text, x10 y216 BackgroundTrans , ` - Find in text Ctrl+F , find next F3 `n
Gui,2: Add, Text, x10 y230 BackgroundTrans , ` - F1: previous tab, F2: next tab `n
Gui,2: Add, Text, x10 y245 BackgroundTrans , ` - Click + mouse wheel = Page up/down `n
Gui,2: Add, Text, x10 y260 gRev_but , ` - Reverse: Shift+Ctrl+Alt+R
;Gui,2: Add, Text, x10 y244 ,
return
; =====================================================
;DisableWindowsFeature
OnStaticDoubleClick(W, L, M, H) { ; prevent copy to clipboard when double clicked ; by just me autohotkey.com/boards/viewtopic.php?t=3569
Static Dummy1 := OnMessage(0x00A2, "OnStaticDoubleClick") ; WM_NCLBUTTONUP
Static Dummy2 := OnMessage(0x00A3, "OnStaticDoubleClick") ; WM_NCLBUTTONDBLCLK
Static Dummy3 := OnMessage(0x0202, "OnStaticDoubleClick") ; WM_LBUTTONUP
Static Dummy4 := OnMessage(0x0203, "OnStaticDoubleClick") ; WM_LBUTTONDBLCLK
Static LBtnDblClicks := {0x00A3: 0x00A1, 0x0203: 0x0201}
Global StaticDoubleClick := False
;ToolTip_("--- " A_GuiControl "`n" A_GuiEvent,3,1)
If (A_GuiControl) && LBtnDblClicks.Haskey(M) {
GuiControlGet, HCTRL, Hwnd, %A_GuiControl%
WinGetClass, Class, ahk_id %HCTRL%
If (Class = "Static") {
StaticDoubleClick := True
PostMessage, % LBtnDblClicks[M], %W%, %L%, , ahk_id %HCTRL%
Return 0
}
}
}
;==========================
AHK_NOTIFYICON(wParam, lParam){
if (lParam = 0x202) { ; WM_LBUTTONUP
Gui, 1:Show
}else if (lParam = 0x203){ ; WM_LBUTTONDBLCLK
Gui, 1: Show
}
}
WM_KEYUP(){
global Curr_Index, TabName
/* Loop 8 {
if (TabName=n%A_Index%) {
Curr_Index=%A_Index%
}
}
*/
Gosub, Number_of_letters
Gosub, Number_of_words
}
WM_LBUTTONDOWN(){
global
if(A_Gui=1){
PostMessage, 0xA1, 2 ; movable borderless window
}
}
get_caret_pos:
Loop 9 {
if(TabName=n%A_Index%)
Curr_Index=%A_Index%
}
;get caret position , next find position on click
VarSetCapacity(Pos1, 4, 0)
VarSetCapacity(Pos2, 4, 0)
SendMessage, 0x00B0, &Pos1, &Pos2,Edit%Curr_Index%, Quick Notes - Drozd ; EM_GETSEL=0x00B0
Pos1 := NumGet(Pos1)
Pos2 := NumGet(Pos2)
caret_pos:=Pos1
caret_pos2:=Pos2
pos:=Pos2
return
; =====================================================
help_pos(){
WinGetPos, x, y, Width, Height, Quick Notes - Drozd
x1 := x + Width
y1 := y ; Abs()
; return, object( 1, x, 2, y, 3, Width, 4,Height )
return, object( 1, x1, 2, y1)
}
toolbar_pos(){
WinGetPos, x, y, Width, Height, Quick Notes - Drozd
f_x1 := x+5
f_y1 := y + Height -40
f_w := (Width-16)
;f_y1 := y + 50 ;top
return, object( 1, f_x1, 2, f_y1, 3 ,f_w )
}
WM_MOVE(){
WinGetPos, x1,y1,w1,h1, Quick Notes - Drozd
;WinGetPos, x2,y2,w2,h2, Find toolbar - Drozd
If (A_Gui=1) {
x := x1+5
y := y1 + h1 -40
w := (w1-10)
; y := y1 + 50 ; top
WinMove, Find toolbar - Drozd ,, x, y, w
WinMove, Help_popup - Drozd ,,% x1+ w1, y1,
}
}
WM_KEYDOWN(wParam, lParam){
if (A_Gui = 3 && wParam = 13){ ; VK_ENTER := 13
Gosub, Find
}else if (A_Gui=3 && wParam != 13 && wParam != 114) {
SendMessage, 0x00B1, %pos1%, %pos1%, Edit%Curr_Index% , Quick Notes - Drozd ; remove selection
}
}
Change:
Gui, Submit, NoHide
Loop 8 {
if (TabName=n%A_Index%) {
Curr_Index=%A_Index%
}
}
Gosub, Number_of_letters
Gosub, Number_of_words
return
Find_toolbar:
Gui,3:+owner1
Gui,3: +ToolWindow -border
Gui,2: +hwndthis_id3
InvertedColor = EDF0FF
Gui,3:+Delimiter`n
Gui,3:Color, 120F00
Gui,3:Font, S8 W600 , Verdana ; Tahoma
;Gui,3: Add, Edit, x70 y4 w140 h20 vQuery_1 , ;Search
Gui,3: Add, ComboBox, x70 y4 w140 0x100 vQuery_1 , ; Search
Gui,3: Font, S7 W700 , Tahoma ; Tahoma Verdana
Gui,3: Add, Text , x224 y9 cFFFFFF gFind , Find ;w40 h24
; Gui,3: Font, S12 W700 , Verdana
Gui,3: Add, Text, x290 y9 cFFFFFF gFind_Next , Next
;Gui,3: Add, Text, x286 y9 cFFFFFF gFind_Next , Next ;w40 h24
Gui,3:Font, S11
Gui,3: Add, Text, x340 y4 w60 h40 cFFFFFF gFind_Close , X
Gui,3: Font, S7 W700 , Segoe UI ;Tahoma
Gui,3: Add, Text, x258 y8 cFFFFFF gFind_Prev , Prev
Gui,3:Font, S7 W700 Q5
Gui,3: Add, Text , x0 y7 w70 cFFFFFF vFindFromPos Center,
Gui,3: Font, S1
;Gui,3: Add, GroupBox, x216 y4 w40 h20
;Gui,3: Add, GroupBox, x268 y4 w40 h20
Gui,3: Font, S8
Gui,3: Add, Checkbox, x340 y8 w13 h13 vFind_Regex
Gui,3: Font, S7
Gui,3: Add, Text, x+8 cCCCCCC vtextFind_Regex gFind_RegexSwitch , RegEx
t_pos:=toolbar_pos()
; f_x1:= toolbar_pos()[1]
f_y1 := toolbar_pos()[2]
f_w := toolbar_pos()[3]
;Gui,3:Show, y%f_y1% w494 h30 , Find toolbar - Drozd
;Gui,3:Show, y%f_y1% w%f_w% h30 , Find toolbar - Drozd
; WinSet, Transparent, 200, Find toolbar - Drozd
Gui,3: Hide
return
Find_RegexSwitch:
GuiControlGet, Find_Regex , 3: , Find_Regex
GuiControl,3: ,Find_Regex , % !Find_Regex
return
Find_toolbar_show:
t_pos:=toolbar_pos()
f_x1:= toolbar_pos()[1]
f_y1:= toolbar_pos()[2]
f_w:= toolbar_pos()[3]
Gui,3:Show, x%f_x1% y%f_y1% w%f_w% h30 , Find toolbar - Drozd ;w494 h30
WinSet, Transparent, 200, Find toolbar - Drozd
return
;====================
add_to_ComboBox_find(box,new_val,max,add_to_list:=false){
ControlGet,list_, List, ,%box%, Find toolbar - Drozd
list_array:=StrSplit(list_,"`n")
if(list_array.Length()>max){
Control, Delete, % list_array.Length(), %box% , Find toolbar - Drozd
}
if(!array_contains(list_array, new_val)){
;ControlGet, list_,3:List, ,%box%, Find toolbar - Drozd
new_box:= "`n" new_val "`n" list_
GuiControl,3:, %box%, %new_box%
GuiControl,3:ChooseString, %box%, %new_val% ; select
}else{
GuiControl,3:ChooseString, %box%, %new_val% ; select
}
}
array_contains(haystack, needle){
if(!isObject(haystack))
return false
if(haystack.Length()==0)
return false
for k,v in haystack
{
v:=Trim(v), needle:=Trim(needle)
if(v==needle)
return k
}
return false
}
;====================
~^f::
IfWinNotActive, Quick Notes - Drozd
return
;Gosub, Find
;Gosub,Find_toolbar_show
Gui, Submit, NoHide
Loop 9 {
if (TabName=n%A_Index%) {
global Curr_Index
Curr_Index=%A_Index%
}
}
ControlGet, Sel,Selected,, Edit%Curr_Index%, Quick Notes - Drozd ; get selected text for search
Sel:=Trim(Sel)
Sel:=RegExReplace(Sel, ",|;|:|-|\.", "")
Query := (Sel && Find_from_sel=1) ? Sel : Query_1
if(Sel && Find_from_sel=1){
add_to_ComboBox_find("ComboBox1",Query, 8, true)
;GuiControlGet, Edit1_, , Edit1
SendMessage, 0x00B1, 0, StrLen(Query) , Edit1 , Find toolbar - Drozd ; EM_SETSEL ;select query
}
Gosub,Find_toolbar_show
return
Find:
Gosub,Find_toolbar_show
Gui,3: Submit, Nohide
GuiControlGet, Query ,3: , Query_1
add_to_ComboBox_find("ComboBox1",Query, 8, true)
Query_ := (Find_Regex=1) ? Query : "\Q" RegExReplace(Query,"i)\\Q|\\E","") "\E"
Note_searched := RegExReplace(Note%Curr_Index%, "`n", "`r`n") ; necessary fix - `r automatically changed to `r`n
;Query := RegExReplace(Query, "^\s*([\s\S]*?)\s*$", "$1")
pos1:=RegExMatch(Note_searched,"im)" Query_, Output)-1
pos2:=pos1 + StrLen(Query)
pos:= pos2
if(pos1<0){
;MsgBox,4096,, % "Nope", 1
GuiControl,3:, FindFromPos, % Chr(10006) ; ✖
Gui,3:Font, s8 w700 cDD0000
GuiControl,3:Font, FindFromPos
GuiControl,3: Show , FindFromPos
SetTimer, hide_FindFromPos, 1000
return
}
SendMessage, 0x00B1, %pos1%, %pos2%, Edit%Curr_Index% , Quick Notes - Drozd ; EM_SETSEL
SendMessage,0x00B7, 0, 0, Edit%Curr_Index% , Quick Notes - Drozd ; EM_SCROLLCARET Scroll caret into view
ControlGet, ControlHWND, Hwnd,, Edit%Curr_Index%, Quick Notes - Drozd
ScrollPos:=DllCall("GetScrollPos", "UInt", ControlHWND, "Int", 1)
ControlGet, Curr_Line, CurrentLine,,Edit%Curr_Index%, Quick Notes - Drozd
x:= Curr_Line - ScrollPos -8
SendMessage, 0x00B6, 0, %x% , Edit%Curr_Index% , Quick Notes - Drozd ; EM_LINESCROLL
return
~$F3::
If WinActive("Quick Notes - Drozd") || WinActive("Find toolbar - Drozd")
Gosub, Find_Next
return
Find_Next:
Gui,3: Submit, Nohide
GuiControlGet, Query ,3: , Query_1
Query_ := (Find_Regex=1) ? Query : "\Q" RegExReplace(Query,"i)\\Q|\\E","") "\E"
Gosub, get_caret_pos
add_to_ComboBox_find("ComboBox1",Query, 8, true)
Note_searched := RegExReplace(Note%Curr_Index%, "`n", "`r`n") ; necessary fix - `r automatically changed to `r`n
Array:=Object()
pos_ := 1
While pos_ {
pos_:=RegExMatch(Note_searched, "im)" Query_, Output, pos_)
if(pos_!=0){
Array.Push(pos_)
}
pos_:=pos_+StrLen(Output)
}
len:=Array.Length()
Loop % Array.Length()
{
if(caret_pos2>Array[len]){
from:=1
ind:=1
break
}else if(Array[A_Index] <= caret_pos2){
continue
}else if(Array[A_Index] > caret_pos2){
ind:=A_Index
ind:= (ind>len) ? 1 : ind
from:=Array[ind]
break
}
}
show_num_finds(len,ind)
pos1:=RegExMatch(Note_searched,"im)" Query_, Output, from ) -1
pos2:=pos1 + StrLen(Output)
pos:= pos2
caret_pos2:=pos2
if(pos1<0){
GuiControl,3:, FindFromPos, % Chr(10006) ; ✖
Gui,3:Font, s8 w700 cDD0000
GuiControl,3:Font, FindFromPos
GuiControl,3: Show , FindFromPos
SetTimer, hide_FindFromPos, 1000
return
}
SendMessage, 0x00B1, %pos1%, %pos2%, Edit%Curr_Index% , Quick Notes - Drozd ; EM_SETSEL
SendMessage,0x00B7, 0, 0, Edit%Curr_Index% , Quick Notes - Drozd ; EM_SCROLLCARET Scroll caret into view
ControlGet, ControlHWND, Hwnd,, Edit%Curr_Index%, Quick Notes - Drozd
ScrollPos:=DllCall("GetScrollPos", "UInt", ControlHWND, "Int", 1)
ControlGet, Curr_Line, CurrentLine,,Edit%Curr_Index%, Quick Notes - Drozd
x:= Curr_Line - ScrollPos -8
SendMessage, 0x00B6, 0, %x% , Edit%Curr_Index% , Quick Notes - Drozd ; EM_LINESCROLL
return
Find_Prev:
Gui,3: Submit, Nohide
GuiControlGet, Query ,3: , Query_1
Query_ := (Find_Regex=1) ? Query : "\Q" RegExReplace(Query,"i)\\Q|\\E","") "\E"
add_to_ComboBox_find("ComboBox1",Query, 8, true)
; ControlSend, Edit1, ^a , Find toolbar - Drozd ; select query
Gosub, get_caret_pos
Note_searched := RegExReplace(Note%Curr_Index%, "`n", "`r`n") ; necessary fix - `r automatically changed to `r`n
Array:=Object()
pos_ := 1
While pos_ {
pos_:=RegExMatch(Note_searched, "im)" Query_, Output, pos_)
if(pos_!=0){
Array.Push(pos_)
}
pos_:=pos_+StrLen(Output)
}
len:=Array.Length()
;show_num_finds(len)
from:=len
Loop % Array.Length()
{
if(caret_pos<=Array[1] || caret_pos>Array[len]){
from:=Array[len]
ind:= len
}else if(Array[A_Index] < caret_pos){
continue
}else if(Array[A_Index] >= caret_pos){
from:=Array[A_Index-1]
ind:=A_Index-1
break
}
}
show_num_finds(len,ind)
pos1:=RegExMatch(Note_searched,"im)" Query_, Output, from )-1
pos2:=pos1 + StrLen(Output)
pos:= pos2
caret_pos:=pos1
if(pos1<0){
GuiControl,3:, FindFromPos, % Chr(10006) ; ✖
Gui,3:Font, s8 w700 cDD0000
GuiControl,3:Font, FindFromPos
GuiControl,3: Show , FindFromPos
SetTimer, hide_FindFromPos, 1000
return
}
SendMessage, 0x00B1, %pos1%, %pos2%, Edit%Curr_Index% , Quick Notes - Drozd ; EM_SETSEL
SendMessage, 0x00B7, 0, 0, Edit%Curr_Index% , Quick Notes - Drozd ; EM_SCROLLCARET Scroll caret into view
ControlGet, ControlHWND, Hwnd,, Edit%Curr_Index%, Quick Notes - Drozd
ScrollPos:=DllCall("GetScrollPos", "UInt", ControlHWND, "Int", 1)
ControlGet, Curr_Line, CurrentLine,,Edit%Curr_Index%, Quick Notes - Drozd
x:= Curr_Line - ScrollPos -8
SendMessage, 0x00B6, 0, %x% , Edit%Curr_Index% , Quick Notes - Drozd ; EM_LINESCROLL
return
show_num_finds(num,ind:=""){
x:= num " [" ind "]"
GuiControl,3:, FindFromPos, %x%
GuiControl,3: Show , FindFromPos
SetTimer, hide_FindFromPos, 4000
}
hide_FindFromPos:
SetTimer, hide_FindFromPos, Off
GuiControl,3: Hide , FindFromPos
GuiControl,3:, FindFromPos, From pos
Gui,3:Font, S7 W700 cFFFFFF
GuiControl,3:Font, FindFromPos
return
Find_Close:
Gui,3: Hide
return
Show_Notes:
Gui, 1:Show
return
~LButton::
MouseGetPos,,, Win_id,control
if(Win_id != this_id2){
Gui, 2: Destroy
}
return
Save:
Gui, Submit, NoHide
Loop 8 {
if (TabName=n%A_Index%) {
FileDelete, %folder_path%note%A_Index%_backup.txt
FileCopy, %folder_path%note%A_Index%.txt, %folder_path%note%A_Index%_backup.txt
FileDelete, %folder_path%note%A_Index%.txt
GuiControlGet,NOTE_actv, ,Note%A_Index%
FileAppend, %NOTE_actv% , %folder_path%note%A_Index%.txt
ControlGet, controlHWND, Hwnd,, Edit%A_Index% , ahk_id %this_id1%
SendMessage, 0xB9, 0, 0, , % "ahk_id " controlHWND ; EM_SETMODIFY = 0xB9 ;clear 'modified'
Break
}
}
Gosub, Rec
Return
Load:
Gui, Submit, NoHide
Loop 8 {
if (TabName=n%A_Index%) {
FileRead, from_file, %folder_path%note%A_Index%.txt
GuiControl,, Note%A_Index% , %from_file%
;SendMessage, 0x115, 7, 0, Edit%A_Index%, Quick Notes - Drozd ; scroll to bottom
;SendMessage, 0x00B1, -1, -1 , Edit%A_Index% , Quick Notes - Drozd ; EM_SETSEL
;SendMessage,0x00B7, 0, 0, Edit%A_Index% , Quick Notes - Drozd ; EM_SCROLLCARET Scroll caret into view
;ControlSend, Edit%A_Index%, ^{End} , Quick Notes - Drozd
Break
}
}
Gosub, Get
Gosub,Number_of_letters
Gosub, Number_of_words
return
Load_All:
Gui, Submit, NoHide
Loop 8 {
FileRead, from_file, %folder_path%note%A_Index%.txt
GuiControl,, Note%A_Index% , %from_file%
}
Loop 8 {
;if (A_Index != 5){
;SendMessage, 0x115, 7, 0, Edit%A_Index%, Quick Notes - Drozd ; scroll to bottom
;SendMessage,0x00B7, 0, 0, Edit%A_Index% , Quick Notes - Drozd ; EM_SCROLLCARET Scroll caret into view
;ControlSend, Edit%A_Index%, ^{End} , Quick Notes - Drozd
;}
}
return
Backup:
Gui, Submit, NoHide
Loop 8 {
if (TabName=n%A_Index%) {
FileRead, from_file, %folder_path%note%A_Index%_backup.txt
GuiControl,, Note%A_Index% , %from_file%
Break
}
}
Gosub, Get
Gosub,Number_of_letters
Return
Save_All_and_Exit:
Gui, Submit, NoHide
Loop 8 {
ControlGet, controlHWND, Hwnd,, Edit%A_Index% , ahk_id %this_id1%
SendMessage, 0xB8, 0, 0, , % "ahk_id " controlHWND ; EM_GETMODIFY = 0xB8
if(ErrorLevel==1){
FileDelete, %folder_path%note%A_Index%_backup.txt
FileCopy, %folder_path%note%A_Index%.txt, %folder_path%note%A_Index%_backup.txt
FileDelete, %folder_path%note%A_Index%.txt
GuiControlGet,NOTE_actv, ,Note%A_Index%
FileAppend, %NOTE_actv% , %folder_path%note%A_Index%.txt
}
}
ExitApp
return
Rec:
GuiControl, Show, Rec
SetTimer, Hide_rec_get, 900
Return
Get:
GuiControl, Show, Get
SetTimer, Hide_rec_get, 900
Return
Hide_rec_get:
GuiControl, Hide, Rec
GuiControl, Hide, Get
SetTimer, Hide_rec_get, off
Return
Open_folder:
run %A_WorkingDir%
Return
; =====================================================
Big:
if(ShowBig=0){
ShowBig:=1
/* ControlMove, Static11, 735,12
ControlMove, Static10, 705,12
ControlMove, Static9, 680,13
ControlMove, Static8, 650,12
ControlMove, Static7, 600,14
ControlMove, Static6, 450,14
ControlMove, Static5, 450,14
*/
; WinMove, Quick Notes - Drozd, , 400,180 , 765, 592
;CenterWindowSize("Quick Notes - Drozd",765, 592 )
;Width_B:=765 , Height_B:=592
CenterWindowSize("Quick Notes - Drozd",Width_B, Height_B )
Loop 8 {
NOTE_actv := "NOTE" A_Index
;GuiControl, Move, %NOTE_actv%, w750 h530
GuiControl, Move, %NOTE_actv%, % "w" Width_B -15 "h" Height_B -62
;Gui, Font , S%font_B_%%A_Index% c%font_color_%%A_Index% , %font_%%A_Index%
;Gui, Font, S12 , Times New Roman
f_size_cur:=f_size_B_%A_Index% " c" font_color_%A_Index%
f_cur:=font_B_%A_Index%
Gui, Font , s%f_size_cur% , %f_cur%
GuiControl, Font, NOTE%A_Index%
}
GuiControl,3: Show, textFind_Regex
}else{
ShowBig:=0
GuiControl,3: Hide, textFind_Regex
; WinMove, Quick Notes - Drozd, , 580,270 , 415, 360
CenterWindowSize("Quick Notes - Drozd",415, 360 )
/* ControlMove, Static11, 388, 12
ControlMove, Static10, 355, 12
ControlMove, Static9, 335, 13
ControlMove, Static8, 313, 12
ControlMove, Static7, 278, 14
ControlMove, Static6, 240,12
ControlMove, Static5, 240,12
*/
Loop 8 {
NOTE_actv := "NOTE" A_Index
GuiControl, Move, %NOTE_actv%, w400 h300
;Gui, Font, S10 CDefault , Segoe UI
f_size_cur:=f_size_%A_Index% " c" font_color_%A_Index%
f_cur:=font_%A_Index%
Gui, Font , s%f_size_cur% , %f_cur%
GuiControl, Font, NOTE%A_Index%
}
}
return
CenterWindow(WinTitle){
WinGetPos,,, Width, Height, %WinTitle%
WinMove, %WinTitle%,, % (A_ScreenWidth/2)-(Width/2), % (A_ScreenHeight/2)-(Height/2)
}
CenterWindowSize(WinTitle, Width, Height ){
WinMove, %WinTitle%,, % (A_ScreenWidth/2)-(Width/2), % (A_ScreenHeight/2)-(Height/2), % Width, % Height
}
onTop:
WonTop:=!WonTop
if WonTop {
WinSet, AlwaysOnTop, on, Quick Notes - Drozd ; ahk_class AutoHotkeyGUI,
GuiControl, Hide , onTop2
GuiControl, Show , onTop1
}else{
WinSet, AlwaysOnTop, off, Quick Notes - Drozd
GuiControl, Hide , onTop1
GuiControl, Show , onTop2
}
return
; =====================================================
Number_of_letters:
Gui, Submit, NoHide
if(!Curr_Index){
Loop 8 {
if(TabName=n%A_Index%)
Curr_Index=%A_Index%
}
}
GuiControlGet,NOTE_actv, ,Note%Curr_Index%
num := StrLen(NOTE_actv)
GuiControl,, RESULT, %num%
return
Number_of_words:
Gui, Submit, NoHide
if(!Curr_Index){
Loop 8 {
if(TabName=n%A_Index%)
Curr_Index=%A_Index%
}
}
GuiControlGet,NOTE_actv, ,Note%Curr_Index%
RegExReplace( NOTE_actv, "\w+", "", Count ) ;
GuiControl,, RESULT2, %Count%
return
; =====================================================
2Reverse:
Reverse:
Gui, Submit, NoHide
Loop 8 {
if (TabName=n%A_Index%) {
GuiControlGet,NOTE_actv, ,Note%A_Index%
rev:=Flip(NOTE_actv)
; GuiControl,, NOTE_actv , %rev%
GuiControl,, Note%A_Index% , %rev%
; msgbox,,, Reverse: %rev%,4
Break
}
}
Flip(Str) {
AutoTrim, Off
;Str:=RegExReplace(Str, " ","|")
Loop, Parse, Str,
res=%A_LoopField%%res%
;res:=RegExReplace(res, "\|"," ")
AutoTrim, On
return res
}
return
~$F4::
Gui 1: Show
return
~+!^r::
If WinActive("Quick Notes - Drozd") || WinActive("Help_popup - Drozd")
Gosub, Reverse
return
Rev_but:
;Gosub, Reverse
Send, +!^r
return
; =====================================================
Notes_settings:
Gui,4:+owner1
Gui,4: +ToolWindow
Gui,4:Add, Button , x140 y340 w60 h22 gSaveSet , Save
Gui,4:Add, Button , x240 y340 w60 h22 gCancel_but , Cancel
Gui,4:Add, Tab, x10 y10 w430 h320 , Notes Names|Fonts|Fonts Big|Misc
Gui,4: Tab, 1
Gui,4: Font, S8 , Segoe UI Bold ;
Gui,4:Add, Text, x110 y36 , Custom Names for Notes
Gui,4: Font, S8 W400 , Tahoma
Gui,4:Add, Text, x40 y64 , Note1
Gui,4:Add, Edit, x+40 y60 w140 vSet_Note1 , Note1
Gui,4:Add, Text, x40 y94 , Note2
Gui,4:Add, Edit, x+40 y90 w140 vSet_Note2 , Note2
Gui,4:Add, Text, x40 y124 , Note3
Gui,4:Add, Edit, x+40 y120 w140 vSet_Note3 , Note3
Gui,4:Add, Text, x40 y154 , Note4
Gui,4:Add, Edit, x+40 y150 w140 vSet_Note4 , Note4
Gui,4:Add, Text, x40 y184 , Note5
Gui,4:Add, Edit, x+40 y180 w140 vSet_Note5 , Note5
Gui,4:Add, Text, x40 y214 , Note6
Gui,4:Add, Edit, x+40 y210 w140 vSet_Note6 , Note6
Gui,4:Add, Text, x40 y244 , Note7
Gui,4:Add, Edit, x+40 y240 w140 vSet_Note7 , Note7
Gui,4:Add, Text, x40 y274 , Note8
Gui,4:Add, Edit, x+40 y270 w140 vSet_Note8 , Note8
Gui,4:Add, Text, x100 y306 , Restart the program for new settings to take effect
Gui,4: Tab,2
Gui,4: Font, S8 , Segoe UI Bold ;
Gui,4:Add, Text, x140 y40 , Font Family
Gui,4:Add, Text, x306 y40 , Size
Gui,4:Add, Text, x370 y40 , Color
Gui,4: Font, S8 W400 , Tahoma
Gui,4:Add, Text, x40 y64 , Note1
Gui,4:Add, Edit, x+40 y60 w140 vSet_f_Note1 , Times New Roman Bold
Gui,4:Add, Edit, x+50 y60 w40 vSet_s_Note1 , 11
Gui,4:Add, Edit, x+20 y60 w60 vSet_c_Note1 , 000000
Gui,4:Add, Text, x40 y94 , Note2
Gui,4:Add, Edit, x+40 y90 w140 vSet_f_Note2 , Font
Gui,4:Add, Edit, x+50 y90 w40 vSet_s_Note2 , 11
Gui,4:Add, Edit, x+20 y90 w60 vSet_c_Note2 , 000000
Gui,4:Add, Text, x40 y124 , Note3
Gui,4:Add, Edit, x+40 y120 w140 vSet_f_Note3 , Font
Gui,4:Add, Edit, x+50 y120 w40 vSet_s_Note3 , 11
Gui,4:Add, Edit, x+20 y120 w60 vSet_c_Note3 , 000000
Gui,4:Add, Text, x40 y154 , Note4
Gui,4:Add, Edit, x+40 y150 w140 vSet_f_Note4 , Font
Gui,4:Add, Edit, x+50 y150 w40 vSet_s_Note4 , 11
Gui,4:Add, Edit, x+20 y150 w60 vSet_c_Note4 , 000000
Gui,4:Add, Text, x40 y184 , Note5
Gui,4:Add, Edit, x+40 y180 w140 vSet_f_Note5 , Font
Gui,4:Add, Edit, x+50 y180 w40 vSet_s_Note5 , 11
Gui,4:Add, Edit, x+20 y180 w60 vSet_c_Note5 , 000000
Gui,4:Add, Text, x40 y214 , Note6
Gui,4:Add, Edit, x+40 y210 w140 vSet_f_Note6 , Font
Gui,4:Add, Edit, x+50 y210 w40 vSet_s_Note6 , 11
Gui,4:Add, Edit, x+20 y210 w60 vSet_c_Note6 , 000000
Gui,4:Add, Text, x40 y244 , Note7
Gui,4:Add, Edit, x+40 y240 w140 vSet_f_Note7 , Font
Gui,4:Add, Edit, x+50 y240 w40 vSet_s_Note7 , 11
Gui,4:Add, Edit, x+20 y240 w60 vSet_c_Note7 , 000000
Gui,4:Add, Text, x40 y274 , Note8
Gui,4:Add, Edit, x+40 y270 w140 vSet_f_Note8 , Font
Gui,4:Add, Edit, x+50 y270 w40 vSet_s_Note8 , 11
Gui,4:Add, Edit, x+20 y270 w60 vSet_c_Note8 , 000000
Gui,4: Tab,3
Gui,4: Font, S8 , Segoe UI Bold ;
Gui,4:Add, Text, x140 y40 , Font Family
Gui,4:Add, Text, x306 y40 , Size
;Gui,4:Add, Text, x370 y40 , Color
Gui,4: Font, S8 W400 , Tahoma
Gui,4:Add, Text, x40 y64 , Note1
Gui,4:Add, Edit, x+40 y60 w140 vSet_f_B_Note1 , Times New Roman Bold
Gui,4:Add, Edit, x+50 y60 w40 vSet_s_B_Note1 , 11
;Gui,4:Add, Edit, x+20 y60 w60 vSet_c_B_Note1 , 000000
Gui,4:Add, Text, x40 y94 , Note2
Gui,4:Add, Edit, x+40 y90 w140 vSet_f_B_Note2 , Font
Gui,4:Add, Edit, x+50 y90 w40 vSet_s_B_Note2 , 11
;Gui,4:Add, Edit, x+20 y90 w60 vSet_c_B_Note2 , 000000
Gui,4:Add, Text, x40 y124 , Note3
Gui,4:Add, Edit, x+40 y120 w140 vSet_f_B_Note3 , Font
Gui,4:Add, Edit, x+50 y120 w40 vSet_s_B_Note3 , 11
;Gui,4:Add, Edit, x+20 y120 w60 vSet_c_B_Note3 , 000000
Gui,4:Add, Text, x40 y154 , Note4
Gui,4:Add, Edit, x+40 y150 w140 vSet_f_B_Note4 , Font
Gui,4:Add, Edit, x+50 y150 w40 vSet_s_B_Note4 , 11
;Gui,4:Add, Edit, x+20 y150 w60 vSet_c_B_Note4 , 000000
Gui,4:Add, Text, x40 y184 , Note5
Gui,4:Add, Edit, x+40 y180 w140 vSet_f_B_Note5 , Font
Gui,4:Add, Edit, x+50 y180 w40 vSet_s_B_Note5 , 11
;Gui,4:Add, Edit, x+20 y180 w60 vSet_c_B_Note5 , 000000
Gui,4:Add, Text, x40 y214 , Note6
Gui,4:Add, Edit, x+40 y210 w140 vSet_f_B_Note6 , Font
Gui,4:Add, Edit, x+50 y210 w40 vSet_s_B_Note6 , 11
;Gui,4:Add, Edit, x+20 y210 w60 vSet_c_B_Note6 , 000000
Gui,4:Add, Text, x40 y244 , Note7
Gui,4:Add, Edit, x+40 y240 w140 vSet_f_B_Note7 , Font
Gui,4:Add, Edit, x+50 y240 w40 vSet_s_B_Note7 , 11
;Gui,4:Add, Edit, x+20 y240 w60 vSet_c_B_Note7 , 000000
Gui,4:Add, Text, x40 y274 , Note8
Gui,4:Add, Edit, x+40 y270 w140 vSet_f_B_Note8 , Font
Gui,4:Add, Edit, x+50 y270 w40 vSet_s_B_Note8 , 11
;Gui,4:Add, Edit, x+20 y270 w60 vSet_c_B_Note8 , 000000
Gui,4: Tab,4
Gui,4: Font, S8 , Segoe UI Bold ;
Gui,4:Add, Text, x140 y40 ,
Gui,4: Font, S8 W400 , Tahoma
Gui,4: Add, GroupBox, x30 y50 w220 h100 , Search Options
Gui,4:Add, Text, x50 y84 , Query from selection
Gui,4:Add, Edit, x+30 y80 w30 vSearch_Op , 0
Gui,4: Add, GroupBox, x260 y50 w160 h100 , Help
Gui,4:Add, Text, x270 y70 , 0: Default `n`n1: Selected text in the note `n is automatically used `n as the search query
;Gui,4:Add, Radio, vMyRadioGroup,Search Option
;Gui,4: Add, GroupBox, x16 y20 w40 h20
font_list1=
(
Times New Roman
Segoe UI
Lucida Console
Verdana
Arial
Arial Black
Tahoma
Courier New
Georgia
)
font_list2=
(
Segoe UI Bold
Segoe UI Semibold
Aharoni
Segoe Script
Segoe Print
Comic Sans MS
Comic Sans MS Bold
Gotham Rounded A
)
Gui,4: Font, S8 , Segoe UI ;
Gui,4:Add, Edit, x30 y160 w120 h150 -Vscroll ReadOnly, %font_list1%
Gui,4:Add, Edit, x170 y160 w120 h150 -Vscroll ReadOnly, %font_list2%
Gui,4:Show, w450 h370 , Quick Notes Settings - Drozd
Gosub, Load_Settings
return
Load_Settings:
IniRead, Find_from_sel, %settings_ini%, Misc, Search Option
GuiControl,4:, Search_Op , %Find_from_sel%
Loop, 8 {
IniRead, n%A_Index%, %settings_ini%, Note%A_Index%, Name
IniRead, font_%A_Index%, %settings_ini%, Note%A_Index%, Font
IniRead, f_size_%A_Index%, %settings_ini%, Note%A_Index%, Size
IniRead, font_B_%A_Index%, %settings_ini%, Note%A_Index%, Font_Big
IniRead, f_size_B_%A_Index%, %settings_ini%, Note%A_Index%, Size_Big
IniRead, font_color_%A_Index%, %settings_ini%, Note%A_Index%, Color
}
Loop, 8 {
GuiControl,4:, Set_Note%A_Index% , % n%A_Index%
GuiControl,4:, font_%A_Index% , % font_%A_Index%
GuiControl,4:, Set_f_Note%A_Index% , % font_%A_Index%
GuiControl,4:, Set_s_Note%A_Index% , % f_size_%A_Index%
GuiControl,4:, Set_c_Note%A_Index% , % font_color_%A_Index%
GuiControl,4:, Set_f_B_Note%A_Index% , % font_B_%A_Index%
GuiControl,4:, Set_s_B_Note%A_Index% , % f_size_B_%A_Index%
;GuiControl,4:, Set_c_B_Note%A_Index% , % font_color_%A_Index%
}
return
SaveSet:
Gui, Submit, NoHide
;IniRead, Find_from_sel, %settings_ini%, Misc, Search Option
IniWrite, %Search_Op%, %settings_ini%, Misc, Search Option
Loop, 8 {
IniWrite, % Set_Note%A_Index%, %settings_ini%, Note%A_Index%, Name
IniWrite, % Set_f_Note%A_Index%, %settings_ini%, Note%A_Index%, Font
IniWrite, % Set_s_Note%A_Index%, %settings_ini%, Note%A_Index%, Size
IniWrite, % Set_f_B_Note%A_Index%, %settings_ini%, Note%A_Index%, Font_Big
IniWrite, % Set_s_B_Note%A_Index%, %settings_ini%, Note%A_Index%, Size_Big
IniWrite, % Set_c_Note%A_Index%, %settings_ini%, Note%A_Index%, Color
}
load_vars()
Gosub, Cancel_but
return
Cancel_but:
Gui,4: Destroy
Gui,1:-Disabled
Gui,1: Show
return
GoSettings:
Gui,1: +Disabled
Gosub, Notes_settings
return
4GuiClose:
Gui 4: Destroy
Gui,1:-Disabled
Gui,1: Show
return
#IfWinActive Quick Notes - Drozd
$F1:: Gosub, GoToPrevTab
$F2:: Gosub, GoToNextTab
#IfWinActive
#IfWinActive Find toolbar - Drozd
$F1:: Gosub, GoToPrevTab
$F2:: Gosub, GoToNextTab
#IfWinActive
GoToNextTab:
Gosub, checkTabLast
if(TabCurr=="TabLast"){
SendMessage, 0x1330, 0,, SysTabControl321, ahk_id %this_id1% ; 0x1330 is TCM_SETCURFOCUS.
SendMessage, 0x130C, 0,, SysTabControl321, ahk_id %this_id1% ; 0x130C is TCM_SETCURSEL.
}else
Control, TabRight , 1, SysTabControl321, ahk_id %this_id1%
Gosub, Change
return
GoToPrevTab:
Gosub, checkTabLast
if(TabCurr=="TabFirst"){
SendMessage, 0x1330, 7,, SysTabControl321, ahk_id %this_id1% ; 0x1330 is TCM_SETCURFOCUS.
SendMessage, 0x130C, 7,, SysTabControl321, ahk_id %this_id1% ; 0x130C is TCM_SETCURSEL.
}else
Control, TabLeft , 1, SysTabControl321, ahk_id %this_id1%
Gosub, Change
return
checkTabLast:
TabCurr:=""
GuiControlGet, Tname , , TabName
Tfirst:=n1,Tlast:=n8
if(Tname==Tfirst){
TabCurr:="TabFirst"
}else if(Tname==Tlast){
TabCurr:="TabLast"
}
;MsgBox,4096,, % Tname "`n" TabCurr
return
; =====================================================
/* #IfWinActive Quick Notes - Drozd
WHEEL_DELTA := (120 << 16)
WheelUp::
SendMessage, 0x00B6, 0, -3, EDIT%Curr_Index% , % "ahk_id " this_id1 ; EM_LINESCROLL scroll up 3
;PostMessage, 0x20A, 7864320, (mY << 16) | mX,, % "ahk_id " this_id1
;Scroll(7864320)
return
WheelDown::
SendMessage, 0x00B6, 0, 3,EDIT%Curr_Index% , % "ahk_id " this_id1 ; EM_LINESCROLL scroll 3
;PostMessage, 0x20A, -7864320, (mY << 16) | mX,, % "ahk_id " this_id1
;Scroll(-7864320)
return
#IfWinActive
Scroll(WHEEL_DELTA) {
MouseGetPos, mX, mY, hWin, hCtrl, 2
PostMessage, 0x20A, WHEEL_DELTA, (mY << 16) | mX,,% "ahk_id" (hCtrl ? hCtrl:hWin)
}
*/
#IfWinActive Quick Notes - Drozd
~LButton & WheelUp:: Gosub, PageUp
~LButton & Wheeldown:: Gosub, PageDown
#IfWinActive
PageDown:
SendMessage, 0x115, 3, 0, EDIT%Curr_Index%, % "ahk_id " this_id1 ; scroll PageDown WM_VSCROLL
return
PageUp:
SendMessage, 0x115, 2, 0, EDIT%Curr_Index% , % "ahk_id " this_id1 ; scroll PageUp
return
; =====================================================
GUIDropFiles:
file_path:=A_GUIEvent
ControlGetFocus, ctrl_foc , Quick Notes - Drozd
if(file_path){
FileRead, from_file, %file_path%
from_file := RegExReplace(from_file, "`n", "`r`n")
GuiControl,1:, %ctrl_foc% , %from_file%
}
return
; =====================================================
GuiSize: ; on window resize
Loop 8 {
;GuiControl Move, Edit%A_Index%, % "H" . (A_GuiHeight-44) . " W" . (A_GuiWidth)
GuiControl Move, Edit%A_Index%, % "H" . (A_GuiHeight-46) . " W" . (A_GuiWidth)
}
GuiControl Move, TabName, % " W" . (A_GuiWidth+2) "H" (A_GuiHeight)
GuiControl Move, Static11, % "x" . (A_GuiWidth-20)
WinGetPos, x1,y1,w1,h1, Quick Notes - Drozd
;WinMove, Find toolbar - Drozd ,, % (x1+5) , (y1 + 50), (w1-10) ; top
WinMove, Find toolbar - Drozd ,, % (x1+5) , (y1 + h1 - 40),(w1-10)
return
3GuiSize:
GuiControl Move, Static3, % "x" . (A_GuiWidth-30)
return
GetModified(){
global this_id1
str:=""
Loop 8 {
ControlGet, controlHWND, Hwnd,, Edit%A_Index% , ahk_id %this_id1%
SendMessage, 0xB8, 0, 0, , % "ahk_id " controlHWND ; EM_GETMODIFY = 0xB8
if(ErrorLevel==1)
str.= "`t" n%A_Index% "`n"
}
return str
}
Close:
GuiClose:
ismodified:=GetModified()
if (ismodified==""){
ExitApp
}else{
MsgBox, 0x00040003, , Do you want to save before exiting? `nModified:`n%ismodified%
IfMsgBox, Yes
Gosub,Save_All_and_Exit
IfMsgBox, No
ExitApp
IfMsgBox Cancel
return
}
return
/* Close:
GuiClose:
MsgBox, 4100, Confirm exit, Do you want to save before exiting Quick Notes?
IfMsgBox, Yes
Gosub,Save_All_and_Exit
IfMsgBox, No
ExitApp
return */
/* Close:
GuiClose:
MsgBox, 4100, Confirm exit, Do you want to exit Quick Notes?
IfMsgBox, No
Return
ExitApp
return
*/
GuiEscape:
3GuiEscape:
Gui 3: Hide
return
/*
Close:
ExitApp
return
GuiClose:
ExitApp
*/
; Esc:: exitapp
Alarm Timer
Code: Select all
;#SingleInstance force
; shows time left on taskbar; movable window
; double click on tray icon = exit
ico:="C:\Program Files\Misc\AutoHotkey Scripts\icons\Alarm-clock.ico"
;ico:="wmploc.dll`, 17"
Menu, Tray,Tip , Alarm Timer
;Menu, Tray, Icon, pifmgr.dll, 5
;Menu, Tray, Icon, wmploc.dll, 21
;Menu, Tray, Icon, shell32.dll,266
;Menu, Tray, Icon, C:\Program Files\Misc\AutoHotkey Scripts\icons\Alarm-clock.ico
;Menu, Tray, Icon, wmploc.dll, 21 ; Win Vista
;Menu, Tray, Icon, wmploc.dll, 17 ; Win8
ico1:=InStr(A_OSVersion,"WIN_VISTA") ? 21: 17
Menu, Tray, Icon, wmploc.dll , %ico1%
Menu, Tray, Add, Exit Alarm Timer, Exit_Gui ; double click tray icon to exit
Menu, Tray, Default, Exit Alarm Timer ; double click tray icon to exit
Menu, Tray, Add, Hide/Show, hide_show
;Menu, Tray, Default, Hide/Show
Menu, ContextMenu, Add, Hide/Show, hide_show
Menu, ContextMenu, Add, Border, border_
Menu, ContextMenu, Add, Open settings file , Open_ini
Menu, ContextMenu, Icon, Open settings file, Shell32.dll, 70
param1= %1%
start_time=5
if(param1){
start_time=%param1%
}
SoundGet, loudness_start
alarm_texts_string:=""
;----
global settings_ini := "Drozd alarm timer.ini"
IfNotExist, %settings_ini%
{
start_ini_text:="[Alarm timer]`r`nwin_sound=1`r`nloudness=5`r`nhide_show_time_key=1`r`nalarm_text1=Alarm`r`nalarm_text2=News`r`nalarm_text3=Mecz`r`nalarm_sound1=C:\WINDOWS\Media\chimes.wav`r`nalarm_sound2=C:\WINDOWS\Media\notify.wav`r`nalarm_sound3=C:\WINDOWS\Media\tada.wav`r`n"
FileAppend, % start_ini_text , %settings_ini%
}
;-----------
Menu, FileMenu, Add, Open settings file , Open_ini
Menu, FileMenu, Icon, Open settings file, Shell32.dll, 70
Menu, FileMenu, Add, Exit, Exit
Menu, FileMenu, Icon, Exit, shell32.dll,132
Menu, MenuBar, Add, &File, :FileMenu
Loop, 10{
IniRead, key, %settings_ini%, Alarm timer, alarm_sound%A_Index%
if (key!="ERROR" && key!=""){
;sound_files=%sound_files%|%key%
Menu, SoundMenu, Add, %key%, MenuHandler
;Menu, SoundMenu, Icon, %key%, shell32.dll,132
}else if (key=="ERROR"){
break
}
}
Menu, MenuBar, Add, &Sound File, :SoundMenu
Menu, AlarmsMenu, Add, 10 min., start_timer_10m
Menu, AlarmsMenu, Icon, 10 min., %ico%
Menu, AlarmsMenu, Add, 15 min., start_timer_15m
Menu, AlarmsMenu, Icon, 15 min., %ico%
Menu, AlarmsMenu, Add,
Menu, AlarmsMenu, Add, 20 min., start_timer_20m
Menu, AlarmsMenu, Icon, 20 min., %ico%
Menu, AlarmsMenu, Add, 30 min., start_timer_30m
Menu, AlarmsMenu, Add,
Menu, AlarmsMenu, Icon, 30 min., %ico%
Menu, AlarmsMenu, Add, 60 min., start_timer_60m
Menu, AlarmsMenu, Icon, 60 min., %ico%
Menu, MenuBar, Add, &Alarms, :AlarmsMenu
Menu MenuBar, Color, A4A4A4 , Single
Gui, Menu, MenuBar
;----
IniRead, key, %settings_ini%, Alarm timer, alarm_sound1
;alarm_sound0:="F:\Music\Jimi Hendrix\Jimi Hendrix - All Along The Watchtower.mp3"
alarm_sound0:="C:\WINDOWS\Media\chimes.wav"
alarm_sound:= (key!="ERROR") ? key : alarm_sound0
IniRead, win_sound, %settings_ini%, Alarm timer, win_sound
IniRead, loudness, %settings_ini%, Alarm timer, loudness
IniRead, hide_show_time_key, %settings_ini%, Alarm timer, hide_show_time_key
Loop, 10{
IniRead, key_text, %settings_ini%, Alarm timer, alarm_text%A_Index%
if(key_text!="ERROR" && key_text!=""){
alarm_texts_string:= alarm_texts_string key_text "|"
}else if (key_text=="ERROR"){
break
}
}
;----
SysGet, MonitorWorkArea, MonitorWorkArea, 1
x:=A_ScreenWidth - 70 - 16
;y:= MonitorWorkAreaBottom -30
y:= MonitorWorkAreaBottom -146
Gui,1: -border
Gui,Color,83001A ; 054258
;Gui,1:Color, 120F00
Gui,1:Color, 7D0019
Gui,Font, S9 w700 CDefault , Segoe UI
Gui,Add,Text,cA4A4A4 x15 y13 h30 Center ,` min or hhmm
Gui, Add, Checkbox, x32 y73 w60 h20 cA4A4A4 vCheckbox1 Checked , ` beep
Gui,Font, S10 w700 CDefault , Segoe UI
Gui,Add,Edit, x120 y10 h22 w100 vTIME Center , %start_time%
Gui, Add, UpDown, vUpDownHeight Range0-60,%start_time%
Gui, Add,Text,cA4A4A4 x10 y42 h20 w100 Center ,` Alarm text
Gui,Font, S9 w700 CDefault , Segoe UI
Gui, Add, ComboBox, x120 y40 w100 vMESSAGE gCombo Limit Choose1, %alarm_texts_string% ;Alarm|Mecz|News
Gui,Font, S10 w700 CDefault , Segoe UI
Gui,Add,Button, x120 y72 h24 w100 gTIMER Center ,Start
Gui,1: Add, Picture, x238 y4 w16 h16 gexit Icon132 AltSubmit, shell32.dll ;
;ControlFocus,Edit1, Alarm Timer - Drozd
;Send, ^a
OnMessage(0x100, "WM_KEYDOWN")
OnMessage(0x201, "WM_LBUTTONDOWN") ; movable borderless window
OnMessage(0x404, "AHK_NOTIFYICON") ;click tray icon to show
Gui,Show, h106 w256 , Alarm Timer - Drozd
;Winset, Transparent, 230, Alarm Timer - Drozd
return
WM_KEYDOWN(wParam, lParam){
ControlGetFocus, control , Alarm Timer - Drozd
if (A_Gui = 1 && wParam = 13 && control=="Edit1" ){ ; VK_ENTER := 13
Gosub, timer
}
}
WM_LBUTTONDOWN(){
PostMessage, 0xA1, 2 ; movable borderless window
}
AHK_NOTIFYICON(wParam, lParam){ ;click tray icon to show
if (lParam = 0x202) { ; WM_LBUTTONUP
Gosub, hide_show
}else if (lParam = 0x203){ ; WM_LBUTTONDBLCLK
;Gui,1: Show
}
}
/* ~LButton::
tray_id:=WinExist("ahk_class Shell_TrayWnd")
MouseGetPos,,,Win_id,control
if(Win_id == tray_id){
sleep 200
Gui,3:Show
}
return
*/
timer:
Gui, Submit, Nohide
Gui, Destroy
Gosub, show_time
#SingleInstance off
#persistent
GuiControlGet, Checkbox1, , Checkbox1
FormatTime, start_timer,, HH:mm:ss
seconds:= StrLen(TIME)<4 ? TIME * 60 : SubStr(TIME, -1 ) * 60 + SubStr(TIME, 1,2 ) * 3600
TIME_min:= StrLen(TIME)<4 ? TIME : SubStr(TIME, 1,2 ) "h " SubStr(TIME, -1 ) ""
time_count= %seconds%
start_time:=A_TickCount
SetTimer, count_time, 998 ;1000
SetTimer, compare_time, 1000
count_time:
;ToolTip, % time_count
time_count:=time_count-1
count_timeLeft_h := Floor(time_count/3600)
count_timeLeft_m := time_count>3600 ? Floor(mod(time_count,3600)/60) : Floor(time_count/60)
count_timeLeft_s := Floor(mod(time_count,60))
;Menu, Tray,Tip , % count_time_left
count_time_left:=count_timeLeft_h >0 ? dig(count_timeLeft_h) " : " dig(count_timeLeft_m) " : " dig(count_timeLeft_s) : "` " dig(count_timeLeft_m) " : " dig(count_timeLeft_s)
time_left_2:=count_timeLeft_m " : " dig(count_timeLeft_s)
;GuiControl,3:, Show_timer, %count_time_left%
if(time_count<=0){
SetTimer, count_time, Off
;SetTimer, compare_time, Off
;Gosub, alarm
}
return
compare_time:
time_compare := Round((A_TickCount - start_time)/1000)
;ToolTip, % time_compare_show
time_compare:=seconds-time_compare
compare_timeLeft_h := Floor(time_compare/3600)
compare_timeLeft_m := time_compare>3600 ? Floor(mod(time_compare,3600)/60) : Floor(time_compare/60)
compare_timeLeft_s := Floor(mod(time_compare,60))
;time_compare_show:= time_compare>3600 ? dig(h) " : " dig(m) " : " dig(s) : dig(m) " : " dig(s)
time_compare_show:=compare_timeLeft_h >0 ? dig(compare_timeLeft_h) ":" dig(compare_timeLeft_m) ":" dig(compare_timeLeft_s) : dig(compare_timeLeft_m) ":" dig(compare_timeLeft_s)
count_time_left2:=RegExReplace(count_time_left,"\s+:\s+",":")
tray_tip:="count: " count_time_left2 "`n" "compare: " time_compare_show "`ntime: " TIME_min " min" "`nstarted on: " start_timer
;diff:=
time_compare_left:=compare_timeLeft_h >0 ? dig(compare_timeLeft_h) " : " dig(compare_timeLeft_m) " : " dig(compare_timeLeft_s) : "` " dig(compare_timeLeft_m) " : " dig(compare_timeLeft_s)
GuiControl,3:, Show_timer, %time_compare_left%
Menu, Tray,Tip , % tray_tip ;"`ndiff: " diff " " m_count " " d2
if(time_compare<=0){
SetTimer, compare_time, Off
SetTimer, count_time, Off
Gosub, alarm
}
return
dig(num){ ;to_two_digits
num:= num<=9 ? "0" . num : num
return num
}
alarm:
if(Checkbox1==1){
SoundBeep,700
SoundBeep,,400
SoundPlay *48
}
GuiControlGet, MESSAGE , , ComboBox
alarm_time:= "" TIME " min."
alarm_text:= MESSAGE
if(alarm_text=="Alarm")
alarm_text:="• Timer •"
Gosub, alarm_dialog_show
return
/* show_time: ; bez ramki
Gui,3: +ToolWindow -border AlwaysOnTop
Gui,3:Color, 120F00 ;120F00
Gui,3: Font, S8 W700 , Tahoma ;Segoe UI Verdana
Gui,3: Add, Text , x8 y6 w60 cFFFFFF vShow_timer , ;01 : 12 : 04
Gui,3: Font, S6 cD0D0D0
;Gui,3: Add, Text , x69 y+-21 w60 gshow_time_exit , x
Gui,3:Show, x%x% y%y% w70 h20 , Show_timer - Drozd
Winset, Transcolor, %InvertedColor% 200, Show_timer - Drozd ; Show_timer - Drozd
WinSet, Style, -0xC00000,Show_timer - Drozd ; COMPLETELY remove window border
;WinSet, Region, 0-4 w70 h20 E, Show_timer - Drozd ; ellipse
OnMessage(0x201, "WM_LBUTTONDOWN") ; movable borderless window
return
*/
show_time: ; z ramką
Gui,3: +ToolWindow -border AlwaysOnTop
Gui,3:Color, 120F00 ;120F00
Gui,3: Font, S8 W700 , Tahoma ;Segoe UI Verdana
Gui,3: Add, Text , x6 y3 w60 cFFFFFF vShow_timer gDblClick , ;01 : 12 : 04
Gui,3: Font, S6 cD0D0D0
;Gui,3: Add, Text , x69 y+-21 w60 gshow_time_exit , x
Gui,3:Show, x%x% y%y% w70 h20 NA, Show_timer - Drozd
; WinSet, Style, -0xC00000,Show_timer - Drozd
Winset, Transparent,200, Show_timer - Drozd
OnMessage(0x201, "WM_LBUTTONDOWN") ; movable borderless window
return
~Pause:: Gosub, hide_show
hide_show:
if (!hide_show_time_key)
return
hide_show_time:=!hide_show_time
if(hide_show_time){
Gui,3:Hide
}else if(!hide_show_time){
Gui,3:Show
}
return
DblClick:
if A_GuiControlEvent <> DoubleClick
return
gosub, border_
return
border_:
win_bord:=!win_bord
if(!win_bord){
WinSet, Style, +0xC00000,Show_timer - Drozd
Gui,3: +ToolWindow -border
ControlMove, Static1 , , 6 ,,, Show_timer - Drozd
}else{
WinSet, Style, -0xC00000,Show_timer - Drozd
Gui,3: +ToolWindow -border
ControlMove, Static1 , ,6 ,,, Show_timer - Drozd
}
return
show_time_exit:
Gui,3: Destroy
return
alarm_dialog_show:
diff:= Abs(time_count - time_compare)
start_msg_timer:=diff
;SoundGetWaveVolume, loudness_start
SoundGet, loudness_start
;play_music(5)
SetTimer, flash, 1000
if(win_sound==1){
SetTimer, beep, 10000
}
Gui,2: +ToolWindow -border AlwaysOnTop
Gui,2:Color, 120F00
;Gui,2: Add, Edit, x60 y4 w140 h20 0x100 vQuery_1 , ; Search
Gui,2: Font, S8 W700 , Tahoma ;Segoe UI Verdana
Gui,2: Add, Text , x43 y6 w60 cFFFFFF vmsg_timer Center , ; 01 : 12 : 04
Gui,2:Add,Groupbox,cD0D0D0 x18 y24 w117 h96 vramka
Gui,2: Font, S11 W700 , Comic Sans MS ;Segoe UI ; Verdana
Gui,2: Add, Text , x55 y37 cFFFFFF vtitle Center gplay_again , Alarm
Gui,2: Font, S11 W700 , Tahoma ;Segoe UI Verdana
Gui,2: Add, Text , x26 y68 w100 h50 cFFFFFF vShow_alarm Center , %alarm_text%
Gui,2: Font, S8 W700 , Segoe UI
Gui,2: Add, Text , x36 y100 w80 cCCCCCC valarm_time Center , %alarm_time%
Gui,2: Font, S8 cD0D0D0
Gui,2: Add, Text , x130 y1 w30 h20 gexit , ` X
Gui,2: Font, S8 W400 cD0D0D0, Segoe UI
;Gui,2: Add, Text , x128 y128 w40 vt_left ,
Gui,2: Add, Text , x100 y128 w20 vt_left Right ,
Gui,2: Add, Text , x122 y128 w30 c413700 vt_left0 ,
Gui,2: Font, S10 W700 , Tahoma
;Gui,2: Add, Text , x61 y125 w30 cFFFFFF gexit , Close
Gui,2: Add, Text , x68 y126 w30 cFFFFFF gexit , OK
;Gui,2:Add,Groupbox,cD0D0D0 x62 y119 w28 h26
Gui,2: Hide
Gui,2:Show, w150 h150 NA, Show_alarm - Drozd
Winset, Transparent,200, Show_alarm - Drozd
;WinSet, Style, -0xC00000,Show_alarm - Drozd ; COMPLETELY remove window border
SetTimer, time_date, 1000
;GuiControl,1:, t_left0, / %time_s%
play_music(loudness)
OnMessage(0x203,"WM_LBUTTONDBLCLK")
OnMessage(0x201, "WM_LBUTTONDOWN") ; movable borderless window
OnMessage(0x200, "WM_MOUSEMOVE")
return
play_music(level){
global alarm_sound, loudness_start
;SoundPlay, C:\Program Files\Misc\AutoHotkey Scripts\sound\flute.mp3
;SoundGetWaveVolume, loudness_start
SoundGet, loudness_start
SoundPlay, %alarm_sound%
play_loudness(level)
;SoundPlay, %sound_file%, Wait
}
play_loudness(n){
loop, %n% {
;SoundSetWaveVolume, % A_Index*5
SoundSet, % A_Index*10
Sleep, 200
;SoundSetWaveVolume, % A_Index*2*5
;Sleep, 200
}
}
beep:
SoundPlay *48
return
time_date:
start_msg_timer+=1
msg_timer_h := Floor(start_msg_timer/3600)
msg_timer_m := time_count>3600 ? Floor(mod(start_msg_timer,3600)/60) : Floor(start_msg_timer/60)
msg_timer_s := Floor(mod(start_msg_timer,60))
msg_timer_l:=msg_timer_h >0 ? dig(msg_timer_h) " : " dig(msg_timer_m) " : " dig(msg_timer_s) : "` " dig(msg_timer_m) " : " dig(msg_timer_s)
GuiControl,2:, msg_timer, %msg_timer_l%
return
flash:
col:=!col
if(col){
Gui,2: Font, S11 cFFFFFF W700 , Comic Sans MS
GuiControl,2: Font, title
}else{
Gui,2: Font, S11 cRed W700 , Comic Sans MS
GuiControl,2: Font, title
}
return
play_again:
play_music(loudness)
Gui,2: -AlwaysOnTop
return
MenuHandler:
alarm_sound:= A_ThisMenuItem
;Gosub,TIMER
return
Combo:
GuiControlGet,tekst,1:, ComboBox1
;MsgBox,,, % tekst
if(tekst=="Mecz_timer"){
GuiControl, , Checkbox1 , 0
alarm_sound:="F:\1.Music\alarm\Iron Maiden-tomorrow.mp3"
;alarm_sound:="F:\1.Music\alarm\Metallica - Welcome Home.mp3"
;alarm_sound:="F:\1.Music\alarm\Metallica - Orion.mp3"
Gosub, timer
}
return
MenuAlarms:
start_timer_7m:
start_timer_10m:
start_timer_15m:
start_timer_20m:
start_timer_30m:
start_timer_60m:
RegExMatch(A_ThisLabel,"i)_(\d+)m", t)
TIME:=t1
alarm_text:= "• Timer •`n" t1 " min."
GuiControl,1:Text, ComboBox1, %alarm_text%
Gui, Submit, Nohide
Gui, Destroy
Gosub, show_time
#SingleInstance off
TIME:=t1
FormatTime, start_timer,, HH:mm:ss
seconds:= StrLen(TIME)<4 ? TIME * 60 : SubStr(TIME, -1 ) * 60 + SubStr(TIME, 1,2 ) * 3600
TIME_min:= StrLen(TIME)<4 ? TIME : SubStr(TIME, 1,2 ) "h " SubStr(TIME, -1 ) ""
time_count= %seconds%
start_time:=A_TickCount
SetTimer, count_time, 998 ;1000
SetTimer, compare_time, 1000
return
3GuiContextMenu:
Menu, ContextMenu, Show, %A_GuiX%, %A_GuiY%
Return
Open_ini:
Run, %settings_ini%
return
guiclose:
exitapp
Exit_Gui:
;MsgBox,,, ` Exit Alarm Timer `n(after double click on tray icon) ,1
MsgBox, 4,, ` Stop Exit of Alarm Timer in 3 sec.?, 3
IfMsgBox, No
exitapp
IfMsgBox, Yes
{
return
}else{
exitapp
}
return
OnExit, exit
return
;Esc::
exit:
SoundSet, % loudness_start
ExitApp
Stopper
Code: Select all
#SingleInstance off
;#NoTrayIcon
/*
=== Drozd stopper
-- top left circle = reset
-- double click = pause
-- tray icon shows 2 timers: countdown and time compare, and the difference (timer is not precise ==> so it's set to 998 not 1000 ms )
-- the difference is caused also by standby mode
*/
Menu, Tray, Icon, imageres.dll,181 ;shell32.dll, 3
;Menu, Tray, Add , Edit Scite, Edit_Scite
;Menu, Tray, Add , Edit Notepad, Edit_Notepad
Menu, Tray, Add , diff_zero, diff_zero
Menu, Tray, Add
Menu, Tray, Add, Reload , Reload
Menu, Tray, Add, Exit , exit ; double click tray icon to exit
Menu, Tray, Default, Exit
Menu, ContextMenu, Add, On Top, OnTop
Menu, ContextMenu, Icon, On Top, Shell32.dll, 248
Menu, ContextMenu, Add,
Menu, ContextMenu, Add, Reset, reset
Menu, ContextMenu, Add, Pause, pause
Menu, ContextMenu, Add
Menu, ContextMenu, Add, Reload , Reload
Menu, ContextMenu, Add, Exit , Exit
Menu, ContextMenu, Icon, Exit, shell32.dll, 132
SysGet, MonitorWorkArea, MonitorWorkArea, 1
x:=A_ScreenWidth - 90 - 16
y:= MonitorWorkAreaBottom -175
time_count:=0
global started:=true
old_diff:=""
Gui,1: +ToolWindow -border +AlwaysOnTop +HwndGuiHwnd
WonTop:=1
Gui,1:Color, 120F00
Gui,1: Font, S8 cD0D0D0
Gui,1: Add, Text , x2 y+-2 w13 h13 greset , ●
Gui,1: Font, S6 w700 cD0D0D0,Tahoma
Gui,1: Add, Text , x88 y1 w8 h8 gexit Center , X
;Gui,1: Font, S6 cD0D0D0
;Gui,1: Add, Text , x+2 y2 gpause , ▮▮
Gui,1: Font, S8 cD0D0D0 w700, Tahoma ;
Gui,1: Add, Text , x18 y8 w60 cFFFFFF vShow_timer Center,
OnMessage(0x201, "WM_LBUTTONDOWN") ; movable borderless window
OnMessage(0x203,"WM_LBUTTONDBLCLK")
Gui,1:Show, x%x% y%y% w90 h24 , Drozd_stoper
Winset, Transparent,200, Drozd_stoper
WinSet, Style, -0xC00000, Drozd_stoper ; COMPLETELY remove window border
SetTimer, count_time, 998
;SetTimer, count_time, 1000
Sleep,200
SetTimer, compare_time, 1000
Gosub, start_time
return
WM_LBUTTONDOWN(){
if (A_Gui=1){
PostMessage, 0xA1, 2 ; movable borderless window
}
}
WM_LBUTTONDBLCLK(){
Gosub, pause
}
reset:
time_count:=0
;old_diff:=""
Gosub, start_time
GuiControl, , Show_timer , % "00:00"
return
count_time:
time_count:=time_count+1
;time_count_show:= (time_count>60) ? Floor(time_count/60) "m " mod(time_count,60) "s" : time_count "s"
s_count:=mod(time_count,60)
m_count:=time_count>3600 ? Floor(mod(time_count,3600)/60) : Floor(time_count/60)
h_count:=Floor(time_count/3600)
if(mod(time_count,60)==0){
;Gosub, Col_red
}
time_count_show:= time_count>3600 ? dig(h_count) ":" dig(m_count) ":" dig(s_count) : dig(m_count) ":" dig(s_count)
GuiControl, , Show_timer , % time_count_show
;Menu, Tray,Tip , % "count: " time_count_show "`nstart: " h0 ":" m0 ":" s0
return
compare_time:
;-----------------------------
time_compare_2 := Round((A_TickCount - start_time_TickCount)/1000)
compare_timeLeft_h := Floor(time_compare_2/3600)
compare_timeLeft_m := time_compare_2>3600 ? Floor(mod(time_compare_2,3600)/60) : Floor(time_compare_2/60)
compare_timeLeft_s := Floor(mod(time_compare_2,60))
;time_compare_show:= time_compare>3600 ? dig(h) " : " dig(m) " : " dig(s) : dig(m) " : " dig(s)
time_compare_2_show:=compare_timeLeft_h >0 ? dig(compare_timeLeft_h) ":" dig(compare_timeLeft_m) ":" dig(compare_timeLeft_s) : dig(compare_timeLeft_m) ":" dig(compare_timeLeft_s)
;-----------------------------
diff:= Abs(time_count - time_compare_2)
tray_tip:="count: " time_count_show "`n" "compare: " time_compare_2_show "`nstart time: " h0 ":" m0 ":" s0 "`ndifference: " format_sec(diff)
Menu, Tray,Tip , % tray_tip
return
start_time:
RegExMatch(A_Now,"(\d\d)(\d\d)(\d\d)$", d)
h0:=d1, m0:=d2, s0:= d3
start_time_TickCount:=A_TickCount
return
dig(num){ ;to_two_digits
num:= num<=9 ? "0" . num : num
return num
}
format_sec(seconds){ ;
h := Floor(seconds/3600)
m := seconds>3600 ? Floor(mod(seconds,3600)/60) : Floor(seconds/60)
s := Floor(mod(seconds,60))
show:=h >0 ? dig(h) ":" dig(m) ":" dig(s) : dig(m) ":" dig(s)
return show
}
pause:
if(started){
started:=false
SetTimer, count_time, Off
}else if(!started){
started:=true
SetTimer, count_time, 1000
}
return
Col_red:
CustomColor2 = 7A0218
Gui, Color, c%CustomColor2%
Winset, Transcolor, %InvertedColor% 200, Drozd_stoper
SetTimer, col_reset, 400
return
col_reset:
SetTimer, col_reset, Off
Gui, Color, c%CustomColor%
Winset, Transcolor, %InvertedColor% 200, Drozd_stoper
return
diff_zero:
if(diff>60){
old_diff:=old_diff " | " format_sec(diff)
}
time_count := time_compare_2
return
Edit_Notepad:
Run, "C:\Program Files\Notepad2\Notepad2.exe" "%A_ScriptFullPath%"
return
Edit_Scite:
Run, "C:\Program Files\AutoHotkey\SciTE\SciTE.exe" "%A_ScriptFullPath%"
return
;^d:: Gosub, pause
onTop:
if WonTop {
WinSet, AlwaysOnTop, off, Drozd_stoper
GuiControl, Show, onTop_off
GuiControl, Hide, onTop_on
WonTop:=0
}else{
WinSet, AlwaysOnTop, on, Drozd_stoper
GuiControl, Show, onTop_on
GuiControl, Hide, onTop_off
WonTop:=1
}
DllCall( "AnimateWindow", "Int", GuiHwnd, "Int", 300, "Int", 0x00010010 )
DllCall( "AnimateWindow", "Int", GuiHwnd, "Int", 300, "Int", 0x00000010 )
return
Reload:
Reload
return
GuiContextMenu:
Menu, ContextMenu, Show, %A_GuiX%, %A_GuiY%
Return
exit:
GuiClose:
ExitApp
;Esc:: ExitApp
Code: Select all
#SingleInstance off
/*
=== Drozd Alarm_timer_auto
-- run from another program with line: Run, Alarm_timer_auto.ahk "minutes" "text" "no beep"
-- or Alarm_timer_auto.ahk 5
-- 3 parameters: 1: minutes, 2: message 3: no beep
-- choose alarm sound: alarm_sound:="C:\sound\alarm.mp3"
-- tray icon shows 2 timers: countdown and time compare, and the difference (timer is not precise ==> so it's set to 998 not 1000 ms )
-- double click on tray icon = exit
*/
Menu, Tray,Tip , Alarm Timer
;Menu, Tray, Icon, wmploc.dll, 21
Menu, Tray, Icon, shell32.dll,266
;Menu, Tray, Add , Edit Scite, Edit_Scite
;Menu, Tray, Add , Edit Notepad, Edit_Notepad
;Menu, Tray, Icon, C:\Program Files\Misc\AutoHotkey Scripts\icons\Alarm-clock.ico
Menu, Tray, Add, Exit Alarm Timer, Exit_Gui ; double click tray icon to exit
Menu, Tray, Default, Exit Alarm Timer
;Run \Alarm_timer_auto.ahk "minutes" "text" ["no beep"]
alarm_sound:="C:\WINDOWS\Media\chimes.wav" ;"C:\Program Files\Misc\AutoHotkey Scripts\sound\Cuckoo4.wav"
text:=""
start_time:=1
param1= %1%
param2= %2%
param3= %3%
if(param1){
start_time=%param1%
}
if(!param2){
param2:=start_time " min"
}
if(param2){
text=%param2%
}
if(param3){
no_beep=true
}
SysGet, MonitorWorkArea, MonitorWorkArea, 1
x:=A_ScreenWidth - 70 - 66
y:= MonitorWorkAreaBottom -172
CustomColor = 120F00
InvertedColor = EDF0FF
;------------------- TIMER ----------------------------------------------------
Gui,submit,nohide
Gui,destroy
Gosub, show_time
#SingleInstance off
#persistent
TIME_min= %start_time%
;seconds:= StrLen(TIME)<4 ? TIME * 60 : SubStr(TIME, -1 ) * 60 + SubStr(TIME, 1,2 ) * 3600
seconds:=TIME_min* 60
time_count= %seconds%
start_time:=A_TickCount
SetTimer, count_time, 998 ;1000
SetTimer, compare_time, 1000
return
count_time:
time_count:=time_count-1
count_timeLeft_h := Floor(time_count/3600)
count_timeLeft_m := time_count>3600 ? Floor(mod(time_count,3600)/60) : Floor(time_count/60)
count_timeLeft_s := Floor(mod(time_count,60))
count_time_left:=count_timeLeft_h >0 ? dig(count_timeLeft_h) ":" dig(count_timeLeft_m) ":" dig(count_timeLeft_s) : "` " dig(count_timeLeft_m) ":" dig(count_timeLeft_s)
time_left_2:=count_timeLeft_m " : " dig(count_timeLeft_s)
if(time_count=0){
SetTimer, count_time, Off
}
return
compare_time:
time_compare := Round((A_TickCount - start_time)/1000)
;ToolTip, % time_compare_show
time_compare:=seconds-time_compare
compare_timeLeft_h := Floor(time_compare/3600)
compare_timeLeft_m := time_compare>3600 ? Floor(mod(time_compare,3600)/60) : Floor(time_compare/60)
compare_timeLeft_s := Floor(mod(time_compare,60))
;time_compare_show:= time_compare>3600 ? dig(h) " : " dig(m) " : " dig(s) : dig(m) " : " dig(s)
time_compare_show:=compare_timeLeft_h >0 ? dig(compare_timeLeft_h) ":" dig(compare_timeLeft_m) ":" dig(compare_timeLeft_s) : dig(compare_timeLeft_m) ":" dig(compare_timeLeft_s)
tray_tip:="count: " count_time_left "`n" "compare: " time_compare_show "`ntime: " TIME_min " min"
;diff:=
Menu, Tray,Tip , % tray_tip ;"`ndiff: " diff " " m_count " " d2
GuiControl,3:, Show_timer, %time_compare_show%
if(time_compare<=0){
SetTimer, compare_time, Off
Gosub, alarm
}
return
dig(num){ ;to_two_digits
num:= num<=9 ? "0" . num : num
return num
}
alarm:
if(no_beep){
SoundPlay *48
SoundPlay, %alarm_sound%
Msgbox,,, %text% ,30
}else{
SoundBeep,800,100
SoundBeep,800,200
SoundPlay *48
SoundPlay,%alarm_sound%
Msgbox,,, %text% ,3
}
exitapp
WM_LBUTTONDOWN(){
PostMessage, 0xA1, 2 ; movable borderless window
}
show_time:
Gui,3: +ToolWindow -border +AlwaysOnTop
Gui,3:Color, %CustomColor% ;120F00
Gui,3: Font, S8 W700 , Tahoma ;Segoe UI Verdana
Gui,3: Add, Text , x0 y4 w52 cFFFFFF vShow_timer Center,
Gui,3: Font, S6 cD0D0D0
;Gui,3: Add, Text , x69 y+-21 w60 gshow_time_exit , x
Gui,3:Show, x%x% y%y% w44 h16 NA, Show_timer - Drozd
Winset, Transparent,200, Show_timer - Drozd
WinSet, Style, -0xC00000,Show_timer - Drozd ; COMPLETELY remove window border
OnMessage(0x201, "WM_LBUTTONDOWN") ; movable borderless window
return
show_time_exit:
Gui,3: Destroy
return
Edit_Notepad:
Run, "C:\Program Files\Notepad2\Notepad2.exe" "%A_ScriptFullPath%"
return
Edit_Scite:
Run, "C:\Program Files\AutoHotkey\SciTE\SciTE.exe" "%A_ScriptFullPath%"
return
Exit_Gui:
MsgBox,,, ` Exit Alarm Timer `n(after double click on tray icon) ,1
exitapp
Snipping Tool (quick screenshots)
Code: Select all
/*
• includes functions from Gdip.ahk library from http://www.autohotkey.com/board/topic/29449-gdi-standard-library-145-by-tic/
• To capture a screenshot drag mouse while holding right shift key
• Each screenshot opens its own window from which it can be saved
• Windows + g , ctrl + g - take a screenshot
• ctrl + h ; Windows + H - take a screenshot from a window (enter window name in the input box)
#g:: Gosub, full_screen
^g:: Gosub, full_screen
#h:: Gosub, FromWindow
^h:: Gosub, FromWindow
*/
#SingleInstance force
SoundPlay *48
Menu, Tray, Icon,Shell32.dll,241
Menu, Tray, Add , E&dit Scite, Edit_Scite
Menu, Tray, Add , E&dit Notepad, Edit_Notepad
Menu, Tray, Add, Exit Screen Capture, Exit_Gui ; double click tray icon to exit
Menu, Tray, Default, Exit Screen Capture
Work_Dir := "C:\Temp\"
;Work_Dir = %temp%
SetWorkingDir, %Work_Dir%
IfNotExist Screenshots
FileCreateDir, Screenshots
folder_path := A_WorkingDir . "\Screenshots\"
index :=2
OnMessage(0x14, "WM_ERASEBKGND")
Gui, -Caption +ToolWindow
Gui, +LastFound
WinSet, TransColor, Black
; Create the pen here so we don't need to create/delete it every time.
RedPen := DllCall("CreatePen", "int", PS_SOLID:=0, "int", 5, "uint", 0xff)
return
RShift & LButton::
Shift & LButton::
CoordMode, Mouse, Screen
MouseGetPos, begin_x, begin_y
MouseGetPos, xorigin, yorigin
SetTimer, rectangle, 10
KeyWait, LButton
SetTimer, rectangle, Off
Gui, Cancel
MouseGetPos, end_x, end_y
if (end_x > begin_x AND end_y > begin_y){
;file%index% := folder_path "screenshot x" begin_x ",y" begin_y " width" Abs(end_x-begin_x) ", height" Abs(end_y-begin_y) ".png"
;screen := begin_x . "|" . begin_y . "|" . Abs(end_x-begin_x) . "|" Abs(end_y-begin_y) ; X|Y|W|H
Capture_x:=begin_x
Capture_y:=begin_y
}else if (end_x < begin_x AND end_y < begin_y){
Capture_x:=end_x
Capture_y:=end_y
}else if (end_x < begin_x AND end_y > begin_y){
Capture_x:=end_x
Capture_y:=begin_y
}else if (end_x > begin_x AND end_y < begin_y){
Capture_x:=begin_x
Capture_y:=end_y
}
Capture_width:=Abs(end_x-begin_x)
Capture_height:= Abs(end_y-begin_y)
screen := Capture_x . "|" . Capture_y . "|" . Capture_width . "|" Capture_height ; X|Y|W|H
;file%index% := folder_path "screenshot x" Capture_x ",y" Capture_y " width" Capture_width ", height" Capture_height ".png"
;file%index% := folder_path "screenshot " A_Now_Format(A_Now) ", w" Capture_width " h" Capture_height ".png"
file%index% := folder_path "screenshot " A_Now_Format(A_Now) ".png"
x:=file%index%
Screenshot(x,screen)
sleep 300
Gosub, makeGUI
return
rectangle:
CoordMode, Mouse, Screen
MouseGetPos, x2, y2
; Has the mouse moved?
if (x1 y1) = (x2 y2)
return
; Allow dragging to the left of the click point.
if (x2 < xorigin) {
x1 := x2
x2 := xorigin
} else
x1 := xorigin
; Allow dragging above the click point.
if (y2 < yorigin) {
y1 := y2
y2 := yorigin
} else
y1 := yorigin
Gui, Show, % "NA X" x1 " Y" y1 " W" x2-x1 " H" y2-y1
Gui, +LastFound
DllCall("RedrawWindow", "uint", WinExist(), "uint", 0, "uint", 0, "uint", 5)
return
full_screen:
file%index% := folder_path "screenshot " A_Now_Format(A_Now) ".png"
x:=file%index%
screen := 0 . "|" . 0 . "|" . A_ScreenWidth . "|" A_ScreenHeight ; X|Y|W|H
Screenshot(x,screen)
sleep 300
Gosub, makeGUI
return
makeGUI:
;Gui,%index% : +LastFound +Resize +Minsize400x330 ; +AlwaysOnTop
Gui,%index%: Color, 6B8590
Gui,%index%: Margin,0,0
Gui,%index%: Add, Picture, x10 y4 w16 h16 gSave Icon259 AltSubmit, shell32.dll ;
Gui,%index%: Add, Picture, x40 y4 w16 h16 gSave_2 Icon24 AltSubmit, imageres.dll ;
file_GUI:= file%index%
;MsgBox, , , % "makeGUI: " index " - " file1
Gui,%index%: Add, Picture, x0 y24 , %file_GUI%
Gui,%index%: Show,, Screenshots - Drozd
index+=1
return
Save:
;File_num:= "C:\a\My File" A_Gui ".png"
File_num:= file%A_Gui%
;FileSelectFile, FileName , S, %File_num%.png , Save As, Image Files (*.png) ;C:\a\My File.png
FileSelectFile, FileName , S, %File_num% , Save As, Image Files (*.png)
file:=file%A_Gui%
;FileCopy, %file%, %FileName%
FileCopy, %file%, %FileName%.png ;Feb5 2018
return
Save_2:
File_num:= file%A_Gui%
;FileSelectFile, FileName , S, %File_num%.png , Save As, Image Files (*.png)
FileSelectFile, FileName , S, %File_num% , Save As, Image Files (*.png)
file:=file%A_Gui%
;======================== compress with pngquanti
CompressPNG := "C:\Program Files\Misc\PNGquant\libs\pngquanti\pngquanti.exe" ; path to pngquant
RunWait , %CompressPNG% "%file%"
RegExMatch(file,"^(.*)\.png$", f)
file:= f1 . "-fs8.png"
;MsgBox, , , % file "`n" FileName
;FileCopy, %file%, %FileName%
FileCopy, %file%, %FileName%.png
;========================
return
#g:: Gosub, full_screen
#h:: Gosub, FromWindow
^g:: Gosub, full_screen
^h:: Gosub, FromWindow
FromWindow:
InputBox, window , Window Title, Enter Window Title, , 300, 100,,,,,ahk_class OperaWindowClass
dat:= A_Now_Format(A_Now)
;file := folder_path "screenshot ”" window "” " A_Now_Format(A_Now) ".png"
file%index%:= folder_path "screenshot ”" window "” " A_Now_Format(A_Now) ".png"
ID:= WinExist(window)
y:=file%index%
ClipFromWindow(y,ID)
Gosub, makeGUI
index+=1
return
ClipFromWindow(outfile, ID) {
pToken := Gdip_Startup()
pBitmap:=Gdip_BitmapFromHWND(ID)
Gdip_SaveBitmapToFile(pBitmap, outfile, 80)
Gdip_DisposeImage(pBitmap)
Gdip_Shutdown(pToken)
}
Screenshot(outfile, screen) {
pToken := Gdip_Startup()
raster := 0x40000000 + 0x00CC0020
pBitmap := Gdip_BitmapFromScreen(screen,raster)
Gdip_SaveBitmapToFile(pBitmap, outfile, 80)
Gdip_DisposeImage(pBitmap)
Gdip_Shutdown(pToken)
}
A_Now_Format(raw){
RegExMatch(raw,"^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})", d)
date:=d1 "-" d2 "-" d3 " " d4 "-" d5 "-" d6
return date
}
WM_ERASEBKGND(wParam, lParam)
{
global x1, y1, x2, y2, RedPen
Critical 50
if A_Gui = 1
{
; Retrieve stock brush.
blackBrush := DllCall("GetStockObject", "int", BLACK_BRUSH:=0x4)
; Select pen and brush.
oldPen := DllCall("SelectObject", "uint", wParam, "uint", RedPen)
oldBrush := DllCall("SelectObject", "uint", wParam, "uint", blackBrush)
; Draw rectangle.
DllCall("Rectangle", "uint", wParam, "int", 0, "int", 0, "int", x2-x1, "int", y2-y1)
; Reselect original pen and brush (recommended by MS).
DllCall("SelectObject", "uint", wParam, "uint", oldPen)
DllCall("SelectObject", "uint", wParam, "uint", oldBrush)
return 1
}
}
;=======
OnExit:
Exit_Gui:
MsgBox,,, ` Exit ,1
FileDelete, %folder_path%*.png
exitapp
return
;=======
;Esc:: Gosub, Exit
Edit_Notepad:
Run, "C:\Program Files\Misc\Notepad2\Notepad2.exe" "%A_ScriptFullPath%"
return
Edit_Scite:
Run, "C:\Program Files\AutoHotkey\SciTE\SciTE.exe" "%A_ScriptFullPath%"
return
Exit:
FileDelete, %folder_path%*.png
;FileRecycle, %folder_path%*.png
;FileRemoveDir,%folder_path%, 1
ExitApp
return
;#Include C:\AutoHotkey Scripts\AHK_Library\Gdip_All.ahk
;#Include C:\AutoHotkey Scripts\functions_Gdip_All.ahk
Gdip_Startup()
{
Ptr := A_PtrSize ? "UPtr" : "UInt"
if !DllCall("GetModuleHandle", "str", "gdiplus", Ptr)
DllCall("LoadLibrary", "str", "gdiplus")
VarSetCapacity(si, A_PtrSize = 8 ? 24 : 16, 0), si := Chr(1)
DllCall("gdiplus\GdiplusStartup", A_PtrSize ? "UPtr*" : "uint*", pToken, Ptr, &si, Ptr, 0)
return pToken
}
Gdip_Shutdown(pToken)
{
Ptr := A_PtrSize ? "UPtr" : "UInt"
DllCall("gdiplus\GdiplusShutdown", Ptr, pToken)
if hModule := DllCall("GetModuleHandle", "str", "gdiplus", Ptr)
DllCall("FreeLibrary", Ptr, hModule)
return 0
}
Gdip_BitmapFromHWND(hwnd)
{
WinGetPos,,, Width, Height, ahk_id %hwnd%
hbm := CreateDIBSection(Width, Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
PrintWindow(hwnd, hdc)
pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
return pBitmap
}
Gdip_SaveBitmapToFile(pBitmap, sOutput, Quality=75)
{
Ptr := A_PtrSize ? "UPtr" : "UInt"
SplitPath, sOutput,,, Extension
if Extension not in BMP,DIB,RLE,JPG,JPEG,JPE,JFIF,GIF,TIF,TIFF,PNG
return -1
Extension := "." Extension
DllCall("gdiplus\GdipGetImageEncodersSize", "uint*", nCount, "uint*", nSize)
VarSetCapacity(ci, nSize)
DllCall("gdiplus\GdipGetImageEncoders", "uint", nCount, "uint", nSize, Ptr, &ci)
if !(nCount && nSize)
return -2
If (A_IsUnicode){
StrGet_Name := "StrGet"
Loop, %nCount%
{
sString := %StrGet_Name%(NumGet(ci, (idx := (48+7*A_PtrSize)*(A_Index-1))+32+3*A_PtrSize), "UTF-16")
if !InStr(sString, "*" Extension)
continue
pCodec := &ci+idx
break
}
} else {
Loop, %nCount%
{
Location := NumGet(ci, 76*(A_Index-1)+44)
nSize := DllCall("WideCharToMultiByte", "uint", 0, "uint", 0, "uint", Location, "int", -1, "uint", 0, "int", 0, "uint", 0, "uint", 0)
VarSetCapacity(sString, nSize)
DllCall("WideCharToMultiByte", "uint", 0, "uint", 0, "uint", Location, "int", -1, "str", sString, "int", nSize, "uint", 0, "uint", 0)
if !InStr(sString, "*" Extension)
continue
pCodec := &ci+76*(A_Index-1)
break
}
}
if !pCodec
return -3
if (Quality != 75)
{
Quality := (Quality < 0) ? 0 : (Quality > 100) ? 100 : Quality
if Extension in .JPG,.JPEG,.JPE,.JFIF
{
DllCall("gdiplus\GdipGetEncoderParameterListSize", Ptr, pBitmap, Ptr, pCodec, "uint*", nSize)
VarSetCapacity(EncoderParameters, nSize, 0)
DllCall("gdiplus\GdipGetEncoderParameterList", Ptr, pBitmap, Ptr, pCodec, "uint", nSize, Ptr, &EncoderParameters)
Loop, % NumGet(EncoderParameters, "UInt") ;%
{
elem := (24+(A_PtrSize ? A_PtrSize : 4))*(A_Index-1) + 4 + (pad := A_PtrSize = 8 ? 4 : 0)
if (NumGet(EncoderParameters, elem+16, "UInt") = 1) && (NumGet(EncoderParameters, elem+20, "UInt") = 6)
{
p := elem+&EncoderParameters-pad-4
NumPut(Quality, NumGet(NumPut(4, NumPut(1, p+0)+20, "UInt")), "UInt")
break
}
}
}
}
if (!A_IsUnicode)
{
nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sOutput, "int", -1, Ptr, 0, "int", 0)
VarSetCapacity(wOutput, nSize*2)
DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sOutput, "int", -1, Ptr, &wOutput, "int", nSize)
VarSetCapacity(wOutput, -1)
if !VarSetCapacity(wOutput)
return -4
E := DllCall("gdiplus\GdipSaveImageToFile", Ptr, pBitmap, Ptr, &wOutput, Ptr, pCodec, "uint", p ? p : 0)
}
else
E := DllCall("gdiplus\GdipSaveImageToFile", Ptr, pBitmap, Ptr, &sOutput, Ptr, pCodec, "uint", p ? p : 0)
return E ? -5 : 0
}
Gdip_DisposeImage(pBitmap)
{
return DllCall("gdiplus\GdipDisposeImage", "uint", pBitmap)
}
Gdip_BitmapFromScreen(Screen=0, Raster="")
{
if (Screen = 0)
{
Sysget, x, 76
Sysget, y, 77
Sysget, w, 78
Sysget, h, 79
}
else if (SubStr(Screen, 1, 5) = "hwnd:")
{
Screen := SubStr(Screen, 6)
if !WinExist( "ahk_id " Screen)
return -2
WinGetPos,,, w, h, ahk_id %Screen%
x := y := 0
hhdc := GetDCEx(Screen, 3)
}
else if (Screen&1 != "")
{
Sysget, M, Monitor, %Screen%
x := MLeft, y := MTop, w := MRight-MLeft, h := MBottom-MTop
}
else
{
StringSplit, S, Screen, |
x := S1, y := S2, w := S3, h := S4
}
if (x = "") || (y = "") || (w = "") || (h = "")
return -1
chdc := CreateCompatibleDC(), hbm := CreateDIBSection(w, h, chdc), obm := SelectObject(chdc, hbm), hhdc := hhdc ? hhdc : GetDC()
BitBlt(chdc, 0, 0, w, h, hhdc, x, y, Raster)
ReleaseDC(hhdc)
pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
SelectObject(chdc, obm), DeleteObject(hbm), DeleteDC(hhdc), DeleteDC(chdc)
return pBitmap
}
CreateDIBSection(w, h, hdc="", bpp=32, ByRef ppvBits=0)
{
Ptr := A_PtrSize ? "UPtr" : "UInt"
hdc2 := hdc ? hdc : GetDC()
VarSetCapacity(bi, 40, 0)
NumPut(w, bi, 4, "uint")
, NumPut(h, bi, 8, "uint")
, NumPut(40, bi, 0, "uint")
, NumPut(1, bi, 12, "ushort")
, NumPut(0, bi, 16, "uInt")
, NumPut(bpp, bi, 14, "ushort")
hbm := DllCall("CreateDIBSection"
, Ptr, hdc2
, Ptr, &bi
, "uint", 0
, A_PtrSize ? "UPtr*" : "uint*", ppvBits
, Ptr, 0
, "uint", 0, Ptr)
if !hdc
ReleaseDC(hdc2)
return hbm
}
CreateCompatibleDC(hdc=0)
{
return DllCall("CreateCompatibleDC", "uint", hdc)
}
SelectObject(hdc, hgdiobj)
{
return DllCall("SelectObject", "uint", hdc, "uint", hgdiobj)
}
PrintWindow(hwnd, hdc, Flags=0)
{
return DllCall("PrintWindow", "uint", hwnd, "uint", hdc, "uint", Flags)
}
Gdip_CreateBitmapFromHBITMAP(hBitmap, Palette=0)
{
Ptr := A_PtrSize ? "UPtr" : "UInt"
DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", Ptr, hBitmap, Ptr, Palette, A_PtrSize ? "UPtr*" : "uint*", pBitmap)
return pBitmap
}
DeleteObject(hObject)
{
return DllCall("DeleteObject", "uint", hObject)
}
DeleteDC(hdc)
{
return DllCall("DeleteDC", "uint", hdc)
}
GetDCEx(hwnd, flags=0, hrgnClip=0)
{
return DllCall("GetDCEx", "uint", hwnd, "uint", hrgnClip, "int", flags)
}
GetDC(hwnd=0)
{
return DllCall("GetDC", "uint", hwnd)
}
BitBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, Raster="")
{
return DllCall("gdi32\BitBlt", "uint", dDC, "int", dx, "int", dy, "int", dw, "int", dh
, "uint", sDC, "int", sx, "int", sy, "uint", Raster ? Raster : 0x00CC0020)
}
ReleaseDC(hdc, hwnd=0)
{
return DllCall("ReleaseDC", "uint", hwnd, "uint", hdc)
}
;FileCopy, %file%, %FileName%
FileCopy, %file%, %FileName%= DllCall(