Nahuel Posted September 22, 2007 Share Posted September 22, 2007 (edited) 1º- Here's my script:expandcollapse popup#include <string.au3> #include <Guiconstants.au3> #include <Constants.au3> #include <Misc.au3> #Include <GuiEdit.au3> #include <File.au3> _Singleton("DesktopStickyNotes") Opt("TrayMenuMode", 1) Opt("TrayAutoPause", 0) Opt("WinTitleMatchMode", 2) Opt("GUICloseOnESC", 0) TraySetClick(8) Global $n = 0 Global $a = 0 Global $moving Global $notaEnGui Global $comp=1 Global $Restore=0 If FileExists("*.restore") then RestaurarNotas() $Restore=1 EndIf $OK=0 $Main=GUICreate("",200,200,-1,-1,-1,BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW)) GUICtrlCreateLabel("Type the StickyNote title:",5,5) $InputTitulo=GUICtrlCreateEdit("",5,22,190,25, $ES_AUTOVSCROLL + $WS_VSCROLL + $ES_MULTILINE + $ES_WANTRETURN) GUICtrlCreateLabel("Type the StickyNote body:",5,52) $Input=GUICtrlCreateEdit("",5,70,190,80, $ES_AUTOVSCROLL + $WS_VSCROLL + $ES_MULTILINE + $ES_WANTRETURN) $OkBut=GUICtrlCreateButton("&OK",5,160,190,-1,$BS_DEFPUSHBUTTON ) $Mensaje=GUICtrlRead($Input) $NotaTitulo=GUICtrlRead($InputTitulo) If not $restore Then GUISetState(@SW_SHOW,$Main) EndIf AnimateTitle($Main, "Desktop StickyNotes! - Nahuel", 100) $NuevaNota = TrayCreateItem("New StickyNote") TrayCreateItem("") $Exit = TrayCreateItem("Save StickyNotes and Exit") While 1 Sleep(10) $msgT = TrayGetMsg() $msg = GUIGetMsg(1) Select Case $msgT = $Exit If WinExists("- StickyNote") Then $WinList=WinList("- StickyNote") For $b=1 to $WinList[0][0] GUIDelete($WinList[$b][1]) Next GUIDelete($Main) TrayTip("StickyNotes saved","StickyNotes that haven't been closed were saved to restore"&@CRLF&"when Desktop StickyNotes is opened again",2000) Sleep(3500) EndIf Exit Case $msgT = $NuevaNota Or $msgT = $TRAY_EVENT_PRIMARYDOUBLE WinSetState($Main,"",@SW_SHOW) Case $msg[0] = $GUI_EVENT_CLOSE If $msg[1]=$Main Then WinSetState($Main,"",@SW_HIDE) Else $NotaH=WinGetTitle($msg[1]) $NotaNa=StringTrimRight($NotaH,13) FileDelete(@ScriptDir&"\"&$NotaNa&".restore") GUIDelete($msg[1]) EndIf Case $msg[0] = $GUI_EVENT_SECONDARYDOWN $Title=WinGetTitle($msg[1]) $NotaNombre=StringTrimRight($Title,13) $hGUI=GUICreate("Sttings for "&$NotaNombre,220,90,-1,-1,-1,BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW),$msg[1]) GUICtrlCreateGroup(" Transparency ",5,10,210,65) $slider = GUICtrlCreateSlider (10,25,200,20) GUICtrlSetData(-1,170) GUICtrlSetLimit(-1,255,0) GUICtrlCreateLabel("Transparent",10,50) GUICtrlCreateLabel("Solid",180,50) GUISetState() while 1 $msg1=GUIGetMsg(1) if $msg1[0]=$slider Then WinSetTrans($msg[1],"",GUictrlread($slider)) EndIf if $msg1[0]=$GUI_EVENT_CLOSE Then $NotaH=WinGetTitle($msg1[1]) $NotaNombre=StringTrimRight($NotaH,13) FileDelete(@ScriptDir&"\"&$NotaNombre&".restore") GUIDelete($msg1[1]) ExitLoop EndIf WEnd Case $msg[0] = $GUI_EVENT_PRIMARYDOWN If $msg[1]=$Main Then Else If $moving <> $GUI_EVENT_MOUSEMOVE Then $moving = $GUI_EVENT_MOUSEMOVE Opt("MouseCoordMode", 0) $mousePos = MouseGetPos() Opt("MouseCoordMode", 1) _WinDrag() EndIf EndIf Case $msg[0] = $OkBut WinSetState($msg[1],"",@sw_hide) $Mensaje=GUICtrlRead($Input) $NotaTitulo=GUICtrlRead($InputTitulo) crearnota($NotaTitulo,$Mensaje) EndSelect WEnd Func crearnota($oTitulo,$oCuerpo) If $oTitulo="" Then MsgBox(64,"Oops!","You must enter a title!") WinSetState($Main,"",@SW_SHOW) Return EndIf If $oCuerpo="" Then MsgBox(64,"Oops!","You must enter a StickyNote!") WinSetState($Main,"",@SW_SHOW) Return EndIf $WinList=WinList("- StickyNote") For $b=1 to $WinList[0][0] $comp=StringCompare($oTitulo&" - StickyNote",$WinList[$b][0]) If $comp=0 Then MsgBox(64,"Oops!","There's already a StickyNote with that title!") WinSetState($Main,"",@SW_SHOW) Return EndIf Next $n+=1 $hGUI = GUICreate($oTitulo&" - StickyNote", 200, 200, $n*10, $n*10,$WS_OVERLAPPEDWINDOW,BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW)) GUISetBkColor(0xFFFFAD) $NotaEnGui=GUICtrlCreateLabel($oCuerpo,0,0,200,200,$SS_CENTER) GUICtrlSetFont($NotaEnGui, 25, 700, "", "Script") $moving = $NotaEnGui WinSetTrans($hGUI, "", 170) GUISetState(@SW_SHOW, $hGUI) FileWrite($oTitulo&".restore",$oCuerpo) FileSetAttrib($oTitulo&".restore","H") EndFunc Func _WinDrag() Do $pos = MouseGetPos() $winPos = WinGetPos($msg[1]) If $pos[0] - $mousePos[0] < 0 Then $x = 0 ElseIf $winPos[2] - $mousePos[0] + $pos[0] > @DesktopWidth Then $x = @DesktopWidth - $winPos[2] Else $x = $pos[0] - $mousepos[0] EndIf If $pos[1] - $mousePos[1] < 0 Then $y = 0 ElseIf $winPos[3] - $mousePos[1] + $pos[1] > @DesktopHeight Then $y = @DesktopHeight - $winPos[3] Else $y = $pos[1] - $mousepos[1] EndIf WinMove($msg[1], '', $x, $y) Until not _IsPressed(01) $moving = $NotaEnGui EndFunc;===>WinDrag() Func AnimateTitle($GuiHand, $sTitle, $iBuf) $sTitle = StringSplit($sTitle, "") For $i = $iBuf To 0 Step - 1 Sleep(5) WinSetTitle($GuiHand, "", _StringRepeat(" ", $i) & $sTitle[1]) Next Local $s For $i = 1 To $sTitle[0] Sleep(10) $s &= $sTitle[$i] WinSetTitle($GuiHand, "", $s) Next EndFunc Func restaurarNotas() $FileList=_FileListToArray(@scriptdir,"*.restore") For $i=1 to $FileList[0] $n+=1 $MensajeF=FileRead($FileList[$I]) $NombreTitulo=StringSplit($FileList[$I],".") $hGUI = GUICreate($NombreTitulo[1]&" - StickyNote", 200, 200, $n*10, $n*10,$WS_OVERLAPPEDWINDOW,BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW)) GUISetBkColor(0xFFFFAD) $NotaEnGui=GUICtrlCreateLabel($MensajeF,0,0,200,200,$SS_CENTER) GUICtrlSetFont($NotaEnGui, 25, 700, "", "Script") $moving = $NotaEnGui WinSetTrans($hGUI, "", 170) GUISetState(@SW_SHOW, $hGUI) Next EndFunc2º- I need you to the following to see what my problem is:Run the script. You'll see the main GUI.Enter a title and a note, anything you want. A yellow 'stickynote' will be created.Now, without closing the yellow stickynote, go to the tray icon and press "save stickynotes and exit". A traytip will tell you that the notes that weren't closed have been saved. Run the script again. You'll see the note that you created before but not the main GUI.And the problem is in this last step. I don't want it to show me the main GUI if there are notes that have been restored, but when I doubleclick the tray item to make it visible, the 'OK' button doesn't work anymore... This DOESN'T happen if I don't use this:If not $restore Then GUISetState(@SW_SHOW,$Main) EndIfI really don't understand why.. sorry for such a long post, but it's really driving me crazy. Edited September 22, 2007 by Nahuel Link to comment Share on other sites More sharing options...
Valuater Posted September 22, 2007 Share Posted September 22, 2007 This works... *****TESTED OK!! change If not $restore Then GUISetState(@SW_SHOW,$Main) EndIfoÝ÷ ÚÚºÚ"µÍYÝ ÌÍÜÝÜH[ÕRTÙ]Ý]JÕ×ÔÒÕË ÌÍÓXZ[B[ÙBÕRTÙ]Ý]JÕ×ÒQK ÌÍÓXZ[B[Y 8) Link to comment Share on other sites More sharing options...
Nahuel Posted September 22, 2007 Author Share Posted September 22, 2007 Thanks, but I did that already. The same thing happens Link to comment Share on other sites More sharing options...
meekaah Posted September 22, 2007 Share Posted September 22, 2007 yeah i had some problems similar to that... seems just like the script went into a loop it cant leave.. Link to comment Share on other sites More sharing options...
Nahuel Posted September 22, 2007 Author Share Posted September 22, 2007 Yes, that's what I thought! But the weird thing is that I can close the main Gui, meaning that WinGetMsg() IS working. The only problem seems to be the $OkBut message... Link to comment Share on other sites More sharing options...
Valuater Posted September 22, 2007 Share Posted September 22, 2007 ******** FIXED ******* expandcollapse popup#include <string.au3> #include <Guiconstants.au3> #include <Constants.au3> #include <Misc.au3> ;#Include <GuiEdit.au3> #include <File.au3> _Singleton("DesktopStickyNotes") ;Opt("TrayIconDebug", 1) Opt("TrayMenuMode", 1) Opt("TrayAutoPause", 0) Opt("WinTitleMatchMode", 2) Opt("GUICloseOnESC", 0) TraySetClick(8) Global $n = 0 Global $a = 0 Global $moving Global $notaEnGui Global $comp=1 Global $Restore=0 If FileExists("*.restore") then RestaurarNotas() $Restore=1 EndIf $OK=0 $Main=GUICreate("",200,200,-1,-1,-1,BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW)) GUICtrlCreateLabel("Type the StickyNote title:",5,5) $InputTitulo=GUICtrlCreateEdit("",5,22,190,25, $ES_AUTOVSCROLL + $WS_VSCROLL + $ES_MULTILINE + $ES_WANTRETURN) GUICtrlCreateLabel("Type the StickyNote body:",5,52) $Input=GUICtrlCreateEdit("",5,70,190,80, $ES_AUTOVSCROLL + $WS_VSCROLL + $ES_MULTILINE + $ES_WANTRETURN) $OkBut=GUICtrlCreateButton("&OK",5,160,190,-1,$BS_DEFPUSHBUTTON ) $Mensaje=GUICtrlRead($Input) $NotaTitulo=GUICtrlRead($InputTitulo) If not $restore Then GUISetState(@SW_SHOW,$Main) Else GUISetState(@SW_HIDE,$Main) EndIf AnimateTitle($Main, "Desktop StickyNotes! - Nahuel", 100) $NuevaNota = TrayCreateItem("New StickyNote") TrayCreateItem("") $Exit = TrayCreateItem("Save StickyNotes and Exit") While 1 Sleep(10) $msgT = TrayGetMsg() $msg = GUIGetMsg(1) Select Case $msgT = $Exit If WinExists("- StickyNote") Then $WinList=WinList("- StickyNote") For $b=1 to $WinList[0][0] GUIDelete($WinList[$b][1]) Next GUIDelete($Main) TrayTip("StickyNotes saved","StickyNotes that haven't been closed were saved to restore"&@CRLF&"when Desktop StickyNotes is opened again",2000) Sleep(3500) EndIf Exit Case $msgT = $NuevaNota Or $msgT = $TRAY_EVENT_PRIMARYDOUBLE GUISetState(@SW_SHOW,$Main) Case $msg[0] = $GUI_EVENT_CLOSE If $msg[1]=$Main Then GUISetState(@SW_HIDE,$Main) Else $NotaH=WinGetTitle($msg[1]) $NotaNa=StringTrimRight($NotaH,13) FileDelete(@ScriptDir&"\"&$NotaNa&".restore") GUIDelete($msg[1]) EndIf Case $msg[0] = $GUI_EVENT_SECONDARYDOWN $Title=WinGetTitle($msg[1]) $NotaNombre=StringTrimRight($Title,13) $hGUI=GUICreate("Sttings for "&$NotaNombre,220,90,-1,-1,-1,BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW),$msg[1]) GUICtrlCreateGroup(" Transparency ",5,10,210,65) $slider = GUICtrlCreateSlider (10,25,200,20) GUICtrlSetData(-1,170) GUICtrlSetLimit(-1,255,0) GUICtrlCreateLabel("Transparent",10,50) GUICtrlCreateLabel("Solid",180,50) GUISetState(@SW_SHOW, $Title) while 1 $msg1=GUIGetMsg(1) if $msg1[0]=$slider Then WinSetTrans($msg[1],"",GUictrlread($slider)) EndIf if $msg1[0]=$GUI_EVENT_CLOSE Then $NotaH=WinGetTitle($msg1[1]) $NotaNombre=StringTrimRight($NotaH,13) FileDelete(@ScriptDir&"\"&$NotaNombre&".restore") GUIDelete($msg1[1]) ExitLoop EndIf WEnd #cs Case $msg[0] = $GUI_EVENT_PRIMARYDOWN If $msg[1]=$Main Then Else If $moving <> $GUI_EVENT_MOUSEMOVE Then $moving = $GUI_EVENT_MOUSEMOVE Opt("MouseCoordMode", 0) $mousePos = MouseGetPos() Opt("MouseCoordMode", 1) _WinDrag() EndIf EndIf #ce Case $msg[0] = $OkBut GUISetState(@SW_HIDE,$Main) $Mensaje=GUICtrlRead($Input) $NotaTitulo=GUICtrlRead($InputTitulo) crearnota($NotaTitulo,$Mensaje) EndSelect WEnd Func crearnota($oTitulo,$oCuerpo) If $oTitulo="" Then MsgBox(64,"Oops!","You must enter a title!") GUISetState(@SW_SHOW,$Main) Return EndIf If $oCuerpo="" Then MsgBox(64,"Oops!","You must enter a StickyNote!") GUISetState(@SW_SHOW,$Main) Return EndIf $WinList=WinList("- StickyNote") For $b=1 to $WinList[0][0] $comp=StringCompare($oTitulo&" - StickyNote",$WinList[$b][0]) If $comp=0 Then MsgBox(64,"Oops!","There's already a StickyNote with that title!") GUISetState(@SW_SHOW,$Main) Return EndIf Next $n+=1 $hGUI = GUICreate($oTitulo&" - StickyNote", 200, 200, $n*10, $n*10,$WS_OVERLAPPEDWINDOW,BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW)) GUISetBkColor(0xFFFFAD) $NotaEnGui=GUICtrlCreateLabel($oCuerpo,0,0,200,200,$SS_CENTER) GUICtrlSetFont($NotaEnGui, 25, 700, "", "Script") $moving = $NotaEnGui WinSetTrans($hGUI, "", 170) GUISetState(@SW_SHOW, $hGUI) FileWrite($oTitulo&".restore",$oCuerpo) FileSetAttrib($oTitulo&".restore","H") EndFunc #cs Func _WinDrag() Do $pos = MouseGetPos() $winPos = WinGetPos($msg[1]) If $pos[0] - $mousePos[0] < 0 Then $x = 0 ElseIf $winPos[2] - $mousePos[0] + $pos[0] > @DesktopWidth Then $x = @DesktopWidth - $winPos[2] Else $x = $pos[0] - $mousepos[0] EndIf If $pos[1] - $mousePos[1] < 0 Then $y = 0 ElseIf $winPos[3] - $mousePos[1] + $pos[1] > @DesktopHeight Then $y = @DesktopHeight - $winPos[3] Else $y = $pos[1] - $mousepos[1] EndIf WinMove($msg[1], '', $x, $y) Until not _IsPressed(01) $moving = $NotaEnGui EndFunc;===>WinDrag() #ce Func AnimateTitle($GuiHand, $sTitle, $iBuf) $sTitle = StringSplit($sTitle, "") For $i = $iBuf To 0 Step - 1 Sleep(5) WinSetTitle($GuiHand, "", _StringRepeat(" ", $i) & $sTitle[1]) Next Local $s For $i = 1 To $sTitle[0] Sleep(10) $s &= $sTitle[$i] WinSetTitle($GuiHand, "", $s) Next EndFunc Func restaurarNotas() $FileList=_FileListToArray(@scriptdir,"*.restore") For $i=1 to $FileList[0] $n+=1 $MensajeF=FileRead($FileList[$I]) $NombreTitulo=StringSplit($FileList[$I],".") $hGUI = GUICreate($NombreTitulo[1]&" - StickyNote", 200, 200, $n*10, $n*10,$WS_OVERLAPPEDWINDOW,BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW)) GUISetBkColor(0xFFFFAD) $NotaEnGui=GUICtrlCreateLabel($MensajeF,0,0,200,200,$SS_CENTER) GUICtrlSetFont($NotaEnGui, 25, 700, "", "Script") $moving = $NotaEnGui WinSetTrans($hGUI, "", 170) GUISetState(@SW_SHOW, $hGUI) Next EndFunc 8) Link to comment Share on other sites More sharing options...
Nahuel Posted September 22, 2007 Author Share Posted September 22, 2007 OOOHHH So there it was! Thank you! I got to find another way now, so I can make them dragable, hehe. Link to comment Share on other sites More sharing options...
Nahuel Posted September 22, 2007 Author Share Posted September 22, 2007 OOOHHH So there it was! Thank you! I got to find another way now, so I can make them dragable, hehe. Link to comment Share on other sites More sharing options...
Valuater Posted September 22, 2007 Share Posted September 22, 2007 What's not drag-able???? 8) Link to comment Share on other sites More sharing options...
Nahuel Posted September 22, 2007 Author Share Posted September 22, 2007 You commented the _WinDrag() function. I thought it had a problem too. I uncommented and it works perfectly. Thanks a lot! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now