Skip to content

Commit 06020ec

Browse files
committed
Merge branch 'develop' into master
2 parents 0149dd7 + 255797c commit 06020ec

File tree

4 files changed

+129
-4
lines changed

4 files changed

+129
-4
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ joplin.json
33
venv
44
hotfolder.spec
55
build/
6-
dist/
6+
dist/
7+
*.exe
8+
JoplinWinBackup.ini

JoplinWinBackup.au3

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#include <MsgBoxConstants.au3>
2+
#include <WinAPIFiles.au3>
3+
4+
;Opt("WinTitleMatchMode", 4) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
5+
6+
$INI="JoplinWinBackup.ini"
7+
$JOPLINEXE = IniRead($INI, "General", "joplin", "C:\Program Files\Joplin\Joplin.exe")
8+
9+
; Ask for backup start
10+
if(IniRead($INI, "General", "ask_for_start", 1) = 1) Then
11+
if(MsgBox($MB_OKCANCEL + $MB_ICONQUESTION, "Joplin Backup", "Start Joplin Backup?") <> $IDOK) Then
12+
exit
13+
EndIf
14+
EndIf
15+
16+
; Create backup directory
17+
$BACKUPFOLDER = IniRead($INI, "General", "backup_folder", @ScriptDir & "\joplinbackup")
18+
DirCreate ( $BACKUPFOLDER )
19+
if(FileExists ($BACKUPFOLDER) = False) Then
20+
MsgBox($MB_OK + $MB_ICONERROR, "Joplin Backup", "Access Error on Backup directory '" & $BACKUPFOLDER & "'")
21+
exit
22+
EndIf
23+
24+
; Activate Joplin window or start joplin
25+
if (WinActivate("[REGEXPTITLE:^Joplin$; CLASS:Chrome_WidgetWin_1]","") = 0) Then
26+
run($JOPLINEXE)
27+
EndIf
28+
$hJOPLIN = WinWaitActive("[REGEXPTITLE:^Joplin$; CLASS:Chrome_WidgetWin_1]","", 10)
29+
30+
if( WinWaitActive("[REGEXPTITLE:^Joplin$; CLASS:Chrome_WidgetWin_1]","", 10) = 0) Then
31+
MsgBox($MB_OK + $MB_ICONERROR, "Joplin Backup", "Failed to start Joplin")
32+
exit
33+
EndIf
34+
35+
; Send keys for export menue
36+
$keyCombo = IniRead($INI, "General", "key_combo", "fej")
37+
Send ("!" & StringMid($keyCombo,1,1))
38+
Sleep(100)
39+
For $i = 2 To StringLen($keyCombo) Step +1
40+
Send (StringMid($keyCombo,$i,1))
41+
Sleep(100)
42+
Next
43+
44+
; Wait wor save dialog
45+
$save_dialog = IniRead($INI, "General", "save_dialog", "Speichern unter")
46+
$hSAVE = WinWaitActive("[TITLE:" & $save_dialog & "]","", 2)
47+
if($hSAVE = 0) Then
48+
MsgBox($MB_OK + $MB_ICONERROR, "Joplin Backup", "Failed to open export")
49+
exit
50+
EndIf
51+
52+
; Generate backupfile name
53+
$BACKUPFILE = IniRead($INI, "General", "backup_file_name", "joplin_backup.jex")
54+
$BACKUPFILE = StringReplace($BACKUPFILE, ".jex", "")
55+
56+
if(IniRead($INI, "General", "backup_file_add_date", 1) = 1) Then
57+
if($BACKUPFILE <> "") Then
58+
$BACKUPFILE = $BACKUPFILE & "_"
59+
EndIf
60+
$BACKUPFILE = $BACKUPFILE & @YEAR & @MON & @MDAY
61+
EndIf
62+
63+
if(IniRead($INI, "General", "backup_file_add_time", 1) = 1) Then
64+
if($BACKUPFILE <> "") Then
65+
$BACKUPFILE = $BACKUPFILE & "_"
66+
EndIf
67+
$BACKUPFILE = $BACKUPFILE & @HOUR & @MIN
68+
EndIf
69+
70+
$BACKUPFILE = $BACKUPFILE & ".jex"
71+
72+
; Send filename and save
73+
ControlSetText($hSAVE, "", "[CLASS:Edit]", $BACKUPFOLDER & "\" & $BACKUPFILE)
74+
Sleep(50)
75+
ControlClick($hSAVE, "", "[Class:Button;Instance:2]")
76+
Sleep(50)
77+
78+
; Check for confirmation dialog
79+
$hCONFIRM = WinGetHandle ( "[ACTIVE]", "" )
80+
if(StringInStr(WinGetTitle($hCONFIRM,""), $save_dialog) = 0) Then
81+
$hCONFIRM = 0
82+
EndIf
83+
84+
if ($hCONFIRM <> 0) Then
85+
if(IniRead($INI, "General", "overwrite_file", 0) = 1) Then
86+
ControlClick($hCONFIRM, "", "[Class:Button;Instance:1]")
87+
Else
88+
ControlClick($hCONFIRM, "", "[Class:Button;Instance:2]")
89+
Sleep(100)
90+
ControlClick($hSAVE, "", "[Class:Button;Instance:3]")
91+
92+
MsgBox($MB_OK + $MB_ICONERROR, "Joplin Backup", "Backup file already exists!" )
93+
EndIf
94+
EndIf

JoplinWinBackup.ini.example

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[General]
2+
joplin=C:\Program Files\Joplin\Joplin.exe
3+
backup_folder=C:\Backup
4+
key_combo=fej
5+
save_dialog=Speichern unter
6+
ask_for_start=1
7+
backup_file_add_date=0
8+
backup_file_add_time=0
9+
backup_file_name="joplin_backup.jex"
10+
overwrite_file=0

README.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# Joplin python tools
1+
# Joplin tools
22

33
Various python tools for Joplin.
44
For the communication with Joplin the API is used.
55

6-
## Additional modules
6+
## Additional python modules
77

8-
Please einstall the following modules:
8+
Please einstall the following python modules:
99

1010
- [PyMuPDF](https://github.com/pymupdf/PyMuPDF)
1111
- [Click](https://click.palletsprojects.com)
@@ -22,6 +22,7 @@ pip install PyMuPDF
2222
- [hotfolder.py](#hotfolderpy)
2323
- [add_pdf_previews.py](#add_pdf_previewspy)
2424
- [todo_overview.py](#todo_overviewpy)
25+
- [JoplinWinBackup.au3](#JoplinWinBackupau3)
2526

2627
### Parameters for all tools
2728

@@ -92,3 +93,21 @@ Creates or Updates a note with a list of all open ToDo's. All to-dos that have b
9293
```python
9394
python todo_overview.py --title "Open ToDo's" --as-todo --tag "importend"
9495
```
96+
97+
### JoplinWinBackup.au3
98+
99+
Since there is no possibility for an automatic backup under windows, the required key combinations are sent to joplin via autoit to create a backup.
100+
101+
Rename the `JoplinWinBackup.ini.example` to `JoplinWinBackup.ini` and place it in the same folder es the `JoplinWinBackup.au3` or `JoplinWinBackup.exe`.
102+
103+
Options from the JoplinWinBackup.ini
104+
105+
- `JoplinWinBackup` Defines the Path to Joplin exe. Default `C:\Program Files\Joplin\Joplin.exe`
106+
- `backup_folder` Path to store the Backups. Default `C:\Backup`
107+
- `key_combo` Key combo to get to the "JEX - Joplin export File" menue. Default `fej`
108+
- `save_dialog` Dialog Title of the save/eport dialog. Default `Speichern unter`
109+
- `ask_for_start` Ask if backup should be started. Default `1`, `0` = No, `1`= Yes
110+
- `backup_file_add_date` Append date to the Backupfile. Default `1`, `0` = No, `1`= Yes
111+
- `backup_file_add_time` Append time to the Backupfile. Default `1`, `0` = No, `1`= Yes
112+
- `backup_file_name` Filename of the Backup. Default `joplin_backup.jex`
113+
- `overwrite_file` Overwrite existing backup file. Default `0`, `0` = No, `1`= Yes

0 commit comments

Comments
 (0)