1 (изменено: anp, 2017-09-10 22:57:51)

Тема: AHK: MS Word AutoSaver

Доброго времени суток. При работе с большими файлами в Word 2013 у меня часто перестает работать встроенная в него функция автоматического сохранения. В итоге Word через какое-то время зависает и закрывается. После чего оказывается, что последнее автоматическое сохранение произведено программой пару часов назад, а не каждые пять минут, как задано в настройках. Из-за этого часть набранного текста не сохранялась. Искал готовое решение в виде скрипта, который бы после запуска выполнял сохранение либо всех открытых в Word файлов, либо одного, заданного файла, с указанным интервалом (по типу эмуляции ctrl+s с задаваемыми интервалами), чтобы отказаться от встроенного автоматического сохранения (подозреваю что из-за него и падает Word). Наткнулся на что-то подобное: MS Word+Excel AutoSaver. Прошу помочь с ним разобраться, у меня этот скрипт по какой-то неведомой причине не работает. Либо предложить какие-то другие варианты решения этой серьезной проблемы. Ниже привожу код, представленный на указанной по ссылке странице англоязычного форума.

#Persistent
#NoEnv
SetTitleMatchMode,2
CoordMode, mouse, Screen
OnExit, writefile
appname := "Document saver"

Menu, Tray, Icon, Shell32.dll, 21
Menu, Tray, NoStandard
Menu, Tray, Add, %appname%,mnuAbout
Menu, Tray, Add
Menu, Tray, Add, Settings,mnusettings
Menu, Tray, Add, exit, mnuexit
menu, tray, default, %appname%
menu,tray, tip, %appname%

Gui, Add, Text, x5 y10 w h20 , Enter the caption of the window to save or click Find
Gui, Add, Edit, vedit1 x5 y35 w215 h20 Gtxtchange,
Gui, Add, Button, vbuttonGet x+5 y w40 h20 Ggettitle, Find
Gui, Add, Button, vbuttonAdd x5 y+10 w50 h20 gAdd default, Add
Gui, Add, Button, vbuttonDel x+5 y w50 h20 gDelet, Delete
Gui, Add, Button, vbuttonminimize x+5 y w50 h20 gminimize, Minimize
Gui, Add, Button, vbuttonAbout x+5 y w50 h20 Gmnuabout, About
Gui, Add, Button, vbuttonExit x+5 y w40 h20 Gmnuexit, Exit
Gui, Add, ListBox, Vlistbox1  x5 y w260 h150 glistboxClick, 
gosub readfile
Gui, Show, , %appname%

Control, disable , , button2, %appname%
Control, disable , , button3, %appname%
Hotkey, ^c, off
SetTimer, timeBegin, 180000
filechanged = false
Return

readfile:
Loop, Read, %A_ScriptDir%\autosave.ini
{
  ;msgbox %A_loopreadline%
  ArrayCount += 1           ; Keep track of how many items are in the array.      
  GuiControl,, ListBox1, %A_loopreadline%
  filearray%arraycount% = %A_loopreadline%
}
return

txtchange:
Control, enable , , button2, %appname%
return

writefile:
if filechanged = true 
{
  fileDelete %A_ScriptDir%\autosave.ini
  ControlGet, outputList, List,, ListBox1,%appname%
  FileAppend , %outputlist%, %A_ScriptDir%\autosave.ini
}
ExitApp

gettitle:
Hotkey, ^c, On  
SetTimer, WatchCursor, 200
return

WatchCursor:
MouseGetPos, , , id, control
WinGetTitle, title, ahk_id %id%
WinGetClass, class, ahk_id %id%
;ToolTip, ahk_id %id%`nahk_class %class%`n%title%`nControl: %control%
tooltip, Caption =  %title%`npress CONTROL + C to copy window caption 
return

^c::
SetTimer, WatchCursor, off
tooltip
;sleep 1000
clipboard =
clipboard = %title% 
tooltip, window caption saved to clipboard`npress CONTROL + V to paste
Hotkey, ^c, Off          ; disable hotkey
ControlSetText, edit1, %title%, %appname%
winactivate, %appname%
sleep 3000
tooltip
return

add:
gui,submit, nohide
GuiControl,, ListBox1, %edit1%
ArrayCount += 1  ; Keep track of how many items are in the array.   
filearray%arraycount% = %edit1%
filechanged = true
Control, disable , , button2, %appname%
return

ListBoxclick:
Control, enable , , button3
return

GuiClose:
mnuExit:
ExitApp 

mnuAbout:
msgbox ,0,%appname%,
(
Saves documents 
when the PC es iddle`n
Created by Salome Cruz 
salocruz@yahoo.com
)
return

