Ogni Cosa, Dovunque! |
| | [AutoIt] Evento "click" e "timeout" per la ballonicon e la traytip. | |
| | Autore | Messaggio |
---|
speed Admin
Messaggi : 418 Occupazione/Hobby : Studente di Informatica
| Titolo: [AutoIt] Evento "click" e "timeout" per la ballonicon e la traytip. 7/2/2011, 2:50 pm | |
| se avete un po' di tempo, potete postarmi un po' di sano codice dove vengono controllati gli eventi "click" e "timeout" di una ballontip nella traytip con autoit?
grazie per l'aiuto e per il tempo!
aspetto qualche esempio che mi chiarisca le idee, se qualcuno se n'intende, certamente!
:-D | |
| | | speed Admin
Messaggi : 418 Occupazione/Hobby : Studente di Informatica
| Titolo: Re: [AutoIt] Evento "click" e "timeout" per la ballonicon e la traytip. 12/2/2011, 9:39 pm | |
| ho trovato qualcosa in merito, ma non è proprio il massimo! anche perchè il codice funziona, ma è "poco leggibile" e non personalizzabile come io invece vorrei. magari voi riuscite a capirci qualcosa, ve lo posto: - Codice:
-
#include <Constants.au3> #include <GuiToolTip.au3> #include <WinAPI.au3> #include <WindowsConstants.au3>
Dim $iInterval = 8, $iInit Dim $iMSInterval = $iInterval * 1000 Dim $aWindows, $hShell_TrayWnd
TrayTip('Title', 'Text', $iInterval)
$aWindows = WinList('[CLASS:tooltips_class32]') $hShell_TrayWnd = WinGetHandle('[CLASS:Shell_TrayWnd]')
For $i = 1 To $aWindows[0][0] If _WinAPI_GetParent($aWindows[$i][1]) = $hShell_TrayWnd And _ BitAND(_WinAPI_GetWindowLong($aWindows[$i][1], $GWL_STYLE), $WS_VISIBLE) Then ExitLoop EndIf Next
$iInit = TimerInit()
While TimerDiff($iInit) <= $iMSInterval If Not _GUIToolTip_ToolExists($aWindows[$i][1]) Then MsgBox(64, 'Notification', 'ToolTip was clicked') ExitLoop EndIf Sleep(50) WEndoÝ÷ ØLZ^Õ×yËlrXÓ¬î·^ÉbrJ'^Ú¶¶²¶*m
«Z¨§±¬¬Ýý±ÉbrGnëpyÚ'ßÛgyçm
«DÅ©©íºÚ"µÍYÕ^UØZ] ][ÝÕÝ ][ÝË ][ÝÐÛXÚÈYI][ÝË LJH[ÙÐÞ ][ÝÔÝ[ ][ÝË ][ÝÖ[ÝHÛXÚÙY] ÌÌÎÉ][ÝÊBQ^][ÙBÙÐÞ ][ÝÔÝ[ ][ÝË ][ÝÕ[YIÌÎNÜÈ ÌÌÎÉ][ÝÊB[YÚ[HBTÛY L BÑ[[ÈÕ^UØZ] ÌÍÜ×Õ^U]K ÌÍÜ×Õ^U^ ÌÍÚWÕ[YSÝ] ÌÍÚWÓÜ[ÛH BØØ[ ÌÍÚWÔ]X]Ú[ÙHHÜ ][ÝÕÚ[]SX]Ú[ÙI][ÝË BØØ[ ÌÍÚWÔÝ[Y ÌÍØUÚ[ÝÜË ÌÍÚÕ^U ÌÍØÐÛXÚÙYHY ÌÍÜ×Õ^U^H ][ÝÉ][ÝÈ[^U ][ÝÉ][ÝË ][ÝÉ][ÝËÌ B[ÙB ÌÍÚWÔÝ[YH[Y[]
B^U ÌÍÜ×Õ^U]K ÌÍÜ×Õ^U^Ì ÌÍÚWÓÜ[ÛB ÌÍØUÚ[ÝÜÈHÚ[Ý ][ÝÖÐÓTÔÎÛÛ×ØÛÜÌÌI][ÝÊBÜ ÌÍÚVHHÈ ÌÍØUÚ[ÝÜÖÌVÌBY]S Ú[Ù]Ý]J ÌÍØUÚ[ÝÜÖÉÌÍÚVVÌWJKH[ ÌÍÚÕ^UH ÌÍØUÚ[ÝÜÖÉÌÍÚVVÌWB^]ÛÜ[Y^Ú[H]S Ú[Ù]Ý]J ÌÍÚÕ^U KH[ [YY ÌÍÚWÔÝ[YH È L ÌÍÚWÕ[YSÝ] JBÛY L BÑ[Y[YY ÌÍÚWÔÝ[YH È L ÌÍÚWÕ[YSÝ] H[ÛÛÛÛUÜ]J ][ÝÐÛXÚÙY] ][ÝÈ [È[YY ÌÍÚWÔÝ[YH [ÈÔB ÌÍØÐÛXÚÙYHB[ÙBÛÛÛÛUÜ]J ][ÝÓÝÛXÚÙY[ÙY ][ÝÈ [È[YY ÌÍÚWÔÝ[YH [ÈÔB^U ][ÝÉ][ÝË ][ÝÉ][ÝËL B ÌÍØÐÛXÚÙYH[Y[YÜ ][ÝÕÚ[]SX]Ú[ÙI][ÝË ÌÍÚWÔ]X]Ú[ÙJB] ÌÍØÐÛXÚÙY[[ÈÏOIÝ×Õ^UØZ] oppure il codice "migliorato" secondo un altro utente: - Codice:
-
;Author: rover 07/04/09 ;MSDN reference: ;Shell_NotifyIcon Function ;http://msdn.microsoft.com/en-us/library/bb762159(VS.85).aspx #include <GUIConstantsEX.au3> #include <Constants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <StaticConstants.au3> Global Const $NIN_BALLOONTIMEOUT = $WM_USER + 4 Global Const $NIN_BALLOONUSERCLICK = $WM_USER + 5 ;Global Const $GWLP_WNDPROC = -4; for SetWindowLongPtr Global $wProcNew = 0, $wProcOld = 0, $iMsg, $iError = 0 ;get handle to AutoIt v3 hidden gui Global $hGUI1 = _AutoItWinGetHandle() ;$hGUI1 = WinGetHandle(AutoItWinGetTitle()) ;will work without GUICreate but global vars must be set in WndProc instead of GUICtrlCreateDummy/GUICtrlSendToDummy ;NOTE: _WinAPI_SetWindowLong() in WinAPI.au3 consistently returns 'The specified procedure could not be found' error 127 ;error is due to the call being SetWindowLong instead of SetWindowLongW, ;using SetWindowLongW the error message is 'The operation completed successfully. Global $hGUI2 = GUICreate("Traytip click detect", 260, 150, @DesktopWidth - 400, @DesktopHeight - 300) Global $cTooltipClose = GUICtrlCreateDummy() Global $cTooltipClick = GUICtrlCreateDummy() Global $cLabel1 = GUICtrlCreateLabel("Traytip area clicked", 70, 80, 120, 16, $SS_CENTER) Global $cLabel2 = GUICtrlCreateLabel("", 10, 110, 240, 16, $SS_CENTER) GUICtrlSetBkColor(-1, 0xFFFFFF) Global $cButton = GUICtrlCreateButton("Create Traytip", 70, 30, 120, 25) GUISetState() ;subclass AutoIt v3 gui to get tray icon/traytip notifications _SubclassWin($hGUI1, $wProcNew, $wProcOld) Global $sLastError = _WinAPI_GetLastErrorMessage() ConsoleWrite('- GetLastErrorMessage ' & $sLastError & "- Error: " & _WinAPI_GetLastError() & @CRLF) ConsoleWrite('+$wProcOld = ' & $wProcOld & @CRLF) GUICtrlSetData($cLabel2, $sLastError) If StringInStr($sLastError, "Access is denied.") <> 0 Then GUICtrlSetBkColor($cLabel2, 0xFF0000) EndIf While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $cButton TrayTip("Clear", "", 1) TrayTip("I'm a title", "I'm the message", 5, 1) Case $cTooltipClick GUICtrlSetData($cLabel2, "") GUICtrlSetColor($cLabel2, 0x0000FF) Sleep(100) GUICtrlSetData($cLabel2, "Tooltip clicked") ConsoleWrite("!NIN_BALLOONUSERCLICK" & @CRLF) Case $cTooltipClose GUICtrlSetData($cLabel2, "") GUICtrlSetColor($cLabel2, 0xFF0000) Sleep(100) GUICtrlSetData($cLabel2, "Tooltip closed") ConsoleWrite("-NIN_BALLOONTIMEOUT" & @CRLF) Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _SubclassWin($hWnd, ByRef $hProcNew, ByRef $hProcOld) If $hProcNew <> 0 Or $hProcOld <> 0 Then Return SetError(1, 0, 0) $hProcNew = DllCallbackRegister("_AutoItWndProc", "int", "hwnd;uint;wparam;lparam") If @error Or $hProcNew = 0 Then Return SetError(2, 0, 0) $hProcOld = DllCall("User32.dll", "int", "SetWindowLongW", "hwnd", _ $hWnd, "int", $GWL_WNDPROC, "ptr", DllCallbackGetPtr($hProcNew)) If @error Or $hProcOld[0] = 0 Then $hProcOld = 0 Return SetError(3, 0, 0) EndIf $hProcOld = $hProcOld[0] Return SetError(0, 0, 1) EndFunc;==>_SubclassWin Func _RestoreWndProc($hWnd, ByRef $hProcNew, ByRef $hProcOld) If $hProcOld <> 0 Then _WinAPI_SetWindowLong($hWnd, $GWL_WNDPROC, $hProcOld) If $hProcNew <> 0 Then DllCallbackFree($hProcNew) $hProcNew = 0 $hProcOld = 0 EndFunc;==>_RestoreWndProc Func OnAutoItExit() _RestoreWndProc($hGUI1, $wProcNew, $wProcOld) EndFunc;==>OnAutoItExit Func _AutoItWndProc($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam, $ilParam Switch $iMsg Case $WM_USER + 1;AutoIt callback message value for tray icon (1025), can be retrieved with ReadProcessMemory and TRAYDATA struct Switch $ilParam Case $NIN_BALLOONTIMEOUT; timeout and by tooltip close icon GUICtrlSendToDummy($cTooltipClose) Case $NIN_BALLOONUSERCLICK GUICtrlSendToDummy($cTooltipClick) EndSwitch EndSwitch ; pass the unhandled messages to default WindowProc Return _WinAPI_CallWindowProc($wProcOld, $hWnd, $iMsg, $iwParam, $ilParam) EndFunc;==>_AutoItWndProc ;=============================================================================== ; ; Function Name: _AutoItWinGetHandle ; Description:: Returns the Windowhandle of AutoIT-Window ; Parameter(s): -- ; Requirement(s): -- ; Return Value(s): Autoitwindow Handle ; Author(s): Prog@ndy ; ;=============================================================================== ; Func _AutoItWinGetHandle() Local $oldTitle = AutoItWinGetTitle() Local $x = Random(1248578, 1249780) AutoItWinSetTitle("qwrzu" & $x) Local $x = WinGetHandle("qwrzu" & $x) AutoItWinSetTitle($oldTitle) Return $x EndFunc;==>_AutoItWinGetHandle | |
| | | Sadga Moderatore
Messaggi : 94
| Titolo: Re: [AutoIt] Evento "click" e "timeout" per la ballonicon e la traytip. 13/2/2011, 5:48 pm | |
| ho trovato un metodo molto più semplice e corto purtroppo non gestisce il timeout e la chiusura: - Codice:
-
#include <Constants.au3> #include <GuiToolTip.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <Process.au3>
Dim $iInterval = 8, $iInit Dim $iMSInterval = $iInterval * 1000 Dim $aWindows, $hShell_TrayWnd
TrayTip('Hei!!', 'Vieni a trovarci sul forum (clicca quì per aprirlo)', $iInterval);crea la traytip
$aWindows = WinList('[CLASS:tooltips_class32]');preleva una lista di tutte le finestre con il nome indicato $hShell_TrayWnd = WinGetHandle('[CLASS:Shell_TrayWnd]')
For $i = 1 To $aWindows[0][0] If _WinAPI_GetParent($aWindows[$i][1]) = $hShell_TrayWnd And _ BitAND(_WinAPI_GetWindowLong($aWindows[$i][1], $GWL_STYLE), $WS_VISIBLE) Then ExitLoop EndIf Next
$iInit = TimerInit()
While TimerDiff($iInit) <= $iMSInterval If Not _GUIToolTip_ToolExists($aWindows[$i][1]) Then _RunDos("start http://everything.forumattivo.it/");apre il forum con il browser predefinito ExitLoop EndIf Sleep(50) WEnd
;il resto (apparte le funzioni basilari) non riesco a capirlo... Saluti By | |
| | | Sadga Moderatore
Messaggi : 94
| Titolo: Re: [AutoIt] Evento "click" e "timeout" per la ballonicon e la traytip. 14/2/2011, 5:00 pm | |
| Questo secondo me è il migliore in assoluto l'ho creato io da zero secondo il mio criterio di funzionalità gestisce anche la chiusura e il timeout funzionante su windows 7 su gli altri non ho testato - Codice:
-
#include <Misc.au3> #include <Process.au3>
TrayTip("Clear","",1) TrayTip("Hey!!","Vienici a trovare sul forum!!",15,1);fà apparire la traytip Sleep(100) $handle=WinGetHandle("[Class:tooltips_class32]","");acquisisce l' handle della finestra tooltip error(@error)
$pos=WinGetPos($handle);trova la posizione della traytip error(@error)
$dll = DllOpen("user32.dll");avvia la dll che serve per far funzionare la funzione "_ispressed" error(@error)
$iInit = TimerInit() $corrisponde=False $soprax=False $soprach=False
While TimerDiff($iInit)<=13000 If _IsPressed("01", $dll) Then;controlla se viene premuto il tasto destro del mouse $mousepos=MouseGetPos() $corrisponde=($mousepos[0]>$pos[0] And $mousepos[0]<($pos[0]+$pos[2])) And ($mousepos[1]>$pos[1] And $mousepos[1]<($pos[1]+$pos[3]));controlla se il mouse è sopra alla traytip $soprax=(($mousepos[0]>(($pos[0]+$pos[2])-30) And $mousepos[0]<(($pos[0]+$pos[2])-15)) And ($mousepos[1]>($pos[1]+15) And $mousepos[1]<($pos[1]+30)));controlla se il mouse è sopra al pulsante chiudi $soprach=(($mousepos[0]>(($pos[0]+$pos[2])-45) And $mousepos[0]<(($pos[0]+$pos[2])-30)) And ($mousepos[1]>($pos[1]+15) And $mousepos[1]<($pos[1]+30)));controlla se il mouse è sopra al pulsante chiave inglese If ($corrisponde=True And $soprax=False And $soprach=False) Then;se il mouse è sopra alla traytip apre il forum MsgBox(0,"","click") ;~ _RunDos("start http://everything.forumattivo.it/") ExitLoop ElseIf ($soprax=True Or $soprach=True) Then MsgBox(0,"","chiuso") ExitLoop EndIf EndIf WEnd DllClose($dll)
TrayTip("Clear","",1)
If ($corrisponde=False And $soprax=False And $soprach=False) Then MsgBox(0,"","timeout") EndIf
Func error($error);funzione che trova un possibile errore If $error Then MsgBox(16,"Errore","Attenzione errore: "&$error);visualizza un msg di errore se viene rilevato un errore Exit EndIf EndFunc | |
| | | speed Admin
Messaggi : 418 Occupazione/Hobby : Studente di Informatica
| Titolo: Re: [AutoIt] Evento "click" e "timeout" per la ballonicon e la traytip. 15/2/2011, 6:14 pm | |
| ottimo! grande codice sorgente quello che hai modificato! alla grande! è normale che il timeout venga individuato dopo alcuni secondi e non subito dopo che il fumetto è scomparso? come già ti sarai accorto, anche premendo sulla "X" del fumetto viene individuato come un click; formalmente è giusto, ma praticamente temo di no! tuttavia, bravissimo! davvero! grazie milleeeee! | |
| | | Sadga Moderatore
Messaggi : 94
| Titolo: Re: [AutoIt] Evento "click" e "timeout" per la ballonicon e la traytip. 15/2/2011, 6:56 pm | |
| Il timeout è un problema da risolvere, si potrebbe diminuire il numero - Citazione :
- TimerDiff($iInit)<=13000
ad esempio a 12000 o11000 (12 o 11 secondi) anche quello della x è un problema ma purtroppo tuttora non ho la competenza per riuscire a risolverlo Saluti By | |
| | | Contenuto sponsorizzato
| Titolo: Re: [AutoIt] Evento "click" e "timeout" per la ballonicon e la traytip. | |
| |
| | | | [AutoIt] Evento "click" e "timeout" per la ballonicon e la traytip. | |
|
Argomenti simili | |
|
| Permessi in questa sezione del forum: | Non puoi rispondere agli argomenti in questo forum.
| |
| |
| |
|