A veces estamos sincronizando gran cantidad de datos y queremos que la computadora se apague sola al terminar.
Para eso escribí un programa en AutoHotkey.
Aca pongo el código. Cualquiera puede bajarse el AutoHotKey y compilarlo. También modificarlo a su gusto.
Prefiero esto en vez de poner el exe, porque me parece mas seguro.
Aca el código:
copiar y pegar en un archiv de texto .ahk. Luego compilarlo con AutoHotKey ( http://www.autohotkey.com/ )
Para eso escribí un programa en AutoHotkey.
Aca pongo el código. Cualquiera puede bajarse el AutoHotKey y compilarlo. También modificarlo a su gusto.
Prefiero esto en vez de poner el exe, porque me parece mas seguro.
Aca el código:
[color=#000000]
DetectHiddenWindows, On
#SingleInstance ignore
TrayIcons(sExeName = "")
{
WinGet, pidTaskbar, PID, ahk_class Shell_TrayWnd
hProc:= DllCall("OpenProcess", "Uint", 0x38, "int", 0, "Uint", pidTaskbar)
pProc:= DllCall("VirtualAllocEx", "Uint", hProc, "Uint", 0, "Uint", 32, "Uint", 0x1000, "Uint", 0x4)
idxTB:= GetTrayBar()
SendMessage, 0x418, 0, 0, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd ; TB_BUTTONCOUNT
Loop, %ErrorLevel%
{
SendMessage, 0x417, A_Index-1, pProc, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd ; TB_GETBUTTON
VarSetCapacity(btn,32,0), VarSetCapacity(nfo,32,0)
DllCall("ReadProcessMemory", "Uint", hProc, "Uint", pProc, "Uint", &btn, "Uint", 32, "Uint", 0)
iBitmap := NumGet(btn, 0)
idn := NumGet(btn, 4)
Statyle := NumGet(btn, 8)
If dwData := NumGet(btn,12)
iString := NumGet(btn,16)
Else dwData := NumGet(btn,16,"int64"), iString:=NumGet(btn,24,"int64")
DllCall("ReadProcessMemory", "Uint", hProc, "Uint", dwData, "Uint", &nfo, "Uint", 32, "Uint", 0)
If NumGet(btn,12)
hWnd := NumGet(nfo, 0)
, uID := NumGet(nfo, 4)
, nMsg := NumGet(nfo, 8)
, hIcon := NumGet(nfo,20)
Else hWnd := NumGet(nfo, 0,"int64"), uID:=NumGet(nfo, 8), nMsg:=NumGet(nfo,12)
WinGet, pid, PID, ahk_id %hWnd%
WinGet, sProcess, ProcessName, ahk_id %hWnd%
WinGetClass, sClass, ahk_id %hWnd%
If !sExeName || (sExeName = sProcess) || (sExeName = pid)
VarSetCapacity(sTooltip,128), VarSetCapacity(wTooltip,128*2)
, DllCall("ReadProcessMemory", "Uint", hProc, "Uint", iString, "Uint", &wTooltip, "Uint", 128*2, "Uint", 0)
, DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "str", wTooltip, "int", -1, "str", sTooltip, "int", 128, "Uint", 0, "Uint", 0)
, sTrayIcons .= "idx: " . A_Index-1 . " | idn: " . idn . " | Pid: " . pid . " | uID: " . uID . " | MessageID: " . nMsg . " | hWnd: " . hWnd . " | Class: " . sClass . " | Process: " . sProcess . "`n" . " | Tooltip: " . wTooltip . "`n"
}
DllCall("VirtualFreeEx", "Uint", hProc, "Uint", pProc, "Uint", 0, "Uint", 0x8000)
DllCall("CloseHandle", "Uint", hProc)
if InStr(sTooltip,"ropbox")>0
{
Return sTooltip
}
Return wTooltip ;sTrayIcons
}
GetTrayBar()
{
ControlGet, hParent, hWnd,, TrayNotifyWnd1 , ahk_class Shell_TrayWnd
ControlGet, hChild , hWnd,, ToolbarWindow321, ahk_id %hParent%
Loop
{
ControlGet, hWnd, hWnd,, ToolbarWindow32%A_Index%, ahk_class Shell_TrayWnd
If Not hWnd
Break
Else If hWnd = %hChild%
{
idxTB := A_Index
Break
}
}
Return idxTB
}
up2date(){
if (RegExMatch(TrayIcons("Dropbox.exe"), "Aktualisiert")>0) {
Return true
}
if (RegExMatch(TrayIcons("Dropbox.exe"), "Up to date")>0) {
Return true
}
if (RegExMatch(TrayIcons("Dropbox.exe"), "Actualizado")>0) {
Return true
}
if (RegExMatch(TrayIcons("Dropbox.exe"), "À jour")>0) {
Return true
}
if (RegExMatch(TrayIcons("Dropbox.exe"), "Aggiornato")>0) {
Return true
}
if (RegExMatch(TrayIcons("Dropbox.exe"), "Mutakhir")>0) {
Return true
}
if (RegExMatch(TrayIcons("Dropbox.exe"), "Terkini")>0) {
Return true
}
if (RegExMatch(TrayIcons("Dropbox.exe"), "Aktualny")>0) {
Return true
}
if (RegExMatch(TrayIcons("Dropbox.exe"), "Atualizado")>0) {
Return true
}
Return false
}
;-----------------------------------------------------------------------
Gui, Add, Text, x52 y20 w320 h50 +Center vDbstatus, starting...
Gui, Font, S10 CDefault, Verdana
Gui, Add, Button, x112 y70 w200 h50 , exit
Gui, Show, x127 y87 h124 w414, Shutdown when Dropbox ist up to date
;-----------------------------------------------------------------------
Seconds=30
altName=close
otravez:
output = % TrayIcons("Dropbox.exe")
GuiControl,, Dbstatus,%output%
if (up2date()){
Seconds-=1
GuiControl,, shutdown,shutdown in %Seconds% `n(click to cancel)
GuiControl,, exit,shutdown in %Seconds% `n(click to cancel)
if (Seconds<1)
{
Shutdown, 9
ExitApp
}
}else{
GuiControl,, shutdown,exit
Seconds=30
sleep 1000
goto, otravez
}
;-----------------------------------------------------------------------
Buttonclose:
Buttonshutdown:
Buttonexit:
GuiClose:
ExitApp
[/color]
copiar y pegar en un archiv de texto .ahk. Luego compilarlo con AutoHotKey ( http://www.autohotkey.com/ )