#s::
sleep 40000     ; presing win + S will save all documents chosen
gosub programstosave
return

timeBegin:
MouseGetPos, xpos, ypos 
if A_TimeIdle  > 180000      ; if PC is inactive more than 3 minutes save documents
{
 ; ToolTip, inactividad 
  tooltip   
  gosub programstosave   
  SetTimer, timeBegin, off    ; after saving documents rest 15 minutes before saving again
  sleep  900000                ; I don´t want to save them every 3 minutes 
  SetTimer, timeBegin, on
}
else
{
 ; ToolTip, hay actividad
  sleep 1000
  tooltip
}
return

programstosave:
loop, %arraycount%
{
  IfWinExist,% filearray%A_Index%
  {
    gosub save
    Sleep 40000
  }
;msgbox % filearray%A_Index%
}
return

save:
if A_TimeIdle > 10000           ; if there is no activity in 10 seconds keep saving
{
  WinActivate
  ToolTip, guardando archivo
  Sleep 3000
  tooltip
  Send ^s    ;  control + S     p/programs in inglish
  ; Send ^g  ; control + G     p/programas en español 
  ;FileAppend , guardado %A_hour%:%A_Min%, %scriptdir%\log.txt
}
return

guiescape:
Minimize:
gui , hide
return

mnusettings:
gui, show
return

delet:   ; ****   this sub delets a selected item from a listbox or dropdownbox **
ControlGet, selected, choice,, listbox1,  ; 1  get the selected item
if selected =
   return
ControlGet, outputList, List,, listbox1,  ; 2  make a list of all its items
GuiControl,, Listbox1, |                  ; 3  third clear the listbox

Loop, Parse, outputList, `n               ; 4  four parse the outputlist 
{                                         ; 5  add to the listbox every field 
  if (selected <> A_LoopField)            ;    in the outputlist exept the selected 
  GuiControl,, ListBox1, %A_LoopField%
}
filechanged = true
Reload
return
Яжнепрограммист :)

2 (изменено: teadrinker, 2017-09-10 15:20:14)

Re: AHK: MS Word AutoSaver

Для начала попробуйте заменить везде ^c на ^sc2E, #s:: на #sc1F::, Send ^s на Send ^{sc1F}

Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Telegram jollycoder

3

Re: AHK: MS Word AutoSaver

teadrinker
Error: Invalid option.
Specifically: w Line#
009: Menu,Tray,NoStandard
010: Menu,Tray,Add,%appname%,mnuAbout
Oil: Menu,Tray,Add
012: Menu,Tray,Add,Settings,mnusettings 013: Menu,Tray,Add,exit,mnuexit 014: Menu,tray,default,%appname%
015: Menu,tray,tip,%appname%
—> 017: Gui,Add,Text,x5 ylO w,Enter the caption of the window to save or
click Find
018: Gui,Add,Edit,veditl x5 y35 w215 h20 Gtxtchange 019: Gui,Add,Button,vbuttonGetx+5y w40 h20 Ggettitle,Find 020: Gui,Add,Button,vbuttonAdd x5 y+10 w50 h20 gAdd default,Add 021: Gui,Add,Button,vbuttonDel x+5 y w50 h20 gDelet,Delete 022: Gui,Add,Button,vbuttonminimize x+5 y w50 h20 gminimize,Minimize
023: Gui,Add,Button,vbuttonAbout x+5 y w50 h20 Gmnuabout,About 024: Gui,Add,Button,vbuttonExit x+5 y w40 h20 Gmnuexit,Exit
The current thread will exit.

Яжнепрограммист :)

4

Re: AHK: MS Word AutoSaver

anp пишет:

Specifically: w Line#

У w должно быть заначение после w.

Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Telegram jollycoder

5

Re: AHK: MS Word AutoSaver

teadrinker
какое значение?

Яжнепрограммист :)

6

Re: AHK: MS Word AutoSaver

Цифра, означающая ширину контрола text в пикселях. Например

Gui, Add, Text, x5 y10 w200 h20

Или вообще можно это w убрать:

Gui, Add, Text, x5 y10 h20
Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Telegram jollycoder
+ anp

7

Re: AHK: MS Word AutoSaver

teadrinker
убрал, запустился скрипт, висит в трее, только чем он занимается не понятно.

#Persistent
#NoEnv
SetTitleMatchMode,2
CoordMode, mouse, Screen
OnExit, writefile
appname := "Document saver"

Menu, Tray, Icon, Shell32.dll, 21
Menu, Tray, NoStandard
Menu, Tray, Add, %appname%,mnuAbout
Menu, Tray, Add
Menu, Tray, Add, Settings,mnusettings
Menu, Tray, Add, exit, mnuexit
menu, tray, default, %appname%
menu,tray, tip, %appname%

Control, disable , , button2, %appname%
Control, disable , , button3, %appname%
Hotkey, ^sc2E, off
SetTimer, timeBegin, 10000
filechanged = false
Return

readfile:
Loop, Read, %A_ScriptDir%\autosave.ini
{
  ;msgbox %A_loopreadline%
  ArrayCount += 1           ; Keep track of how many items are in the array.      
  GuiControl,, ListBox1, %A_loopreadline%
  filearray%arraycount% = %A_loopreadline%
}
return

txtchange:
Control, enable , , button2, %appname%
return

writefile:
if filechanged = true 
{
  fileDelete %A_ScriptDir%\autosave.ini
  ControlGet, outputList, List,, ListBox1,%appname%
  FileAppend , %outputlist%, %A_ScriptDir%\autosave.ini
}
ExitApp

gettitle:
Hotkey, ^sc2E, On  
SetTimer, WatchCursor, 200
return

WatchCursor:
MouseGetPos, , , id, control
WinGetTitle, title, ahk_id %id%
WinGetClass, class, ahk_id %id%
;ToolTip, ahk_id %id%`nahk_class %class%`n%title%`nControl: %control%
tooltip, Caption =  %title%`npress CONTROL + C to copy window caption 
return

^sc2E::
SetTimer, WatchCursor, off
tooltip
;sleep 1000
clipboard =
clipboard = %title% 
tooltip, window caption saved to clipboard`npress CONTROL + V to paste
Hotkey, ^sc2E, Off          ; disable hotkey
ControlSetText, edit1, %title%, %appname%
winactivate, %appname%
sleep 3000
tooltip
return

