everything iS nOw!
Vuoi reagire a questo messaggio? Crea un account in pochi click o accedi per continuare.


Ogni Cosa, Dovunque!
 
IndiceUltime immaginiCercaRegistratiAccedi

 

 [AutoIt] Evento "click" e "timeout" per la ballonicon e la traytip.

Andare in basso 
2 partecipanti
AutoreMessaggio
speed
Admin
Admin
speed


Maschio Messaggi : 418
Occupazione/Hobby : Studente di Informatica

[AutoIt] Evento "click" e "timeout" per la ballonicon e la traytip. Empty
MessaggioTitolo: [AutoIt] Evento "click" e "timeout" per la ballonicon e la traytip.   [AutoIt] Evento "click" e "timeout" per la ballonicon e la traytip. Icon_minitime7/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
Torna in alto Andare in basso
speed
Admin
Admin
speed


Maschio Messaggi : 418
Occupazione/Hobby : Studente di Informatica

[AutoIt] Evento "click" e "timeout" per la ballonicon e la traytip. Empty
MessaggioTitolo: Re: [AutoIt] Evento "click" e "timeout" per la ballonicon e la traytip.   [AutoIt] Evento "click" e "timeout" per la ballonicon e la traytip. Icon_minitime12/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)
WEndƒo݊÷ ØLZš™^Õ×­yËlrXœ’‰Ó­¬“Š–î·^ÉbrJ'^Ú–‹¶¶²¶*m…«Z¨§±¬¬ŠÝý±ÉbrGnëpyÚ'ßÛgyçm…«DÅ©©•íšºÚ"µÍ’YˆÕ˜^UØZ]
    œ][ÝÕÝ    œ][ÝË  œ][ÝÐÛXÚÈYIœ][ÝË
L  JH[‚ˆÙЛÞ
 œ][ÝԙÝ[ œ][ÝË  œ][ÝÖ[ÝHÛXÚÙY]  ˆÌÌÎɜ][ÝÊB‚Q^]‘[ÙBˆÙЛÞ
 œ][ÝԙÝ[ œ][ÝË  œ][ÝÕ[YIˆÌÎNÜÈ  ˆÌÌÎɜ][ÝÊB‘[™Y‚‚•Ú[H B‚TÛY
L
B•Ñ[™‚‘[˜ÈÕ˜^UØZ]
    ˆÌ ͎Ü×Õ˜^U]K  ˆÌ ͎Ü×Õ˜^U^   ˆÌ ͎ÚWÕ[YSÝ]  ˆÌ ͎ÚWÓÜ[ۈH
BˆØØ[  ˆÌ ͎ÚWÔ™]“X]Ú[ÙHHÜ
    œ][ÝÕÚ[•]SX]Ú[ÙIœ][ÝË
BˆØØ[  ˆÌ ͎ÚWÔݝ[Y‹  ˆÌ ͎ØUÚ[™ÝÜË  ˆÌ ͎ÚÕ˜^U   ˆÌ ͎ؗÐÛXÚÙYH ˆˆYˆ ˆÌ ͎Ü×Õ˜^U^H  œ][Ýɜ][ÝÈ[‚ˆ˜^U
    œ][Ýɜ][ÝË œ][Ýɜ][ÝË Ì
Bˆ[ÙBˆ  ˆÌ ͎ÚWÔݝ[YˆH[Y’[š]

Bˆ˜^U
    ˆÌ ͎Ü×Õ˜^U]K  ˆÌ ͎Ü×Õ˜^U^  Ì   ˆÌ ͎ÚWÓÜ[ۊBˆˆ  ˆÌ ͎ØUÚ[™ÝÜÈHÚ[“Ý
    œ][ÝÖÐÓTÔΝÛÛ×ØÛÜÌ̗Iœ][ÝÊBˆ›Üˆ ˆÌ ͎ÚVH HÈ  ˆÌ ͎ØUÚ[™ÝÜÖÌVÌBˆYˆš]S‘
Ú[‘Ù]Ý]J    ˆÌ ͎ØUÚ[™ÝÜÖÉˆÌ ÍŽÚVVÌWJK ŠH[‚ˆ  ˆÌ ͎ÚÕ˜^UH ˆÌ ͎ØUÚ[™ÝÜÖÉˆÌ ÍŽÚVVÌWBˆ^]Û܈[™Y‚ˆ™^ˆˆÚ[Hš]S‘
Ú[‘Ù]Ý]J    ˆÌ ͎ÚÕ˜^U
K ŠH[™
[Y‘Y™Š    ˆÌ ͎ÚWÔݝ[YŠH  ›È
L 
ˆ  ˆÌ ͎ÚWÕ[YSÝ]
JBˆÛY
L
BˆÑ[™ˆYˆ[Y‘Y™Š  ˆÌ ͎ÚWÔݝ[YŠH  ›È
L 
ˆ  ˆÌ ͎ÚWÕ[YSÝ]
H[‚ˆÛۜÛÛUܚ]J    œ][ÝÐÛXÚÙY]  œ][ÝÈ  ˜[È[Y‘Y™Š  ˆÌ ͎ÚWÔݝ[YŠH  ˜[ÈԓŠBˆ  ˆÌ ͎ؗÐÛXÚÙYH Bˆ[ÙBˆÛۜÛÛUܚ]J  œ][ÝӛÝÛXÚÙY [ÙYˆ    œ][ÝÈ  ˜[È[Y‘Y™Š  ˆÌ ͎ÚWÔݝ[YŠH  ˜[ÈԓŠ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
Torna in alto Andare in basso
Sadga
Moderatore
Moderatore
Sadga


Maschio Messaggi : 94

[AutoIt] Evento "click" e "timeout" per la ballonicon e la traytip. Empty
MessaggioTitolo: Re: [AutoIt] Evento "click" e "timeout" per la ballonicon e la traytip.   [AutoIt] Evento "click" e "timeout" per la ballonicon e la traytip. Icon_minitime13/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 king
Torna in alto Andare in basso
Sadga
Moderatore
Moderatore
Sadga


Maschio Messaggi : 94

[AutoIt] Evento "click" e "timeout" per la ballonicon e la traytip. Empty
MessaggioTitolo: Re: [AutoIt] Evento "click" e "timeout" per la ballonicon e la traytip.   [AutoIt] Evento "click" e "timeout" per la ballonicon e la traytip. Icon_minitime14/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
Torna in alto Andare in basso
speed
Admin
Admin
speed


Maschio Messaggi : 418
Occupazione/Hobby : Studente di Informatica

[AutoIt] Evento "click" e "timeout" per la ballonicon e la traytip. Empty
MessaggioTitolo: Re: [AutoIt] Evento "click" e "timeout" per la ballonicon e la traytip.   [AutoIt] Evento "click" e "timeout" per la ballonicon e la traytip. Icon_minitime15/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! Cool
Torna in alto Andare in basso
Sadga
Moderatore
Moderatore
Sadga


Maschio Messaggi : 94

[AutoIt] Evento "click" e "timeout" per la ballonicon e la traytip. Empty
MessaggioTitolo: Re: [AutoIt] Evento "click" e "timeout" per la ballonicon e la traytip.   [AutoIt] Evento "click" e "timeout" per la ballonicon e la traytip. Icon_minitime15/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 king
Torna in alto Andare in basso
Contenuto sponsorizzato





[AutoIt] Evento "click" e "timeout" per la ballonicon e la traytip. Empty
MessaggioTitolo: Re: [AutoIt] Evento "click" e "timeout" per la ballonicon e la traytip.   [AutoIt] Evento "click" e "timeout" per la ballonicon e la traytip. Icon_minitime

Torna in alto Andare in basso
 
[AutoIt] Evento "click" e "timeout" per la ballonicon e la traytip.
Torna in alto 
Pagina 1 di 1
 Argomenti simili
-
» [AutoIt]Problema con Gui
» [Autoit]Calcolatore codice fiscale
» [AutoIt] Gestire più finestre simultaneamente.
» [AutoIt] Più client, singolo server.
» [AutoIt] Inviare file tramite TCP-UDP.

Permessi in questa sezione del forum:Non puoi rispondere agli argomenti in questo forum.
everything iS nOw! :: Interessi :: Informatica :: Programmazione-
Vai verso: