Code: Select all
#NoEnv
#SingleInstance force
#Include <DBA>
#Include <hot_strings>
#Include <LinearGradient>
#Include <Class_ImageButton>
#Include %A_ScriptDir%\Lib\WinClipAPI.ahk
#Include %A_ScriptDir%\Lib\WinClip.ahk
SetWorkingDir, %A_ScriptDir%
DetectHiddenWindows, on
; #############################################################################
; Application Data
; #############################################################################
Application := {Name: "Hotkey Manager", Version: "0.1"}
global Window := {Width: 800, Height: 550, Title: Application.Name}
global process_id_handlehotkey := ""
; #############################################################################
; globals
; #############################################################################
global connectionString := A_ScriptDir "\hotkey.sqlite"
global listrow_actualrow := 0
global listrow_maxrow := 0
global DBChanges := 0
global msgbox_owner := 0
global MSGBOXCLOSE
global MSGBOXOK
global MSGBOXCANCEL
global MSGBOXYES
global MSGBOXNO
global DETAILvar :=
global trigger := "\s" replace
; #############################################################################
; GUI
; #############################################################################
Gui,Hotkey: default
BG_Color = 0xFFFFFF
FT_Color = 0x005A8C
FT_Color2 = 0xF9E4C9
TX_Color = 0x333333
TX_Color2 = 0xD6D6D6
ButtonBorderRadius = 0
ButtonBorderThickness = 2
Gui,Hotkey: +0x400000 -Caption +Border
Gui,Hotkey: Margin, 0, 0
Gui,Hotkey: Color, %BG_Color%
Gui,Hotkey: Font, s8 q5 Bold
Gui,Hotkey: Add, Button, gHotkeyGUICLOSE vCLOSE x775 y5 h20 w20 hwndCLOSE center, x
Opt1 := [0, FT_Color,, BG_Color, 0]
Opt2 := [, BG_Color,, FT_Color]
Opt4 := [, BG_Color,, FT_Color2]
Opt5 := [,,, BG_Color]
If !(ImageButton.Create(CLOSE, Opt1, Opt2,, Opt4, Opt5))
MsgBox, 0, ImageButton Error CLOSE, % ImageButton.LastError
Gui,Hotkey: Add, Picture, gHotkeyCaptionClick x0 y0 w830 h63 0x4000000 vPicure hwndHPIC
Colors := [FT_Color, FT_Color]
If !LinearGradient(HPIC, Colors)
MsgBox, 0, Linear Gradient, Funtion failed:`n%ErrorLevel%
Gui,Hotkey: Add, Button, % "x" (Window.Width-100)-108 " y" (Window.Height-36) " w" 80 " h" 24 " gHOTKEYCANCEL vHOTKEYCANCEL hwndHOTKEYCANCEL", % "Abbrechen"
Opt1 := [0, BG_Color,, FT_Color, ButtonBorderRadius,, FT_Color, ButtonBorderThickness]
Opt2 := [, FT_Color,, BG_Color]
Opt4 := [, BG_Color,, FT_Color2]
Opt5 := [,,, FT_Color]
If !(ImageButton.Create(HOTKEYCANCEL, Opt1, Opt2,, Opt4, Opt5))
MsgBox, 0, ImageButton Error HOTKEYCANCEL, % ImageButton.LastError
Gui,Hotkey: Add, Button, % "x" (Window.Width-100)-20 " y" (Window.Height-36) " w" 80 " h" 24 " gHOTKEYOK vHOTKEYOK hwndHOTKEYOK DEFAULT", % "OK"
Opt1 := [0, BG_Color,, FT_Color, ButtonBorderRadius,, FT_Color, ButtonBorderThickness]
Opt2 := [, FT_Color,, BG_Color]
Opt4 := [, BG_Color,, FT_Color2]
Opt5 := [,,, FT_Color]
If !(ImageButton.Create(HOTKEYOK, Opt1, Opt2,, Opt4, Opt5))
MsgBox, 0, ImageButton Error HOTKEYOK, % ImageButton.LastError
Gui,Hotkey: Font, s22 q5 Bold, Arial Narrow
Gui,Hotkey: Add, Text, x310 y15 R1 BackgroundTrans -Wrap Center c%BG_Color%, hotkey
Gui,Hotkey: Font, s22 q5 Normal, Arial Narrow
Gui,Hotkey: Add, Text, x390 y15 R1 BackgroundTrans -Wrap Center c%BG_Color%, Manager
Gui,Hotkey: Font ; Reset font options
Gui,Hotkey: Font, s11, Calibri
Gui,Hotkey: Add, Edit, x5 y70 w790 gFind vSrch1,
; listview
Gui,Hotkey: Add, ListView, x5 y105 w790 h400 Grid gSubLV -LV0x10 hwndHLV1 AltSubmit -multi vLV1, dummy| Hotkey | Ersetzen mit
Gui,Hotkey: Font
Gui,Hotkey: Font, s8 q5 Bold
Gui,Hotkey: Add, Button, % "x" 50 " y" (Window.Height-36) " w" 80 " h" 24 " gHOTKEYDETAIL v1 hwndHOTKEYDETAIL1", % "Hinzufügen"
Opt1 := [0, BG_Color,, FT_Color, ButtonBorderRadius,, FT_Color, ButtonBorderThickness]
Opt2 := [, FT_Color,, BG_Color]
Opt4 := [, BG_Color,, FT_Color2]
Opt5 := [,,, FT_Color]
If !(ImageButton.Create(HOTKEYDETAIL1, Opt1, Opt2,, Opt4, Opt5))
MsgBox, 0, ImageButton Error HOTKEYDETAIL1, % ImageButton.LastError
Gui,Hotkey: Add, Button, % "x" 140 " y" (Window.Height-36) " w" 80 " h" 24 " gHOTKEYDETAIL v5 hwndHOTKEYDETAIL2", % "Ändern"
Opt1 := [0, BG_Color,, FT_Color, ButtonBorderRadius,, FT_Color, ButtonBorderThickness]
Opt2 := [, FT_Color,, BG_Color]
Opt4 := [, BG_Color,, FT_Color2]
Opt5 := [,,, FT_Color]
If !(ImageButton.Create(HOTKEYDETAIL2, Opt1, Opt2,, Opt4, Opt5))
MsgBox, 0, ImageButton Error HOTKEYDETAIL2, % ImageButton.LastError
Gui,Hotkey: Add, Button, % "x" 230 " y" (Window.Height-36) " w" 80 " h" 24 " gHOTKEYDELETE v3 hwndHOTKEYDELETE", % "Löschen"
Opt1 := [0, BG_Color,, FT_Color, ButtonBorderRadius,, FT_Color, ButtonBorderThickness]
Opt2 := [, FT_Color,, BG_Color]
Opt4 := [, BG_Color,, FT_Color2]
Opt5 := [,,, FT_Color]
If !(ImageButton.Create(HOTKEYDELETE, Opt1, Opt2,, Opt4, Opt5))
MsgBox, 0, ImageButton Error HOTKEYDELETE, % ImageButton.LastError
Gui,Hotkey: Font
;hide first column
LV_ModifyCol(1, 0)
;set width of columns
lv_modifycol(2, 200)
lv_modifycol(3, 585)
Gui,DETAIL: +0x400000 -Caption +Border
Gui,DETAIL: Margin, 0, 0
Gui,DETAIL: Color, %BG_Color%
Gui,DETAIL: Font, s10 q5 Bold
Gui,DETAIL: Add, Button, gDETAILClose vDETAILCLOSE x375 y5 h20 w20 hwndDETAILCLOSE center, x
Opt1 := [0, FT_Color,, BG_Color, 0]
Opt2 := [, BG_Color,, FT_Color]
Opt4 := [, BG_Color,, FT_Color2]
Opt5 := [,,, BG_Color]
If !(ImageButton.Create(DETAILCLOSE, Opt1, Opt2,, Opt4, Opt5))
MsgBox, 0, ImageButton Error DETAILCLOSE, % ImageButton.LastError
Gui,DETAIL: Add, Picture, gCaptionClick2 x0 y0 w460 h63 0x4000000 vPicture2 hwndHPIC2
Colors := [FT_Color, FT_Color]
If !LinearGradient(HPIC2, Colors)
MsgBox, 0, Linear Gradient, Funtion failed:`n%ErrorLevel%
Gui,DETAIL: Font, s10 q5 Normal
Gui,DETAIL: Add, EDIT, x50 y75 w300 h20 c%TX_Color% vHotkey1,
Gui,DETAIL: Add, EDIT, x50 y110 w300 h180 c%TX_Color% vHotkey2,
Gui,DETAIL: Add, Text, x50 y300 w300 h50, Tipp: Zeilenumbruch mit "\n"
Gui,DETAIL: Font, s8 q5 Bold
Gui,DETAIL: Add, Button, gDETAILCancel vDETAILCancel x175 y360 w100 h24 hwndDETAILCancel , Abbrechen
Opt1 := [0, BG_Color,, FT_Color, ButtonBorderRadius,, FT_Color, ButtonBorderThickness]
Opt2 := [, FT_Color,, BG_Color]
Opt4 := [, BG_Color,, FT_Color2]
Opt5 := [,,, FT_Color]
If !(ImageButton.Create(DETAILCancel, Opt1, Opt2,, Opt4, Opt5))
MsgBox, 0, ImageButton Error DETAILCancel, % ImageButton.LastError
Gui,DETAIL: Add, Button, gDETAILOK vDETAILOK x285 y360 w100 h24 hwndDETAILOK Default, OK
Opt1 := [0, BG_Color,, FT_Color, ButtonBorderRadius,, FT_Color, ButtonBorderThickness]
Opt2 := [, FT_Color,, BG_Color]
Opt4 := [, BG_Color,, FT_Color2]
Opt5 := [,,, FT_Color]
If !(ImageButton.Create(DETAILOK, Opt1, Opt2,, Opt4, Opt5))
MsgBox, 0, ImageButton Error DETAILOK, % ImageButton.LastError
Gui,DETAIL: Font, s22 q5 Bold, Arial Narrow
Gui,DETAIL: Add, Text, x110 y15 R1 BackgroundTrans -Wrap Center c%BG_Color%, Hotkey
Gui,DETAIL: Font, s22 q5 Normal, Arial Narrow
Gui,DETAIL: Add, Text, x195 y15 R1 BackgroundTrans -Wrap vDetailHeader left c%BG_Color%, xxxxxxxxxxx
Gui,DETAIL: Show, w400 h400 HIDE, launcherDETAIL
Read_DB()
Gui,Hotkey: Show, % "hide w" Window.Width " h" Window.Height, % Window.Title
return
; ----- Show Main GUI when WIN+H is pressed -----
#h::
Gui,Hotkey: default
Gui,Hotkey:Show
;msgbox, wait
listrow_actualrow := 0
DBChanges := 0
GuiControl, Hotkey:, srch1,
GuiControl,Hotkey:Focus,srch1
; buggy second call, don' know why
GuiControl, Hotkey:, srch1,
Return
~DEL::
IfWinNotActive, % Window.Title
{
Send, {DEL}
Return
}
ControlGetFocus, CurrCtrl, % Window.Title
IfEqual, CurrCtrl, Edit1
{
gosub,HOTKEYDELETE
}
Return
~Up::
IfWinNotActive, % Window.Title
{
;Send, {Up}
Return
}
ControlGetFocus, CurrCtrl, % Window.Title
IfEqual, CurrCtrl, Edit1
{
ControlSend, SysListView321, {Up}, % Window.Title
listrow_actualrow--
if (listrow_actualrow < 1)
listrow_actualrow := 1
GuiControl,Hotkey:Focus,srch1
}
Return
~Down::
IfWinNotActive, % Window.Title
{
;Send, {Down}
Return
}
ControlGetFocus, CurrCtrl, % Window.Title
IfEqual, CurrCtrl, Edit1
{
ControlSend, SysListView321, {Down}, % Window.Title
listrow_actualrow++
if (listrow_actualrow > listrow_maxrow)
listrow_actualrow := listrow_maxrow
GuiControl,Hotkey:Focus,srch1
}
Return
SubLV:
if ( A_GuiEvent = "Normal") || (A_GuiEvent = "RightClick")
{
Gui,Hotkey:listview, LV1
RowNumber := "0"
RowNumber := LV_GetNext(RowNumber, "Focused") ;Starts searching for the focused row in the listview at row #0 and stores the focused row in the variable %RowNumber%.
listrow_actualrow := RowNumber
GuiControl,Hotkey:Focus,srch1
}
if (A_GuiEvent = "DoubleClick")
{
Gui,Hotkey:listview, LV1
RowNumber := "0"
RowNumber := LV_GetNext(RowNumber, "Focused") ;Starts searching for the focused row in the listview at row #0 and stores the focused row in the variable %RowNumber%.
if RowNumber = 0 ;If there is no row selected in the listview, do nothing.
return
gosub, HOTKEYDETAIL
; LV_GetText(Col1Text, RowNumber, 2) ;Gets the text in row number %RowNumber%, column 1 and saves it in %Col1Text%.
; LV_GetText(Col2Text, RowNumber, 3) ;Gets the text in row number %RowNumber%, column 2 and saves it in %Col2Text%.
; listrow_actualrow := RowNumber
; msgbox, %Col1Text% - %Col2Text%
; GuiControl,Hotkey:Focus,srch1
}
return
HOTKEYOK:
if (DBChanges > 0)
{
show_msgbox("Beenden?", "Wollen Sie alle Änderungen speichern?", 2, 1)
}
else
{
;show_msgbox("Beenden?", "Keine Änderungen. Wirklich beenden?", 2, 2)
gosub, PasteSelection
}
return
PasteSelection:
Gui,Hotkey:listview, LV1
LV_GetText(Col1Text, listrow_actualrow, 2) ;Gets the text in row number %RowNumber%, column 1 and saves it in %Col1Text%.
LV_GetText(Col2Text, listrow_actualrow, 3) ;Gets the text in row number %RowNumber%, column 2 and saves it in %Col2Text%.
StringReplace, Col2Text, Col2Text, \n , `n , All
Gui,Hotkey:HIDE
WinClip.Clear()
WinClip.SetText(Col2Text)
WinClip.Paste()
return
; #############################################################################
; Write Changes to DB
; #############################################################################
Write_Changes_to_DB()
{
; remove old hotstrings
remove_old()
sqldelete := "delete from replace"
do_sql(sqldelete)
sqlinsert := "insert into replace select * from replace_tmp"
do_sql(sqlinsert)
set_hotstrings()
return
}
Rollback_changes_in_DB()
{
sqldelete := "delete from replace_tmp"
do_sql(sqldelete)
sqlinsert := "insert into replace_tmp select * from replace"
do_sql(sqlinsert)
return
}
HotkeyGuiEscape:
HotkeyGuiClose:
HOTKEYCANCEL:
if (DBChanges > 0)
{
;Rollback_changes_in_DB()
;Gui,Hotkey:HIDE
show_msgbox("Beenden?", "Alle Änderungen gehen verloren. `nWirklich beenden?", 2, 2)
}
else
{
Gui,Hotkey:HIDE
}
return
HOTKEYDETAIL:
ControlGetFocus, CurrCtrl, % Window.Title
if (CurrCtrl = "Button4")
{
GuiControl, DETAIL:, Hotkey1,
GuiControl, DETAIL:, Hotkey2,
GuiControl, DETAIL:, DetailHeader, Hinzufügen
DETAILvar := "add"
}
else if (CurrCtrl = "Button5" OR CurrCtrl = "Edit1")
{
GuiControl, DETAIL:, DetailHeader, Ändern
DETAILvar := "modify"
Gui,Hotkey:default
Gui,Hotkey:listview, LV1
if (listrow_actualrow > 0)
{
LV_GetText(Col1Text, listrow_actualrow, 2) ;Gets the text in row number %RowNumber%, column 1 and saves it in %Col1Text%.
LV_GetText(Col2Text, listrow_actualrow, 3) ;Gets the text in row number %RowNumber%, column 2 and saves it in %Col2Text%.
Gui,Detail: +AlwaysonTop
Gui,Detail:listview, LV1
GuiControl, DETAIL:, Hotkey1, %Col1Text%
StringReplace, Col2Text, Col2Text, \n , `n , All
GuiControl, DETAIL:, Hotkey2, %Col2Text%
}
else
{
return
}
}
Gui, Hotkey: +Disabled ;disable the owner
Gui, DETAIL: +OwnerHotkey ;specify the owner.
Gui, DETAIL: Font, s22 q5 Normal, Arial Narrow
Gui, DETAIL: SHOW
GuiControl,DETAIL:Focus,Hotkey1
return
DETAILGuiEscape:
DETAILGuiClose:
DETAILClose:
DETAILCancel:
DETAILvar :=
Gui, Hotkey: -Disabled ;disable the owner
Gui,DETAIL: HIDE
GuiControl,Hotkey:Focus,srch1
Return
DETAILOK:
Gui,Hotkey:default
Gui,DETAIL:submit,nohide
Gui,DETAIL:listview, LV1
if (Hotkey1 ="" OR Hotkey2 = "")
{
show_msgbox("Hotkey leer", "Bitte einen Wert eingeben", 3, 3)
return
}
if (DETAILvar = "add")
{
c1:= % Hotkey1
c2:= % Hotkey2
record := {}
record.hotkey := Hotkey1
StringReplace, Hotkey2, Hotkey2, `n, ``n , All
record.replace := Hotkey2
currentDB1 := DBA.DataBaseFactory.OpenDataBase("SQLite", connectionString)
currentDB1.Insert(record, "replace_tmp")
currentDB1.Close()
VarSetCapacity(currentDB1,0)
listrow_maxrow++
DBChanges++
StringReplace, c2, c2, `n, \n , All
LV_Add("", "", c1,c2)
LV_Modify(listrow_maxrow, "Select")
LV_Modify(listrow_maxrow, "Focus")
listrow_actualrow := listrow_maxrow
}
else if (DETAILvar = "modify")
{
c1:= % Hotkey1
c2:= % Hotkey2
StringReplace, Hotkey2, Hotkey2, `n, ``n , All
sqlupdate := ""
; primary key changed
if (Col1Text <> Hotkey1 AND Col2Text <> Hotkey2)
{
sqlupdate := "UPDATE replace_tmp SET hotkey ='" . Hotkey1 . "', replace = '" . Hotkey2 . "' WHERE hotkey = '" . Col1Text . "';"
}
else if (Col1Text <> Hotkey1)
{
sqlupdate := "UPDATE replace_tmp SET hotkey ='" . Hotkey1 . "' WHERE hotkey = '" . Col1Text . "';"
}
; NON primary key changed
else if (Col2Text <> Hotkey2)
{
sqlupdate := "UPDATE replace_tmp SET replace ='" . Hotkey2 . "' WHERE hotkey = '" . Col1Text . "';"
}
else
{
;msgbox, nothing changed
DETAILvar :=
Gui, Hotkey: -Disabled ;disable the owner
Gui,DETAIL: HIDE
GuiControl,Hotkey:Focus,srch1
return
}
DBChanges++
do_sql(sqlupdate)
StringReplace, C2, C2, `n, \n , All
lv_modify(listrow_actualrow, "col2" , C1 )
lv_modify(listrow_actualrow, "col3" , C2 )
GuiControl,Hotkey:Focus,srch1
}
DETAILvar :=
Gui, Hotkey: -Disabled ;disable the owner
Gui,DETAIL: HIDE
GuiControl,Hotkey:Focus,srch1
return
HOTKEYDELETE:
Gui,Hotkey:default
Gui,Hotkey:listview, LV1
LV_GetText(Col1Text, listrow_actualrow, 2) ;Gets the text in row number %RowNumber%, column 1 and saves it in %Col1Text%.
LV_GetText(Col2Text, listrow_actualrow, 3) ;Gets the text in row number %RowNumber%, column 2 and saves it in %Col2Text%.
LV_Delete(listrow_actualrow)
sqldelete := "delete from replace_tmp where hotkey = '" . Col1Text . "'"
do_sql(sqldelete)
listrow_maxrow--
DBChanges++
LV_Modify(listrow_actualrow-1, "Select")
LV_Modify(listrow_actualrow-1, "Focus")
listrow_actualrow--
if (listrow_actualrow < 1)
listrow_actualrow := 1
GuiControl,Hotkey:Focus,srch1
return
Read_DB()
{
Gui,Hotkey:default
Gui,Hotkey:ListView, LV1
LV_Delete()
sqldelete := "delete from replace_tmp"
do_sql(sqldelete)
currentDB2 := DBA.DataBaseFactory.OpenDataBase("SQLite", connectionString)
rs := currentDB2.OpenRecordSet("Select hotkey, replace from replace")
count_items := 0
while(!rs.EOF)
{
count_items++
db_hotkey := rs["hotkey"]
db_replace := rs["replace"]
StringReplace, db_replace, db_replace, ``n, \n , All
record := {}
record.hotkey := db_hotkey
record.replace := db_replace
currentDB2.Insert(record, "replace_tmp")
LV_Add("", "", db_hotkey,db_replace)
rs.MoveNext()
}
listrow_maxrow := count_items
rs.Close()
currentDB2.Close()
VarSetCapacity(currentDB2,0)
remove_old()
set_hotstrings()
return
}
Find:
listrow_actualrow := 0
Gui,Hotkey: Submit, Nohide
Gui,Hotkey:listview, LV1
LV_Delete()
src:= % srch1
currentDB3 := DBA.DataBaseFactory.OpenDataBase("SQLite", connectionString)
if (SRC = "")
{
rs := currentDB3.OpenRecordSet("Select hotkey, replace from replace_tmp")
}
if (SRC <> "")
{
StringSplit, SRCArray, src, %A_Space%,
sql_searchstring := "Select hotkey, replace from replace_tmp where "
Loop, %SRCArray0%
{
this_src := SRCArray%a_index%
if (this_src <> "")
{
sql_searchstring .= "UPPER(hotkey) like UPPER('%" this_src "%') OR UPPER(replace) like UPPER('%" this_src "%')"
sql_searchstring .= " OR "
}
}
StringTrimRight, sql_searchstring, sql_searchstring, 4
rs := currentDB3.OpenRecordSet(sql_searchstring)
}
count_items := 0
while(!rs.EOF)
{
count_items++
db_hotkey := rs["hotkey"]
db_replace := rs["replace"]
StringReplace, db_replace, db_replace, ``n, \n , All
LV_Add("", "", db_hotkey,db_replace)
rs.MoveNext()
}
listrow_maxrow := count_items
rs.Close()
currentDB3.Close()
VarSetCapacity(currentDB3,0)
GuiControl,Hotkey:Focus,srch1
return
HotkeyCaptionClick:
PostMessage, 0xA1, 2,,, A
Return
CaptionClick2:
PostMessage, 0xA1, 2,,, A
Return
show_msgbox(msgbox_title, msgbox_text, msg_type, msg_owner )
{
BG_Color = 0xFFFFFF
FT_Color = 0x005A8C
FT_Color2 = 0xF9E4C9
TX_Color = 0x333333
TX_Color2 = 0xD6D6D6
ButtonBorderRadius = 0
ButtonBorderThickness = 2
Gui, OwnerMsgBox:+0x400000 -Caption +Border
Gui, OwnerMsgBox:Margin, 0, 0
Gui, OwnerMsgBox:Color, %BG_Color%
Gui, OwnerMsgBox:Font, s7 q5 Bold
Gui, OwnerMsgBox:Add, Button, gMSGBOXGUICLose vMSGBOXCLOSE x325 y5 h20 w20 hwndCLOSE center, x
Opt1 := [0, FT_Color,, BG_Color, 0]
Opt2 := [, BG_Color,, FT_Color]
Opt4 := [, BG_Color,, FT_Color2]
Opt5 := [,,, BG_Color]
If !(ImageButton.Create(CLOSE, Opt1, Opt2,, Opt4, Opt5))
MsgBox, 0, ImageButton Error CLOSE, % ImageButton.LastError
Gui, OwnerMsgBox:Add, Picture, gMSGBOXCaptionClick x0 y0 w380 h63 0x4000000 vPicure hwndHPIC
Colors := [FT_Color, FT_Color]
If !LinearGradient(HPIC, Colors)
MsgBox, 0, Linear Gradient, Funtion failed:`n%ErrorLevel%
Gui, OwnerMsgBox:Add, Picture, x20 y45 0x4000000 w128 h-1 Icon1, %A_ScriptFullPath%
Gui, OwnerMsgBox:Add, Text, x150 y70 c%FT_Color%, %Manufacturer%
Gui, OwnerMsgBox:Font, s11 q5 Normal, Arial
Gui, OwnerMsgBox:Add, Text, x20 y80 R1 c%TX_Color%, %msgbox_text%
Gui,OwnerMsgBox: Font
Gui,OwnerMsgBox: Font, s7 q5 Bold
Gui, OwnerMsgBox:Add, Button, gMSGBOXNO vMSGBOXNO x120 y165 w100 h24 hwndMSGBOXNO, NEIN
Opt1 := [0, BG_Color,, FT_Color, ButtonBorderRadius,, FT_Color, ButtonBorderThickness]
Opt2 := [, FT_Color,, BG_Color]
Opt4 := [, BG_Color,, FT_Color2]
Opt5 := [,,, FT_Color]
If !(ImageButton.Create(MSGBOXNO, Opt1, Opt2,, Opt4, Opt5))
MsgBox, 0, ImageButton Error MSGBOXNO, % ImageButton.LastError
Gui, OwnerMsgBox:Add, Button, gMSGBOXOK vMSGBOXOK x120 y165 w100 h24 hwndMSGBOXOK, OK
Opt1 := [0, BG_Color,, FT_Color, ButtonBorderRadius,, FT_Color, ButtonBorderThickness]
Opt2 := [, FT_Color,, BG_Color]
Opt4 := [, BG_Color,, FT_Color2]
Opt5 := [,,, FT_Color]
If !(ImageButton.Create(MSGBOXOK, Opt1, Opt2,, Opt4, Opt5))
MsgBox, 0, ImageButton Error MSGBOXOK, % ImageButton.LastError
Gui, OwnerMsgBox:Add, Button, gMSGBOXYES vMSGBOXYES x230 y165 w100 h24 hwndMSGBOXYES DEFAULT, JA
Opt1 := [0, BG_Color,, FT_Color, ButtonBorderRadius,, FT_Color, ButtonBorderThickness]
Opt2 := [, FT_Color,, BG_Color]
Opt4 := [, BG_Color,, FT_Color2]
Opt5 := [,,, FT_Color]
If !(ImageButton.Create(MSGBOXYES, Opt1, Opt2,, Opt4, Opt5))
MsgBox, 0, ImageButton Error MSGBOXYES, % ImageButton.LastError
Gui, OwnerMsgBox:Add, Button, gMSGBOXCANCEL vMSGBOXCANCEL x10 y165 w100 h24 hwndMSGBOXCANCEL, CANCEL
Opt1 := [0, BG_Color,, FT_Color, ButtonBorderRadius,, FT_Color, ButtonBorderThickness]
Opt2 := [, FT_Color,, BG_Color]
Opt4 := [, BG_Color,, FT_Color2]
Opt5 := [,,, FT_Color]
If !(ImageButton.Create(MSGBOXCANCEL, Opt1, Opt2,, Opt4, Opt5))
MsgBox, 0, ImageButton Error MSGBOXCANCEL, % ImageButton.LastError
Gui,OwnerMsgBox:Default
if ( msg_type == 1 )
{
GuiControl, HIDE, MSGBOXOK
}
else if ( msg_type == 2 )
{
GuiControl, HIDE, MSGBOXCANCEL
GuiControl, HIDE, MSGBOXOK
}
else if ( msg_type == 3 )
{
GuiControl, HIDE, MSGBOXCANCEL
GuiControl, HIDE, MSGBOXYES
GuiControl, HIDE, MSGBOXNO
}
Gui, OwnerMsgBox:Font, s16 q5 Bold, Arial Narrow
Gui, OwnerMsgBox:Add, Text, x60 y18 R1 BackgroundTrans -Wrap Center c%BG_Color%, MessageBox -
Gui, OwnerMsgBox:Font, s16 q5 Normal, Arial Narrow
Gui, OwnerMsgBox:Add, Text, x185 y18 R1 BackgroundTrans -Wrap Center c%BG_Color%, %msgbox_title%
Gui, OwnerMsgBox: Add, Edit, x50 y140 w275 h32 c%TX_Color% -VScroll vmsgbox_owner hWndILE_FILE HIDE -E0x200, %msg_owner%
Gui, Hotkey: +Disabled ;disable the owner
Gui, OwnerMsgBox: +OwnerHotkey ;specify the owner.
Gui, OwnerMsgBox:Show, w340 h200, msgboxgui
return
}
MSGBOXGUICLose:
Gui, Hotkey: -Disabled ;disable the owner
Gui,OwnerMsgBox: Destroy
Return
MSGBOXYES:
Gui, Hotkey: -Disabled ;disable the owner
Gui,OwnerMsgBox:Default
GuiControlGet, msgbox_owner
Gui,OwnerMsgBox: Destroy
if ( msgbox_owner == 1 )
{
;speichern und close
Write_Changes_to_DB()
Gui,Hotkey:HIDE
}
else if ( msgbox_owner == 2 )
{
;beenden und Rollback
Rollback_changes_in_DB()
Gui,Hotkey:HIDE
}
Return
MSGBOXNO:
Gui, Hotkey: -Disabled ;disable the owner
Gui,OwnerMsgBox:Default
GuiControlGet, msgbox_owner
Gui,OwnerMsgBox: Destroy
if ( msgbox_owner == 1 )
{
Rollback_changes_in_DB()
Gui,Hotkey:HIDE
}
else if ( msgbox_owner == 2 )
{
;abbrechen und nix machen
}
Return
MSGBOXCANCEL:
Gui, Hotkey: -Disabled ;disable the owner
Gui,OwnerMsgBox:Default
GuiControlGet, msgbox_owner
Gui,OwnerMsgBox: Destroy
if ( msgbox_owner == 1 )
{
; msgbox, Abbrechen, nix machen
}
else if ( msgbox_owner == 2 )
{
; no action
}
Return
MSGBOXOK:
Gui, Hotkey: -Disabled ;disable the owner
Gui,OwnerMsgBox:Default
GuiControlGet, msgbox_owner
Gui,OwnerMsgBox: Destroy
if ( msgbox_owner == 1 )
{
; no action
}
else if ( msgbox_owner == 2 )
{
; no action
}
Return
MSGBOXCaptionClick:
PostMessage, 0xA1, 2,,, A
Return
do_sql(sqlstatement)
{
currentDB := DBA.DataBaseFactory.OpenDataBase("SQLite", connectionString)
currentDB.Query(sqlstatement)
currentDB.Close()
VarSetCapacity(currentDB,0)
}
remove_old()
{
currentDB := DBA.DataBaseFactory.OpenDataBase("SQLite", connectionString)
rs := currentDB.OpenRecordSet("Select hotkey, replace from replace")
while(!rs.EOF)
{
db_hotkey := "i)" . rs["hotkey"] . trigger
hotstrings(db_hotkey)
rs.MoveNext()
}
rs.Close()
currentDB.Close()
VarSetCapacity(currentDB,0)
return
}
; #############################################################################
; ----- SET HOTSTRINGS AS SELECT FROM DB_TABLE -----
; #############################################################################
set_hotstrings()
{
currentDB := DBA.DataBaseFactory.OpenDataBase("SQLite", connectionString)
rs := currentDB.OpenRecordSet("Select hotkey, replace from replace")
while(!rs.EOF)
{
db_hotkey := "i)" . rs["hotkey"] . trigger
db_replace := rs["replace"]
hotstrings(db_hotkey,db_replace)
rs.MoveNext()
}
rs.Close()
currentDB.Close()
VarSetCapacity(currentDB,0)
return
}