add:
gui,submit, nohide
GuiControl,, ListBox1, %edit1%
ArrayCount += 1  ; Keep track of how many items are in the array.   
filearray%arraycount% = %edit1%
filechanged = true
Control, disable , , button2, %appname%
return

ListBoxclick:
Control, enable , , button3
return

GuiClose:
mnuExit:
ExitApp 

mnuAbout:
msgbox ,0,%appname%,
(
Saves documents 
when the PC es iddle`n
Created by Salome Cruz 
salocruz@yahoo.com
)
return

#sc1F::
sleep 40000     ; presing win + S will save all documents chosen
gosub programstosave
return

timeBegin:
MouseGetPos, xpos, ypos 
if A_TimeIdle  > 180000      ; if PC is inactive more than 3 minutes save documents
{
 ; ToolTip, inactividad 
  tooltip   
  gosub programstosave   
  SetTimer, timeBegin, off    ; after saving documents rest 15 minutes before saving again
  sleep  900000                ; I don?t want to save them every 3 minutes 
  SetTimer, timeBegin, on
}
else
{
 ; ToolTip, hay actividad
  sleep 1000
  tooltip
}
return

programstosave:
loop, %arraycount%
{
  IfWinExist,% filearray%A_Index%
  {
    gosub save
    Sleep 40000
  }
;msgbox % filearray%A_Index%
}
return

save:
if A_TimeIdle > 10000           ; if there is no activity in 10 seconds keep saving
{
  WinActivate
  ToolTip, guardando archivo
  Sleep 3000
  tooltip
  Send ^{sc1F}    ;  control + S     C/WordDrive
  ; Send ^g  ; control + G     C/WordDrive 
  ;FileAppend , guardado %A_hour%:%A_Min%, %scriptdir%\log.txt
}
return

guiescape:
Minimize:
gui , hide
return

mnusettings:
gui, show
return

delet:   ; ****   this sub delets a selected item from a listbox or dropdownbox **
ControlGet, selected, choice,, listbox1,  ; 1  get the selected item
if selected =
   return
ControlGet, outputList, List,, listbox1,  ; 2  make a list of all its items
GuiControl,, Listbox1, |                  ; 3  third clear the listbox

Loop, Parse, outputList, `n               ; 4  four parse the outputlist 
{                                         ; 5  add to the listbox every field 
  if (selected <> A_LoopField)            ;    in the outputlist exept the selected 
  GuiControl,, ListBox1, %A_LoopField%
}
filechanged = true
Reload
return
Яжнепрограммист :)

8

Re: AHK: MS Word AutoSaver

Сейчас с телефона, не могу запустить. Попозже, если никто не разберется.

Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Telegram jollycoder

9

Re: AHK: MS Word AutoSaver

Походу, вы вместе с w изрядный кусок кода убрали.

Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Telegram jollycoder

10 (изменено: anp, 2017-09-10 22:32:05)

Re: AHK: MS Word AutoSaver

Убрал эти Gui.


Gui, Add, Text, x5 y10 w h20 , Enter the caption of the window to save or click Find
Gui, Add, Edit, vedit1 x5 y35 w215 h20 Gtxtchange,
Gui, Add, Button, vbuttonGet x+5 y w40 h20 Ggettitle, Find
Gui, Add, Button, vbuttonAdd x5 y+10 w50 h20 gAdd default, Add
Gui, Add, Button, vbuttonDel x+5 y w50 h20 gDelet, Delete
Gui, Add, Button, vbuttonminimize x+5 y w50 h20 gminimize, Minimize
Gui, Add, Button, vbuttonAbout x+5 y w50 h20 Gmnuabout, About
Gui, Add, Button, vbuttonExit x+5 y w40 h20 Gmnuexit, Exit
Gui, Add, ListBox, Vlistbox1  x5 y w260 h150 glistboxClick, 
gosub readfile
Gui, Show, , %appname%

Ошибка появляться перестала. Только чем он занят, не ясно.

Яжнепрограммист :)

11 (изменено: anp, 2017-09-10 23:04:02)

Re: AHK: MS Word AutoSaver

Я уже не знаю что с этим Вордом делать, перешел бы на другой редактор, но никак - в этом файле графика (рамки и тп.) которые нигде кроме как тут не поддерживаются. Уже и на RAM-диск каталог автоматического хранения переносил, все процессы гасил, чтобы никто не цеплялся к Ворду, систему сносил, все-равно с большими файлами автосохранение там работает с глюками, на fat32 пытался переносить - всё-равно виснет раз в пару дней непонятно почему, не сохранив результат. Сейчас еще макрос VBA пытаюсь параллельно использовать, но там есть недостаток - сохраняются все открытые документы, а не только тот нужный, в котором работаю.

Яжнепрограммист :)

12

Re: AHK: MS Word AutoSaver

Вот поправленный код(оригинал, только без вылетов):

#Persistent
#NoEnv
SetTitleMatchMode,2
CoordMode, mouse, Screen
OnExit, writefile
appname := "Document saver"

Menu, Tray, Icon, Shell32.dll, 21
Menu, Tray, NoStandard
Menu, Tray, Add, %appname%,mnuAbout
Menu, Tray, Add
Menu, Tray, Add, Settings,mnusettings
Menu, Tray, Add, exit, mnuexit
menu, tray, default, %appname%
menu,tray, tip, %appname%

Gui, Add, Text, x5 y10 h20 , Enter the caption of the window to save or click Find
Gui, Add, Edit, vedit1 x5 y35 w215 h20 Gtxtchange,
Gui, Add, Button, vbuttonGet x+5 w40 h20 Ggettitle, Find
Gui, Add, Button, vbuttonAdd x5 y+10 w50 h20 gAdd default, Add
Gui, Add, Button, vbuttonDel x+5 w50 h20 gDelet, Delete
Gui, Add, Button, vbuttonminimize x+5 w50 h20 gminimize, Minimize
Gui, Add, Button, vbuttonAbout x+5 w50 h20 Gmnuabout, About
Gui, Add, Button, vbuttonExit x+5 w40 h20 Gmnuexit, Exit
Gui, Add, ListBox, Vlistbox1  x5 w260 h150 glistboxClick, 
gosub readfile
Gui, Show, , %appname%

Control, disable , , button2, %appname%
Control, disable , , button3, %appname%
Hotkey, ^c, off
SetTimer, timeBegin, 180000
filechanged = false
Return

readfile:
Loop, Read, %A_ScriptDir%\autosave.ini
{
  ;msgbox %A_loopreadline%
  ArrayCount += 1           ; Keep track of how many items are in the array.      
  GuiControl,, ListBox1, %A_loopreadline%
  filearray%arraycount% = %A_loopreadline%
}
return

txtchange:
Control, enable , , button2, %appname%
return

writefile:
if filechanged = true 
{
  fileDelete %A_ScriptDir%\autosave.ini
  ControlGet, outputList, List,, ListBox1,%appname%
  FileAppend , %outputlist%, %A_ScriptDir%\autosave.ini
}
ExitApp

gettitle:
Hotkey, ^c, On  
SetTimer, WatchCursor, 200
return

WatchCursor:
MouseGetPos, , , id, control
WinGetTitle, title, ahk_id %id%
WinGetClass, class, ahk_id %id%
;ToolTip, ahk_id %id%`nahk_class %class%`n%title%`nControl: %control%
tooltip, Caption =  %title%`npress CONTROL + C to copy window caption 
return

^c::
SetTimer, WatchCursor, off
tooltip
;sleep 1000
clipboard =
clipboard = %title% 
tooltip, window caption saved to clipboard`npress CONTROL + V to paste
Hotkey, ^c, Off          ; disable hotkey
ControlSetText, edit1, %title%, %appname%
winactivate, %appname%
sleep 3000
tooltip
return

add:
gui,submit, nohide
GuiControl,, ListBox1, %edit1%
ArrayCount += 1  ; Keep track of how many items are in the array.   
filearray%arraycount% = %edit1%
filechanged = true
Control, disable , , button2, %appname%
return

ListBoxclick:
Control, enable , , button3
return

GuiClose:
mnuExit:
ExitApp 

mnuAbout:
msgbox ,0,%appname%,
(
Saves documents 
when the PC es iddle`n
Created by Salome Cruz 
salocruz@yahoo.com
)
return

#s::
sleep 40000     ; presing win + S will save all documents chosen
gosub programstosave
return

timeBegin:
MouseGetPos, xpos, ypos 
if A_TimeIdle  > 180000      ; if PC is inactive more than 3 minutes save documents
{
 ; ToolTip, inactividad 
  tooltip   
  gosub programstosave   
  SetTimer, timeBegin, off    ; after saving documents rest 15 minutes before saving again
  sleep  900000                ; I don?t want to save them every 3 minutes 
  SetTimer, timeBegin, on
}
else
{
 ; ToolTip, hay actividad
  sleep 1000
  tooltip
}
return

programstosave:
loop, %arraycount%
{
  IfWinExist,% filearray%A_Index%
  {
    gosub save
    Sleep 40000
  }
;msgbox % filearray%A_Index%
}
return

save:
if A_TimeIdle > 10000           ; if there is no activity in 10 seconds keep saving
{
  WinActivate
  ToolTip, guardando archivo
  Sleep 3000
  tooltip
  Send ^s    ;  control + S     p/programs in inglish
  ; Send ^g  ; control + G     p/programas en espanol 
  ;FileAppend , guardado %A_hour%:%A_Min%, %scriptdir%\log.txt
}
return

guiescape:
Minimize:
gui , hide
return

mnusettings:
gui, show
return

delet:   ; ****   this sub delets a selected item from a listbox or dropdownbox **
ControlGet, selected, choice,, listbox1,  ; 1  get the selected item
if selected =
   return
ControlGet, outputList, List,, listbox1,  ; 2  make a list of all its items
GuiControl,, Listbox1, |                  ; 3  third clear the listbox

Loop, Parse, outputList, `n               ; 4  four parse the outputlist 
{                                         ; 5  add to the listbox every field 
  if (selected <> A_LoopField)            ;    in the outputlist exept the selected 
  GuiControl,, ListBox1, %A_LoopField%
}
filechanged = true
Reload
return

13

Re: AHK: MS Word AutoSaver

А почему не используете пример через таймер в вашей ссылки?

14 (изменено: anp, 2017-09-10 22:33:33)

Re: AHK: MS Word AutoSaver

svoboden
Так там же вроде только Excel, господа.

Яжнепрограммист :)

15 (изменено: svoboden, 2017-09-10 16:36:15)

Re: AHK: MS Word AutoSaver

Вот Word https://autohotkey.com/board/topic/1228 … ntry692457.

16 (изменено: anp, 2017-09-10 22:34:23)

Re: AHK: MS Word AutoSaver

MandarinKa02
Спасибо, запустился, только не сохраняет почему-то ничего он.

Яжнепрограммист :)

17 (изменено: ypppu, 2017-12-21 18:56:23)

Re: AHK: MS Word AutoSaver

Вот вам скрипт(можно под любое окно настроить).

+ AutoSaver.ahk

#Persistent
#NoEnv

GoSub, Init

MsgBox, 64, Инфо, % g_sInfo
Hotkey, ^P, ChangeWindow, On
Return




ChangeWindow:
Hotkey, ^P, ChangeWindow, Off
WinGet,      aPID,   PID, A
WinGetTitle, aTitle, ahk_pid %aPID%
MsgBox, % 64+4, Окно, Вы выбрали окно: %aTitle%.`nПродолжить?
IfMsgBox No
{
	MsgBox, 64, Инфо, Выберите новое окно.
	Hotkey, ^P, ChangeWindow, On
	Return
}
ChangeTime:
InputBox, g_aTime, % g_inptBox1, % g_inptBox2,0,,200
If(ErrorLevel)
{
	MsgBox, 48, Внимание, Вы нажали отмена.`nСкрипт будет закрыт, 5
	ExitApp
	return
}
If(g_aTime < 30)
{
	MsgBox, % 48+4, Внимание, Вы установили частоту сохранения меньше 30сек.`nПродолжить?
	IfMsgBox No
	{
		GoSub, ChangeTime
		Return
	}
}
Sleep 1000
GoSub, Save
SetTimer, Save, % (g_aTime * 1000)
Return

Save:
WinActivate, ahk_pid %aPID%
Send, ^S
Return




F6::
ExitApp
Return

















































































Init:
g_sInfo := "Порядок действий:" "`n"
         . "1. Нажмите ОК"     "`n"
         . "2. Выберите окно"  "`n"
         . "3. Нажмите CTRL+P" "`n"
		 
		 
g_inptBox1 := "Введите частоту сохранения(в секундах)"
g_inptBox2 := "1мин = 60сек."  "`n"
            . "2мин = 120сек." "`n"
            . "3мин = 180сек." "`n"
            . "4мин = 240сек." "`n"
            . "5мин = 300сек." "`n"
g_aTime := 5

Return

Если что обращайтесь.

+ anp

18 (изменено: anp, 2017-09-10 22:36:11)

Re: AHK: MS Word AutoSaver

MandarinKa02
Спасибо, он работает. Выполняет нажатие Ctrl+Shift+S.
Но! Только если печатать текст на английском языке. А когда включена русская раскладка, в тексте во время срабатывания скрипта появляется английская буква ''S'', при этом сохранение файла не происходит.

Яжнепрограммист :)

19 (изменено: stealzy, 2017-09-13 13:46:58)

Re: AHK: MS Word AutoSaver

Send ^S

Потому что при русской это будет ^Ы.
Универсальный вариант использует VK код клавиши и выглядит так:
Send ^{vk53} ; S
Или
Send % "^" Format("{vk{:x}}", GetKeyVK("S")) ; выглядит страшно, зато не нужно знать VK код клавиши, на место S можно подставить любую.

+ anp

20

Re: AHK: MS Word AutoSaver

А зачем вообще там что-то посылать, когда у ворда есть объектная модель.

21 (изменено: anp, 2017-09-10 22:37:12)

Re: AHK: MS Word AutoSaver

Это не смог заставить работать, запускается но непонятно-что делает. Хотя судя по описанию, он должен еще и теневые копии открытых файлов делать, или что-то типа того.

Яжнепрограммист :)

22 (изменено: svoboden, 2017-09-13 04:49:36)

Re: AHK: MS Word AutoSaver

Так что, я должен проверять еще, работают там примеры или нет? Судя по отзывам, там все работает.

23 (изменено: anp, 2017-09-10 22:18:30)

Re: AHK: MS Word AutoSaver

MandarinKa02 пишет:

Вот вам скрипт(можно под любое окно настроить)

+ AutoSaver.ahk

#Persistent
#NoEnv

GoSub, Init

MsgBox, 64, Инфо, % g_sInfo
Hotkey, ^P, ChangeWindow, On
Return




ChangeWindow:
Hotkey, ^P, ChangeWindow, Off
WinGet,      aPID,   PID, A
WinGetTitle, aTitle, ahk_pid %aPID%
MsgBox, % 64+4, Окно, Вы выбрали окно: %aTitle%.`nПродолжить?
IfMsgBox No
{
	MsgBox, 64, Инфо, Выберите новое окно.
	Hotkey, ^P, ChangeWindow, On
	Return
}
ChangeTime:
InputBox, g_aTime, % g_inptBox1, % g_inptBox2,0,,200
If(ErrorLevel)
{
	MsgBox, 48, Внимание, Вы нажали отмена.`nСкрипт будет закрыт, 5
	ExitApp
	return
}
If(g_aTime < 30)
{
	MsgBox, % 48+4, Внимание, Вы установили частоту сохранения меньше 30сек.`nПродолжить?
	IfMsgBox No
	{
		GoSub, ChangeTime
		Return
	}
}
Sleep 1000
GoSub, Save
SetTimer, Save, % (g_aTime * 1000)
Return

Save:
WinActivate, ahk_pid %aPID%
Send, ^S
Return




F6::
ExitApp
Return

















































































Init:
g_sInfo := "Порядок действий:" "`n"
         . "1. Нажмите ОК"     "`n"
         . "2. Выберите окно"  "`n"
         . "3. Нажмите CTRL+P" "`n"
		 
		 
g_inptBox1 := "Введите частоту сохранения(в секундах)"
g_inptBox2 := "1мин = 60сек."  "`n"
            . "2мин = 120сек." "`n"
            . "3мин = 180сек." "`n"
            . "4мин = 240сек." "`n"
            . "5мин = 300сек." "`n"
g_aTime := 5

Return

Если что обращайтесь.

Поставил как посоветовал stealzy Send ^{vk53} ; S - и всё ништяк заработало, это на порядок удобнее чем встраивать в ворд vba макросы.
Потестирую еще, отпишусь тут. Нужно разобраться что другие варианты скриптов, предлагаемые по ссылкам за собой скрывали.

Яжнепрограммист :)

24 (изменено: anp, 2017-09-11 10:37:57)

Re: AHK: MS Word AutoSaver

svoboden пишет:

Так что я должен проверять еще, работают там примеры или нет? Судя по отзывам, там все работает.

Ну, я попытался на уровне знаний человека, не имеющего какого-либо компьютерного образования, использовать скрипты по ссылкам. Но заставить их сохранять файлы не смог, по этой причине и написал, что они не работают. Но всё-равно, огромное огромное спасибо за помощь, сэр.

Яжнепрограммист :)

25 (изменено: Malcev, 2017-09-10 22:25:14)

Re: AHK: MS Word AutoSaver

svoboden пишет:

Так что я должен проверять еще, работают там примеры или нет? Судя по отзывам, там все работает.

Я считаю, что желательно проверять, перед тем как давать ссылку.

26

Re: AHK: MS Word AutoSaver

Код должен оформляться специальным тегом. anp, исправьте это сообщение: http://forum.script-coding.com/viewtopi … 32#p119232.
Предложения должны начинаться заглавной буквой и заканчиваться знаками препинания.
anp, исправьте:
http://forum.script-coding.com/viewtopi … 36#p119236

http://forum.script-coding.com/viewtopi … 38#p119238
http://forum.script-coding.com/viewtopi … 51#p119251
http://forum.script-coding.com/viewtopi … 54#p119254
http://forum.script-coding.com/viewtopi … 57#p119257

stealzy, аналогичная просьба не забывать точки. http://forum.script-coding.com/viewtopi … 52#p119252

27 (изменено: svoboden, 2017-09-10 22:32:50)

Re: AHK: MS Word AutoSaver

Malcev пишет:

желательно проверять, перед тем как давать ссылку.

Не знаю, как там могут не работать примеры, если вопросы абсолютно одинаковые. Да и еще там выбран лучший ответ.

28

Re: AHK: MS Word AutoSaver

ypppu
Ваше поручение выполнено. Благодарю за заботу.

Яжнепрограммист :)

29

Re: AHK: MS Word AutoSaver

svoboden, я тоже не знаю, так как ворд не стоит.

30

Re: AHK: MS Word AutoSaver

Malcev, так я тоже не знаю, у меня не активирован World.

31 (изменено: svoboden, 2017-09-13 03:24:02)

Re: AHK: MS Word AutoSaver

Тут и тут, смотрите еще про Word ответы, а про COM можно здесь прочитать.

+ anp

32 (изменено: svoboden, 2017-09-13 04:54:19)

Re: AHK: MS Word AutoSaver

Проверил, вот так у меня нормально все сохраняет:

1::
Word := ComObjActive("Word.Application")
Files := "Путь к файлу.docx" . filename
word.ActiveDocument.SaveAs(Files)
return

33

Re: AHK: MS Word AutoSaver

svoboden
Спасибо, посмотрю, как только время появится. Но это же только часть кода?
У меня пока вариант MandarinKa02 отлично работает. Поставил на сохранение каждые три минуты. Сегодня раза три спасло от потери данных. Теперь, когда Word не может файл сохранить, то он хотя-бы сообщает: "не удалось сохранить файл". Раньше же просто молчал, как партизан. Проблема такая только с большими файлами, где много рисунков и фотографий.

Яжнепрограммист :)

34 (изменено: MandarinKa02, 2017-12-21 19:37:08)

Re: AHK: MS Word AutoSaver

anp пишет:

У меня пока вариант MandarinKa02 отлично работает.

Обращайтесь.

35

Re: AHK: MS Word AutoSaver

MandarinKa02, для выделения кода цветом допустимо использовать тег quote, но не spoiler, исправьте: http://forum.script-coding.com/viewtopi … 56#p117656. Спойлер можно использовать в дополнение к тегу code или quote, но не вместо.

Проставьте точки в конце предложений.
http://forum.script-coding.com/viewtopi … 20#p119320

http://forum.script-coding.com/viewtopi … 99#p119299
http://forum.script-coding.com/viewtopi … 39#p119239
http://forum.script-coding.com/viewtopi … 26#p119126
http://forum.script-coding.com/viewtopi … 10#p118910
http://forum.script-coding.com/viewtopi … 61#p118861
http://forum.script-coding.com/viewtopi … 31#p118831
http://forum.script-coding.com/viewtopi … 37#p118237
http://forum.script-coding.com/viewtopi … 29#p118229
http://forum.script-coding.com/viewtopi … 27#p118227
http://forum.script-coding.com/viewtopi … 25#p118225
http://forum.script-coding.com/viewtopi … 03#p118103
http://forum.script-coding.com/viewtopi … 47#p118047
http://forum.script-coding.com/viewtopi … 03#p118003
http://forum.script-coding.com/viewtopi … 04#p118004
http://forum.script-coding.com/viewtopi … 37#p118037
http://forum.script-coding.com/viewtopi … 36#p117936
http://forum.script-coding.com/viewtopi … 10#p117910
http://forum.script-coding.com/viewtopi … 66#p117866

36 (изменено: svoboden, 2017-09-14 02:09:16)

Re: AHK: MS Word AutoSaver

Вы и вправду считаете, что обычные сочетание клавиш будут надежней работать, чем com объекты? А если окно будет перекрыто другим окном, или оно не будет активно, или программа будет свернута, как хоткеи, тогда могут помочь?

37

Re: AHK: MS Word AutoSaver

svoboden пишет:

А если окно будет перекрыто другим окном, или оно не будет активно

В коде MandarinKa02 окно тупо активируется перед отправкой сочетания, логичнее конечно отправлять сочетание только если окно активно, потому что в ином случае и сохранять нечего. Кстати, ControlSend позволяет отправлять в неактивные окна.

38 (изменено: svoboden, 2017-09-14 02:24:06)

Re: AHK: MS Word AutoSaver

stealzy пишет:

Кстати, ControlSend позволяет отправлять в неактивные окна.

ControlSend в MC World?
Это, например, почти тоже самое, что в гугл хром оправить ControlSend. От кого-кого, но от вас я такого не ожидал.

39 (изменено: stealzy, 2017-09-14 02:38:09)

Re: AHK: MS Word AutoSaver

svoboden, какие-то проблемы с ControlSend?
Только что проверил - все работает, и в 2003, и в 2007, даже в свернутых окнах.

ControlSend _WwG1, % "^" Format("{vk{:x}}", GetKeyVK("S")), ahk_class OpusApp ahk_exe WINWORD.EXE

Я ведь не против COM методов, я лишь ответил по существу ваших возражений против ^s.
И кстати, чего именно вы от меня не ожидали ?

40 (изменено: svoboden, 2017-09-14 03:15:30)

Re: AHK: MS Word AutoSaver

Еще какие. У меня ничего не сохраняет. World 2010.

stealzy пишет:

В коде MandarinKa02 окно тупо активируется перед отправкой сочетания

Ну и что, что активируется, а как этот код сохранит файл, если я, например, выберу пункт Файл.
P.S. Не понимаю, почему вы за, за не очень надежный метод в этом вопросе, ну, ладно. Я лично за COM в этом вопросе.

41

Re: AHK: MS Word AutoSaver

svoboden пишет:

Не понимаю, почему вы за

Я разве где-то писал что за? Просто заметил что возражения в 36 сообщении ни по делу.