Leaderboard
Popular Content
Showing content with the highest reputation on 06/04/2019 in all areas
-
so... it doesnt create a save.txt in the directory where the au3 resides? or it creates the file but the file doesnt have the contents? or the script doesnt work entirely? or you could tell us what "it doesnt work" means and I can put my magical crystal ball away.2 points
-
[NEW VERSION] - 2 Aug 18 Added: When specifying the icon to use, if the $vIcon parameter is set to the name of an ico or exe file, the main icon within will be displayed, but if a trailing "|" followed by the icon index is added to the name, that icon from within the file is used New UDF and example in the zip below. Details of previous versions: Changelog.txt A forum query about the small pop-ups that some apps produce from the systray led me to create my version of how this can be done. By the way, I call these small GUIs "Toasts" for obvious reasons! A zip containing the UDF, an example script and my StringSize UDF (which is also required): Toast.zip As always, kind comments and constructive criticisms welcome - particularly the former! M231 point
-
BackupDetector ( Backup attention popup )
Earthshine reacted to Exit for a topic
Have you ever shut down the computer while still performing a backup? If not, then ignore this post. Otherwise, this program may be helpful. It is registered in the startup folder after a query and then runs with every system start and ends only with system shutdown. Whenever a backup activity begins or ends, a message is generated. This prevents the computer from being accidentally turned off while a backup is still active. ; BackupDetector.exe Backup attention popup. ;============================================================================================================== ; Programm Name: BackupDetector.exe ; Description: Monitoring backup activities. ; Whenever a backup activity starts or ends, a message is generated. ; This eliminates the possibility of accidentally turning off the computer while a backup is still active. ; Syntax: BackupDetector.exe (no Parameters) ; Return Value(s): None. It's a never ending programm. ; Author: Exit ( http://www.autoitscript.com/forum/user/45639-exit ) ; SourceCode: http://www.autoitscript.com/forum/index.php?showtopic=199161 Version: 2019.06.21 ; COPYLEFT: © 2019 Freeware by "Exit" ; ALL WRONGS RESERVED ;============================================================================================================== #pragma compile(AutoItExecuteAllowed, True) #AutoIt3Wrapper_Res_SaveSource=y #NoTrayIcon If Not @Compiled Then Opt("TrayIconHide", 0) Opt("ExpandVarStrings", 1) #include <_SingleScript.au3> ; http://www.autoitscript.com/forum/index.php?showtopic=178681 _SingleScript() ; Close all running scripts with the same name $l = (StringRight(@OSLang, 2) = "07") ? 0 : 1 ; German=0 other=1 $sScriptShortcut = @AppDataDir & "\Microsoft\Windows\Start Menu\Programs\Startup\" & StringTrimRight(@ScriptName, 3) & "lnk" If @Compiled Then If Not FileExists($sScriptShortcut) Then $rc = MsgBox(4 + 32 + 256 + 262144, Default, $l ? _ "Should the program run at every system start?" : _ "Soll das Programm bei jedem Systemstart ausgeführt werden?") If $rc = 6 Then $rc = FileCreateShortcut(@ScriptFullPath, $sScriptShortcut) MsgBox(64 + 262144, Default, ($rc ? "" : ("--> " & ($l ? "NO" : "KEINE") & " <-- ")) & _ ($l ? "Shortcut created in the startup folder." : "Verknüpfung im Startordner erstellt.")) EndIf EndIf EndIf $bMessagebox = False $hPid = 0 While Sleep(5000) If ProcessExists("vssvc.exe") Then ; is Volume Shadow Copy running? If $bMessagebox = False Then If $hPid Then ProcessClose($hPid) $sText = $l ? "The backup is now running. @HOUR@:@MIN@:@SEC@@LF@" & _ "Please do not turn off the computer." & @LF & _ "When the backup is finished, a new message appears." : _ "Die Sicherung läuft jetzt. @HOUR@:@MIN@:@SEC@@LF@" & _ "Den Computer bitte nicht ausschalten." & @LF & _ "Wenn die Sicherung beendet ist, erscheint eine neue Meldung." $sCommand = '$rc = MsgBox(64+262144,@ScriptName & " on " & @Computername,"' & $sText & '") + Sleep(2147483647)' ; Retain PID due to sleep $sCommand = '"' & StringReplace($sCommand, '"', '""') & '"' $hPid = ShellExecute(@AutoItExe, ' /AutoIt3ExecuteLine ' & $sCommand) $bMessagebox = True EndIf Else If $bMessagebox = True Then If $hPid Then ProcessClose($hPid) $sText = $l ? "The backup is done. @HOUR@:@MIN@:@SEC@@LF@" & _ "The computer can (but does not have to) be turned off." & @LF & _ "Thank you for your patience, now you can press 'OK'." : _ "Die Sicherung ist fertig. @HOUR@:@MIN@:@SEC@@LF@" & _ "Der Computer kann (aber muss nicht) ausgeschaltet werden." & @LF & _ "Vielen Dank für ihre Geduld. Nun können Sie 'OK' drücken." $sCommand = '$rc = MsgBox(64+262144,@ScriptName & " on " & @Computername,"' & $sText & '") + Sleep(2147483647)' ; Retain PID due to sleep $sCommand = '"' & StringReplace($sCommand, '"', '""') & '"' $hPid = ShellExecute(@AutoItExe, ' /AutoIt3ExecuteLine ' & $sCommand) $bMessagebox = False EndIf EndIf WEnd ; End of BackupDetector script1 point -
_RegReadToArray
coffeeturtle reacted to nacerbaaziz for a topic
good morning everybody. today i liked to share an small example with you which it an function to read the registry values as an array the result array is 2d array witch $a_array[n][0] = value name $a_array[n][1] = value Data $a_array[0][0] = values count here's the function #include <Array.au3> #include <WinAPIReg.au3> #include <APIRegConstants.au3> Local $a_array = _RegReadToArray("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run") If @error Then MsgBox(16, "error", @error) Exit EndIf _ArrayDisplay($a_array) Func _RegReadToArray($s_RegKey) Local $a_KeySplitInfo = StringSplit($s_RegKey, "\\", 2) If UBound($a_KeySplitInfo) <= 1 Then $a_KeySplitInfo = StringSplit($s_RegKey, "\", 2) If UBound($a_KeySplitInfo) <= 1 Then Return (1, 1, 0) EndIf Local $H_KeyInfo = "", $s_RegKeyInfo = "" Switch $a_KeySplitInfo[0] Case "hklm", "HKEY_LOCAL_MACHINE", "hklm64", "HKEY_LOCAL_MACHINE64" $H_KeyInfo = $HKEY_LOCAL_MACHINE Case "hkCu", "HKEY_CURRENT_USER", "hkCU64", "HKEY_CURRENT_USER64" $H_KeyInfo = $HKEY_CURRENT_USER Case "hkCr", "HKEY_CLASSES_ROOT", "HKCR64", "HKEY_CLASSES_ROOT64" $H_KeyInfo = $HKEY_CLASSES_ROOT Case "HKU", "HKEY_USERS", "HKU64", "HKEY_USERS64" $H_KeyInfo = $HKEY_USERS Case Else Return SetError(2, 2, 0) EndSwitch _ArrayDelete($a_KeySplitInfo, 0) $s_RegKeyInfo = _ArrayToString($a_KeySplitInfo, "\") Local $H_KeyInfoOpen = _WinAPI_RegOpenKey($H_KeyInfo, $s_RegKeyInfo, $KEY_READ) Local $A_KeyInfo = _WinAPI_RegQueryInfoKey($H_KeyInfoOpen) If @error Then Return SetError(1, 1, 0) _WinAPI_RegCloseKey($H_KeyInfoOpen) Local $A_RegVal[$A_KeyInfo[2] + 1][2] Local $iV = 1, $s_RegRead = "" While 1 $s_RegVal = RegEnumVal($s_RegKey, $iV) If @error <> 0 Then ExitLoop $s_RegRead = RegRead($s_RegKey, $s_RegVal) If Not (@error) Then $A_RegVal[$iV][0] = $s_RegVal $A_RegVal[$iV][1] = $s_RegRead EndIf $iV += 1 WEnd $A_RegVal[0][0] = UBound($A_RegVal) - 1 If $A_RegVal[0][0] >= 1 Then Return $A_RegVal Else Return SetError(3, 3, 0) EndIf EndFunc ;==>_RegReadToArray i hope you benefit from it with my greetings1 point -
Why not build your project using SQL alone? https://www.youtube.com/watch?v=MPSMH8w7nfw1 point
-
compile released and tentative
Earthshine reacted to SgtHugoStiglitz for a topic
I look to Scite doc for Autoit3wrapper argument, #AutoIt3Wrapper_Run_After= run a batch script who create 2 folders, released and tentative). Thank you people.1 point -
Sharing ReflexMem Macro Designer
LegitStack reacted to Earthshine for a topic
thanks for the share mate. if you should restart it, just use an Agile method to develop. I prefer a special blend of xRUP or modified and AGILE way of Rational Unified Process (just with one dev. still just do sprints to implement functions, one for debugging, then add another sprint with a few more features until done. that way, wherever you stop, you can just pick up and continue with a well running debugged system. that's how the big boys do it in the real world, like rolling out a customer website for an Electric company (I actually worked on a wonderful HI PERFORMANCE and SUCCESSFUL team that did just that) scrum is also very good, just use one and stick to it https://g.co/kgs/USYEeb1 point -
compile released and tentative
Earthshine reacted to JLogan3o13 for a topic
@retro_spec you are obviously not someone we want around here. 👋1 point -
_RegReadToArray
nacerbaaziz reacted to water for a topic
My 2 cents worth Do not unse Local in a Loop Do not use ReDim for every entry - Slooows down your script. Create/enlarge the Array in steps of 100 and set the real size when all registry keys have been processed.1 point -
_RegReadToArray
nacerbaaziz reacted to coffeeturtle for a topic
@Polymath Thank you! This is nice! I guess you're using msgbox for demonstrative purposes. Easier to see output though when maybe just add #include <Array.au3> at the top and instead of the msgBox to display each value one at a time, just use _ArrayDisplay($a_array) (outside of the loop) (you probably already knew that) Thanks again though!1 point -
For the curious, here is a script drawing 2 GDI frames with some text inside that you can drag individually. #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPISysWin.au3> #include <WinAPIGdi.au3> #include <WinAPI.au3> Local $hDLL = DllOpen("user32.dll") AutoItSetOption("MouseCoordMode", 2) ;Register callback $hKey_Proc = DllCallbackRegister("_Mouse_Proc", "int", "int;ptr;ptr") $hM_Module = DllCall("kernel32.dll", "hwnd", "GetModuleHandle", "ptr", 0) $hM_Hook = DllCall("user32.dll", "hwnd", "SetWindowsHookEx", "int", $WH_MOUSE_LL, "ptr", DllCallbackGetPtr($hKey_Proc), "hwnd", $hM_Module[0], "dword", 0) Global Const $MSLLHOOKSTRUCT = $tagPOINT & ";dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo" Global $currentEvent[2] Global $iLBUTTONDOWN = 0 Global $iRBUTTONDOWN = 0 Global $iMBUTTONDOWN = 0 Global $LRClickStatus = 0 Global $RLClickStatus = 0 Global $LRDrag = 0 Global $RLDrag = 0 Global $LMDrag = 0 Global $RMDrag = 0 Global $doubleClickTime = 400 Global $tPoint Local $hGUI, $hGraphics, $hBackbuffer, $hBitmap Local Const $width = Int(@DesktopWidth * 0.5), $height = Int(@DesktopHeight * 0.5) Global $max_width = 1900 Global $max_height = 1000 ; Initialize GDI+ _GDIPlus_Startup() Local $GUI_title = "GDI+" $hGUI = GUICreate($GUI_title, $width, $height, -1, -1, BitOR($GUI_SS_DEFAULT_GUI,$WS_THICKFRAME,$WS_TABSTOP)) GUISetState() Dim $tab[2][3] ; Création de la zone principale d'affichage Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) $hBitmap = _GDIPlus_BitmapCreateFromGraphics($max_width, $max_height, $hGraphics) $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2) _GDIPlus_GraphicsClear($hBackbuffer, 0xFFF0F0F0) ; Formatage du texte $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000) $hFormat = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($hFormat, 1) $hFamily = _GDIPlus_FontFamilyCreate("Arial") $hFont = _GDIPlus_FontCreate($hFamily, 10, 2) $hPen = _GDIPlus_PenCreate(0xFF000000, 2) Global $cadre_largeur = 200 Global $cadre_hauteur = 200 ; Premier stack $cadre_x = 100 $cadre_y = 100 $tLayout = _GDIPlus_RectFCreate($cadre_x, $cadre_y, $cadre_largeur, 15) _GDIPlus_GraphicsDrawStringEx($hBackbuffer, "Hello world A", $hFont, $tLayout, $hFormat, $hBrush) $tLayout2 = _GDIPlus_RectFCreate($cadre_x, $cadre_y + 15, $cadre_largeur, 15) _GDIPlus_GraphicsDrawStringEx($hBackbuffer, "Bye world A", $hFont, $tLayout2, $hFormat, $hBrush) _GDIPlus_GraphicsDrawRect($hBackbuffer, $cadre_x, $cadre_y, $cadre_largeur, $cadre_hauteur, $hPen) ; cadre _GDIPlus_GraphicsDrawRect($hBackbuffer, $cadre_x, $cadre_y + 15, $cadre_largeur, 15, $hPen) ; titre $tab[0][0] = $cadre_x $tab[0][1] = $cadre_y $tab[0][2] = "A" ; Second stack $cadre_x = 400 $cadre_y = 300 $tLayout = _GDIPlus_RectFCreate($cadre_x, $cadre_y, $cadre_largeur, 15) _GDIPlus_GraphicsDrawStringEx($hBackbuffer, "Hello world B", $hFont, $tLayout, $hFormat, $hBrush) $tLayout2 = _GDIPlus_RectFCreate($cadre_x, $cadre_y + 15, $cadre_largeur, 15) _GDIPlus_GraphicsDrawStringEx($hBackbuffer, "Bye world B", $hFont, $tLayout2, $hFormat, $hBrush) _GDIPlus_GraphicsDrawRect($hBackbuffer, $cadre_x, $cadre_y, $cadre_largeur, $cadre_hauteur, $hPen) ; cadre _GDIPlus_GraphicsDrawRect($hBackbuffer, $cadre_x, $cadre_y + 15, $cadre_largeur, 15, $hPen) ; titre _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $max_width, $max_height) ; copy from backbuffer to visible graphic $tab[1][0] = $cadre_x $tab[1][1] = $cadre_y $tab[1][2] = "B" Global $decalageX, $decalageY Global $deplacement_en_cours = False Global $index_stack GUIRegisterMsg($WM_PAINT, "WM_PAINT") GUIRegisterMsg($WM_SIZE, "WM_SIZE") While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE _Exit() Case $GUI_EVENT_MAXIMIZE $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) EndSwitch WEnd Func _Mouse_Proc($nCode, $wParam, $lParam) Local $info, $mouseData, $time, $timeDiff If $nCode < 0 Then $ret = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", $hM_Hook[0], _ "int", $nCode, "ptr", $wParam, "ptr", $lParam) Return $ret[0] EndIf $info = DllStructCreate($MSLLHOOKSTRUCT, $lParam) $mouseData = DllStructGetData($info, 3) $time = DllStructGetData($info, 5) $timeDiff = $time - $currentEvent[1] Select Case $wParam = $WM_MOUSEMOVE ;Test for Drag in here If $currentEvent[0] <> "LDrag" Or $currentEvent[0] <> "LRDrag" Or $currentEvent[0] <> "LMDrag" Then If $iLBUTTONDOWN = 1 Then $currentEvent[0] = "LDrag" If $deplacement_en_cours Then $mouseX = MouseGetPos(0) $mouseY = MouseGetPos(1) _GDIPlus_GraphicsClear($hBackbuffer, 0xFFF0F0F0) For $i = 0 To UBound($tab) - 1 ; on déplace seulement celui dont l'index correspond dans le tableau If $i = $index_stack Then $tLayout = _GDIPlus_RectFCreate($mouseX - $decalageX, $mouseY - $decalageY, $cadre_largeur, 15) _GDIPlus_GraphicsDrawStringEx($hBackbuffer, "Hello world " & $tab[$i][2], $hFont, $tLayout, $hFormat, $hBrush) $tLayout2 = _GDIPlus_RectFCreate($mouseX - $decalageX, $mouseY - $decalageY + 15, $cadre_largeur, 15) _GDIPlus_GraphicsDrawStringEx($hBackbuffer, "Bye world " & $tab[$i][2], $hFont, $tLayout2, $hFormat, $hBrush) _GDIPlus_GraphicsDrawRect($hBackbuffer, $mouseX - $decalageX, $mouseY - $decalageY, $cadre_largeur, $cadre_hauteur, $hPen) ; cadre _GDIPlus_GraphicsDrawRect($hBackbuffer, $mouseX - $decalageX, $mouseY - $decalageY + 15, $cadre_largeur, 15, $hPen) ; titre $tab[$index_stack][0] = $mouseX - $decalageX $tab[$index_stack][1] = $mouseY - $decalageY Else ; les autres sont simplement redessinés au même endroit $tLayout = _GDIPlus_RectFCreate($tab[$i][0], $tab[$i][1], $cadre_largeur, 15) _GDIPlus_GraphicsDrawStringEx($hBackbuffer, "Hello world " & $tab[$i][2], $hFont, $tLayout, $hFormat, $hBrush) $tLayout2 = _GDIPlus_RectFCreate($tab[$i][0], $tab[$i][1] + 15, $cadre_largeur, 15) _GDIPlus_GraphicsDrawStringEx($hBackbuffer, "Bye world " & $tab[$i][2], $hFont, $tLayout2, $hFormat, $hBrush) _GDIPlus_GraphicsDrawRect($hBackbuffer, $tab[$i][0], $tab[$i][1], $cadre_largeur, $cadre_hauteur, $hPen) ; cadre _GDIPlus_GraphicsDrawRect($hBackbuffer, $tab[$i][0], $tab[$i][1] + 15, $cadre_largeur, 15, $hPen) ; titre EndIf Next _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $max_width, $max_height) EndIf If $iRBUTTONDOWN = 1 Then $currentEvent[0] = "LRDrag" $LRDrag = 2 EndIf EndIf EndIf If $currentEvent[0] <> "RDrag" Or $currentEvent[0] <> "RMDrag" Or $currentEvent[0] <> "LRDrag" Then If $iRBUTTONDOWN = 1 Then $currentEvent[0] = "RDrag" EndIf EndIf If $currentEvent[0] <> "MDrag" Then If $iMBUTTONDOWN = 1 Then $currentEvent[0] = "MDrag" $currentEvent[1] = $time EndIf EndIf If $iRBUTTONDOWN = 1 And $iMBUTTONDOWN = 1 And $currentEvent[0] <> "RMDrag" Then $RMDrag = 2 $currentEvent[0] = "RMDrag" $currentEvent[1] = $time EndIf If $iLBUTTONDOWN = 1 And $iMBUTTONDOWN = 1 And $currentEvent[0] <> "LMDrag" Then $LMDrag = 2 $currentEvent[0] = "LMDrag" $currentEvent[1] = $time EndIf Case $wParam = $WM_MOUSEWHEEL If _WinAPI_HiWord($mouseData) > 0 Then ;Wheel Up $currentEvent[0] = "WheelUp" $currentEvent[1] = $time Else ;Wheel Down $currentEvent[0] = "WheelDown" $currentEvent[1] = $time EndIf Case $wParam = $WM_LBUTTONDOWN $mouseX = MouseGetPos(0) $mouseY = MouseGetPos(1) For $i = 0 To UBound($tab) - 1 If $mouseX > $tab[$i][0] And $mouseX < $tab[$i][0] + $cadre_largeur And _ $mouseY > $tab[$i][1] And $mouseY < $tab[$i][1] + $cadre_hauteur Then $decalageX = $mouseX - $tab[$i][0] $decalageY = $mouseY - $tab[$i][1] ; ... on peut déplacer $deplacement_en_cours = True $index_stack = $i EndIf Next ; Register Button Down, check for Right/Left If $currentEvent[0] = "RClick" Then $LRClickStatus = 1 EndIf $iLBUTTONDOWN = 1 Case $wParam = $WM_LBUTTONUP ;Update $iLBUTTONDOWN $iLBUTTONDOWN = 0 ;Test for Right/Left Click If $RLClickStatus = 1 And ($timeDiff) < $doubleClickTime Then $currentEvent[0] = "RLClick" $currentEvent[1] = $time EndIf If $currentEvent[0] = "LClick" And ($timeDiff) < $doubleClickTime Then $currentEvent[0] = "LDClick" $currentEvent[1] = $time EndIf ;Test for Drops If $currentEvent[0] = "LDrag" Then $currentEvent[0] = "LDrop" $currentEvent[1] = $time ; si un déplacement était en cours, on indique que c'est terminé puisqu'on vient de relacher le bouton de la souris If $deplacement_en_cours Then $deplacement_en_cours = False EndIf EndIf If $LRDrag = 2 And $iRBUTTONDOWN = 1 Then $LRDrag = 1 ; Denote $LRDrag as still having one button clicked, need to register the drop on RButton up EndIf If $LRDrag = 1 And $iRBUTTONDOWN = 0 Then $currentEvent[0] = "LRDrop" $currentEvent[1] = $time $LRDrag = 0 EndIf If $LMDrag = 2 And $iMBUTTONDOWN = 1 Then $LMDrag = 1 ; Denote $LMDrag as still having one button clicked, need to register the drop on MButton up EndIf If $LMDrag = 1 And $iMBUTTONDOWN = 0 Then $currentEvent[0] = "LMDrop" $currentEvent[1] = $time $LMDrag = 0 EndIf ;Set LClick if other events haven't fired If $currentEvent[1] <> $time Then $currentEvent[0] = "LClick" $currentEvent[1] = $time EndIf ;Negate $LRClickStatus $RLClickStatus = 0 Case $wParam = $WM_RBUTTONDOWN ;Register Button Down If $currentEvent[0] = "LClick" Then $RLClickStatus = 1 EndIf $iRBUTTONDOWN = 1 Case $wParam = $WM_RBUTTONUP ;Test for Left, Right, and Right Doubleclick here ;Update $iRBUTTONDOWN $iRBUTTONDOWN = 0 ;Test for Right/Left Click If $LRClickStatus = 1 And ($timeDiff) < $doubleClickTime Then $currentEvent[0] = "LRClick" $currentEvent[1] = $time EndIf If $currentEvent[0] = "RClick" And ($timeDiff) < $doubleClickTime Then $currentEvent[0] = "RDClick" $currentEvent[1] = $time EndIf ;Test for Drops If $currentEvent[0] = "RDrag" Then $currentEvent[0] = "RDrop" $currentEvent[1] = $time EndIf If $LRDrag = 2 And $iLBUTTONDOWN = 1 Then $LRDrag = 1 ; Denote $LRDrag as still having one button clicked, need to register the drop on RButton up EndIf If $LRDrag = 1 And $iLBUTTONDOWN = 0 Then $currentEvent[0] = "LRDrop" $currentEvent[1] = $time $LRDrag = 0 EndIf If $RMDrag = 2 And $iMBUTTONDOWN = 1 Then $RMDrag = 1 ; Denote $LMDrag as still having one button clicked, need to register the drop on MButton up EndIf If $RMDrag = 1 And $iMBUTTONDOWN = 0 Then $currentEvent[0] = "RMDrop" $currentEvent[1] = $time $RMDrag = 0 EndIf ;Set LClick if other events haven't fired If $currentEvent[1] <> $time Then $currentEvent[0] = "RClick" $currentEvent[1] = $time EndIf ;Negate $LRClickStatus $LRClickStatus = 0 Case $wParam = $WM_MBUTTONDOWN ;Register Button Down $iMBUTTONDOWN = 1 Case $wParam = $WM_MBUTTONUP ;Test for Middle Double Click here ;Update $iRBUTTONDOWN $iMBUTTONDOWN = 0 ;Test for Right/Left Click If $currentEvent[0] = "MClick" And ($timeDiff) < $doubleClickTime Then $currentEvent[0] = "MDClick" $currentEvent[1] = $time EndIf ;Test for Drops If $currentEvent[0] = "MDrag" Then $currentEvent[0] = "MDrop" $currentEvent[1] = $time EndIf If $LMDrag = 2 And $iLBUTTONDOWN = 1 Then $LMDrag = 1 ; Denote $LRDrag as still having one button clicked, need to register the drop on RButton up EndIf If $LMDrag = 1 And $iLBUTTONDOWN = 0 Then $currentEvent[0] = "LMDrop" $currentEvent[1] = $time $LMDrag = 0 EndIf If $RMDrag = 2 And $iRBUTTONDOWN = 1 Then $RMDrag = 1 ; Denote $LMDrag as still having one button clicked, need to register the drop on MButton up EndIf If $RMDrag = 1 And $iRBUTTONDOWN = 0 Then $currentEvent[0] = "RMDrop" $currentEvent[1] = $time $RMDrag = 0 EndIf ;Set MClick if other events haven't fired If $currentEvent[1] <> $time Then $currentEvent[0] = "MClick" $currentEvent[1] = $time EndIf EndSelect ;~ If $currentEvent[0] <> "" Then ConsoleWrite("event:"&$currentEvent[0] & @CRLF) $ret = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", $hM_Hook[0], _ "int", $nCode, "ptr", $wParam, "ptr", $lParam) Return $ret[0] EndFunc ;==>_Mouse_Proc Func WM_PAINT($hwnd, $iMsg, $wParam, $lParam) If $hwnd = $hGUI Then _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0) _WinAPI_RedrawWindow($hwnd, 0, 0, $RDW_VALIDATE) EndIf Return 'GUI_RUNDEFMSG' EndFunc ;==>WM_PAINT Func WM_SIZE($hwnd, $iMsg, $wParam, $lParam) If $hwnd = $hGUI Then $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) EndIf Return 'GUI_RUNDEFMSG' EndFunc Func _Exit() DllCall("user32.dll", "int", "UnhookWindowsHookEx", "hwnd", $hM_Hook[0]) $hM_Hook[0] = 0 DllCallbackFree($hKey_Proc) $hKey_Proc = 0 ; Clean up _GDIPlus_PenDispose($hPen) _GDIPlus_GraphicsDispose($hBackbuffer) _GDIPlus_BitmapDispose ($hBitmap) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hBrush) ; Uninitialize GDI+ _GDIPlus_Shutdown() DllClose($hDLL) Exit EndFunc1 point
-
How to save the output in a txt file
zoel reacted to Earthshine for a topic
oops! i never actually saved it! code below fixed #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <StringConstants.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <AutoItConstants.au3> #include <GuiEdit.au3> #include <ScrollBarsConstants.au3> #include <GUIToolTip.au3> #include <WinAPIDlg.au3> Local $aWndPos Local $vDos, $sline = "" $NetAs = GUICreate("NetAs-Network Assistant", 1096, 521, 182, 135) Local $idFilemenu = GUICtrlCreateMenu("&File") Local $idSaveitem = GUICtrlCreateMenuItem("Save", $idFilemenu) Local $idabout = GUICtrlCreateMenuItem("About", $idFilemenu) Local $idExititem = GUICtrlCreateMenuItem("Exit", $idFilemenu) Local $idInput = GUICtrlCreateEdit("", 168, 34, 921, 465) GUICtrlSetFont(-1, 10, 400, 0, "Courier") GUICtrlSetBkColor(-1, 0x0000FF) GUICtrlSetColor($idInput, 0xFFFFFF) Local $Button1 = GUICtrlCreateButton("IPconfig", 48, 56, 75, 25) Local $Button3 = GUICtrlCreateButton("FlushDNS", 48, 96, 75, 25) Local $Button5 = GUICtrlCreateButton("ConnRelease", 48, 136, 75, 25) Local $Button7 = GUICtrlCreateButton("DisplayDNS", 48, 176, 75, 25) Local $Button9 = GUICtrlCreateButton("Route Print", 48, 216, 75, 25) Local $Button11 = GUICtrlCreateButton("ARP", 48, 256, 75, 25) Local $Button13 = GUICtrlCreateButton("NSLookup", 48, 296, 75, 25) Local $Button15 = GUICtrlCreateButton("NetStat -an", 48, 336, 75, 25) Local $Button17 = GUICtrlCreateButton("GetMac", 48, 376, 75, 25) Local $Button19 = GUICtrlCreateButton("Ping", 48, 416, 75, 25) Local $Button23 = GUICtrlCreateButton("Run", 656, 8, 73, 25) Local $Button24 = GUICtrlCreateButton("Clear", 576, 8, 75, 25) Local $Input1 = GUICtrlCreateInput("", 736, 8, 345, 21) GUISetState(@SW_SHOW) $hENTER = GUICtrlCreateDummy() Dim $AccelKeys[1][2] = [["{ENTER}", $hENTER]] ; Set accelerators GUISetAccelerators($AccelKeys) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $idExititem Exit Case $GUI_EVENT_CLOSE, $idabout MsgBox(64, "About", "NetAs-Network Assistant" _ & @CRLF & "Version 1.1" _ & @CRLF & "By zoel" _ & @CRLF & @CRLF & "Designed in AutoIt with help by @subz ") Case $Button1 GUICtrlSetData($idInput, _CmdInfo() & @CRLF) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) Case $idSaveitem Local $sFileSaveDialog = FileSaveDialog("Save File As", @ScriptDir, "Text Files (*.txt)", $FD_PATHMUSTEXIST) Local $editcontent = guictrlread($idInput) ;~ ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $editcontent = ' & $editcontent & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console FileWrite($sFileSaveDialog, $editcontent) ;~ ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : FileWrite("Save.txt", $sFileSaveDialog) = ' & FileWrite("Save.txt", $sFileSaveDialog) & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console Case $Button3 GUICtrlSetData($idInput, _CmdInfo2() & @CRLF) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) Case $Button5 GUICtrlSetData($idInput, _CmdInfo3() & @CRLF) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) Case $Button7 GUICtrlSetData($idInput, _CmdInfo4() & @CRLF) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) Case $Button9 GUICtrlSetData($idInput, _CmdInfo5() & @CRLF) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) Case $Button11 GUICtrlSetData($idInput, _CmdInfo6() & @CRLF) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) Case $Button13 GUICtrlSetData($idInput, _CmdInfo7() & @CRLF) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) Case $Button15 GUICtrlSetData($idInput, _CmdInfo8() & @CRLF) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) Case $Button17 GUICtrlSetData($idInput, _CmdInfo9() & @CRLF) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) Case $Button19 GUICtrlSetData($idInput, _CmdInfo10() & @CRLF) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) Case $Button24 GUICtrlSetData($idInput, "") Case $Button23, $hENTER $vDos = Run(@ComSpec & " /c " & GUICtrlRead($Input1), @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $sline &= StdoutRead($vDos) If @error Then ExitLoop WEnd GUICtrlSetData($idInput, $sline & @CRLF) GUICtrlSetData($Input1, "") ;----> Reset $sline = "" EndSwitch WEnd Func _CmdInfo($_sCmdInfo = "ipconfig /all") Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo, "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) ; Wait until the process has closed using the PID returned by Run. ProcessWaitClose($iPID) ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead. Local $sOutput = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF) Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF) Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr Return $sReult EndFunc Func _CmdInfo2($_sCmdInfo2 = "IPConfig /FlushDNS") Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo2, "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) ; Wait until the process has closed using the PID returned by Run. ProcessWaitClose($iPID) ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead. Local $sOutput = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF) Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF) Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr Return $sReult EndFunc Func _CmdInfo3($_sCmdInfo3 = "IPConfig /Release") Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo3, "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) ; Wait until the process has closed using the PID returned by Run. ProcessWaitClose($iPID) ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead. Local $sOutput = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF) Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF) Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr Return $sReult EndFunc Func _CmdInfo4($_sCmdInfo4 = "ipconfig /displaydns") Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo4, "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) ; Wait until the process has closed using the PID returned by Run. ProcessWaitClose($iPID) ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead. Local $sOutput = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF) Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF) Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr Return $sReult EndFunc Func _CmdInfo5($_sCmdInfo5 = "Route Print") Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo5, "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) ; Wait until the process has closed using the PID returned by Run. ProcessWaitClose($iPID) ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead. Local $sOutput = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF) Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF) Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr Return $sReult EndFunc Func _CmdInfo6($_sCmdInfo6 = "ARP -a") Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo6, "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) ; Wait until the process has closed using the PID returned by Run. ProcessWaitClose($iPID) ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead. Local $sOutput = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF) Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF) Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr Return $sReult EndFunc Func _CmdInfo7($_sCmdInfo7 = "NSLookup") Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo7, "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) ; Wait until the process has closed using the PID returned by Run. ProcessWaitClose($iPID) ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead. Local $sOutput = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF) Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF) Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr Return $sReult EndFunc Func _CmdInfo8($_sCmdInfo8 = "netstat -aof") Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo8, "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) ; Wait until the process has closed using the PID returned by Run. ProcessWaitClose($iPID) ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead. Local $sOutput = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF) Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF) Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr Return $sReult EndFunc Func _CmdInfo9($_sCmdInfo9 = "getmac") Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo9, "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) ; Wait until the process has closed using the PID returned by Run. ProcessWaitClose($iPID) ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead. Local $sOutput = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF) Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF) Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr Return $sReult EndFunc Func _CmdInfo10($_sCmdInfo10 = "ping google.com") Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo10, "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) ; Wait until the process has closed using the PID returned by Run. ProcessWaitClose($iPID) ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead. Local $sOutput = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF) Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF) Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr Return $sReult EndFunc1 point -
How to save the output in a txt file
zoel reacted to Earthshine for a topic
here, look at the save file case... #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <StringConstants.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <AutoItConstants.au3> #include <GuiEdit.au3> #include <ScrollBarsConstants.au3> #include <GUIToolTip.au3> #include <WinAPIDlg.au3> Local $aWndPos Local $vDos, $sline = "" $NetAs = GUICreate("NetAs-Network Assistant", 1096, 521, 182, 135) Local $idFilemenu = GUICtrlCreateMenu("&File") Local $idSaveitem = GUICtrlCreateMenuItem("Save", $idFilemenu) Local $idabout = GUICtrlCreateMenuItem("About", $idFilemenu) Local $idExititem = GUICtrlCreateMenuItem("Exit", $idFilemenu) Local $idInput = GUICtrlCreateEdit("", 168, 34, 921, 465) GUICtrlSetFont(-1, 10, 400, 0, "Courier") GUICtrlSetBkColor(-1, 0x0000FF) GUICtrlSetColor($idInput, 0xFFFFFF) Local $Button1 = GUICtrlCreateButton("IPconfig", 48, 56, 75, 25) Local $Button3 = GUICtrlCreateButton("FlushDNS", 48, 96, 75, 25) Local $Button5 = GUICtrlCreateButton("ConnRelease", 48, 136, 75, 25) Local $Button7 = GUICtrlCreateButton("DisplayDNS", 48, 176, 75, 25) Local $Button9 = GUICtrlCreateButton("Route Print", 48, 216, 75, 25) Local $Button11 = GUICtrlCreateButton("ARP", 48, 256, 75, 25) Local $Button13 = GUICtrlCreateButton("NSLookup", 48, 296, 75, 25) Local $Button15 = GUICtrlCreateButton("NetStat -an", 48, 336, 75, 25) Local $Button17 = GUICtrlCreateButton("GetMac", 48, 376, 75, 25) Local $Button19 = GUICtrlCreateButton("Ping", 48, 416, 75, 25) Local $Button23 = GUICtrlCreateButton("Run", 656, 8, 73, 25) Local $Button24 = GUICtrlCreateButton("Clear", 576, 8, 75, 25) Local $Input1 = GUICtrlCreateInput("", 736, 8, 345, 21) GUISetState(@SW_SHOW) $hENTER = GUICtrlCreateDummy() Dim $AccelKeys[1][2] = [["{ENTER}", $hENTER]] ; Set accelerators GUISetAccelerators($AccelKeys) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $idExititem Exit Case $GUI_EVENT_CLOSE, $idabout MsgBox(64, "About", "NetAs-Network Assistant" _ & @CRLF & "Version 1.1" _ & @CRLF & "By zoel" _ & @CRLF & @CRLF & "Designed in AutoIt with help by @subz ") Case $Button1 GUICtrlSetData($idInput, _CmdInfo() & @CRLF) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) Case $idSaveitem Local $sFileSaveDialog = FileSaveDialog("Save File As", @ScriptDir, "Text Files (*.txt)", $FD_PATHMUSTEXIST) ;~ Local $editcontent = guictrlread($idInput) ;~ ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $editcontent = ' & $editcontent & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console ;~ FileWrite("Save.txt", $editcontent) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : FileWrite("Save.txt", $sFileSaveDialog) = ' & FileWrite("Save.txt", $sFileSaveDialog) & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console Case $Button3 GUICtrlSetData($idInput, _CmdInfo2() & @CRLF) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) Case $Button5 GUICtrlSetData($idInput, _CmdInfo3() & @CRLF) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) Case $Button7 GUICtrlSetData($idInput, _CmdInfo4() & @CRLF) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) Case $Button9 GUICtrlSetData($idInput, _CmdInfo5() & @CRLF) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) Case $Button11 GUICtrlSetData($idInput, _CmdInfo6() & @CRLF) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) Case $Button13 GUICtrlSetData($idInput, _CmdInfo7() & @CRLF) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) Case $Button15 GUICtrlSetData($idInput, _CmdInfo8() & @CRLF) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) Case $Button17 GUICtrlSetData($idInput, _CmdInfo9() & @CRLF) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) Case $Button19 GUICtrlSetData($idInput, _CmdInfo10() & @CRLF) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) Case $Button24 GUICtrlSetData($idInput, "") Case $Button23, $hENTER $vDos = Run(@ComSpec & " /c " & GUICtrlRead($Input1), @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $sline &= StdoutRead($vDos) If @error Then ExitLoop WEnd GUICtrlSetData($idInput, $sline & @CRLF) GUICtrlSetData($Input1, "") ;----> Reset $sline = "" EndSwitch WEnd Func _CmdInfo($_sCmdInfo = "ipconfig /all") Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo, "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) ; Wait until the process has closed using the PID returned by Run. ProcessWaitClose($iPID) ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead. Local $sOutput = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF) Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF) Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr Return $sReult EndFunc Func _CmdInfo2($_sCmdInfo2 = "IPConfig /FlushDNS") Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo2, "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) ; Wait until the process has closed using the PID returned by Run. ProcessWaitClose($iPID) ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead. Local $sOutput = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF) Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF) Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr Return $sReult EndFunc Func _CmdInfo3($_sCmdInfo3 = "IPConfig /Release") Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo3, "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) ; Wait until the process has closed using the PID returned by Run. ProcessWaitClose($iPID) ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead. Local $sOutput = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF) Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF) Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr Return $sReult EndFunc Func _CmdInfo4($_sCmdInfo4 = "ipconfig /displaydns") Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo4, "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) ; Wait until the process has closed using the PID returned by Run. ProcessWaitClose($iPID) ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead. Local $sOutput = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF) Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF) Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr Return $sReult EndFunc Func _CmdInfo5($_sCmdInfo5 = "Route Print") Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo5, "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) ; Wait until the process has closed using the PID returned by Run. ProcessWaitClose($iPID) ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead. Local $sOutput = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF) Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF) Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr Return $sReult EndFunc Func _CmdInfo6($_sCmdInfo6 = "ARP -a") Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo6, "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) ; Wait until the process has closed using the PID returned by Run. ProcessWaitClose($iPID) ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead. Local $sOutput = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF) Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF) Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr Return $sReult EndFunc Func _CmdInfo7($_sCmdInfo7 = "NSLookup") Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo7, "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) ; Wait until the process has closed using the PID returned by Run. ProcessWaitClose($iPID) ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead. Local $sOutput = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF) Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF) Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr Return $sReult EndFunc Func _CmdInfo8($_sCmdInfo8 = "netstat -aof") Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo8, "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) ; Wait until the process has closed using the PID returned by Run. ProcessWaitClose($iPID) ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead. Local $sOutput = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF) Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF) Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr Return $sReult EndFunc Func _CmdInfo9($_sCmdInfo9 = "getmac") Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo9, "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) ; Wait until the process has closed using the PID returned by Run. ProcessWaitClose($iPID) ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead. Local $sOutput = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF) Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF) Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr Return $sReult EndFunc Func _CmdInfo10($_sCmdInfo10 = "ping google.com") Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo10, "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) ; Wait until the process has closed using the PID returned by Run. ProcessWaitClose($iPID) ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead. Local $sOutput = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF) Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF) Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr Return $sReult EndFunc here is what i changed to the below code Case $idSaveitem Local $sFileSaveDialog = FileSaveDialog("Save File As", @ScriptDir, "Text Files (*.txt)", $FD_PATHMUSTEXIST) ;~ Local $editcontent = guictrlread($idInput) ;~ ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $editcontent = ' & $editcontent & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console ;~ FileWrite("Save.txt", $editcontent) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : FileWrite("Save.txt", $sFileSaveDialog) = ' & FileWrite("Save.txt", $sFileSaveDialog) & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console1 point -
How to save the output in a txt file
zoel reacted to Earthshine for a topic
no, you have to program that in... lol see if you can implement a Save-As menu item1 point -
SnipperSnapper <MS Snipping Tool Enhancer>
dlopez0682 reacted to Jos for a topic
Just remove the "Func _WinAPI_PlaySound()" from the master script as it is part of an included UDF file WinAPIMisc.au3. Jos1 point -
How to save the output in a txt file
zoel reacted to Earthshine for a topic
ok, on the folder where you develop your script, in Windows Explorer you can right-click the mouse on that folder and look at properties, then Security tab and Advanced I think. post a snapshot of that, and tell us what kind of user you are, regular, admin, etc... maybe add this to very top of script #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Add_Constants=n #AutoIt3Wrapper_res_requestedExecutionLevel=requireAdministrator #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****1 point -
Change that piece of code to this: Case $idSaveitem Local $editcontent = guictrlread($idInput) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $editcontent = ' & $editcontent & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console ;~ FileWrite("Save.txt", $editcontent) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : FileWrite("Save.txt", $editcontent) = ' & FileWrite("Save.txt", $editcontent) & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console Then copy and paste the SciTE output pane here and let us see what's happening. The first ConsoleWrite will display what it got from the Edit control, the second one will tell us if the FileWrite had any errors.1 point
-
WebDriver UDF - Help & Support
Letraindusoir reacted to Danp2 for a topic
Hi @Suraj18, Thanks for the kind words. Please share some additional details showing what you have tried thus far and the outcome. Dan1 point -
provide the output from my the function in my signature1 point
-
A new and improved version of his The GuiBuilder Return by DFerrato, has been added to the GUI Creator list in the first post. A new screenshot and download can be found at this post.1 point
-
Hello to all.. Returning this project, submitted a new version of the GUIBUILDER. This is an open project and i hope your suggestion and collaboration. Sample of Look and Feel. 1) Motivations: When you return to the development of the guibuilder, i ask to myself because I make a new program when there are already other full already extensive use among programrs as for example ISNT Studio or the K.O.D.A. And I found myself with the necessity that this is easily extensible, independent of the programming language and in a future integrated into a larger suite that includes other components (e.g., automation in the program flows, modeling of data structure, programming by rules, distinction of tasks by users, integration with other applications using standards such as SOAP or REST, etc.). This is so understanding the state of the art of software development today, is no longer useful that the aid is only in GUI development's. 2) Rationalizations: My first impulse to resuming development was to follow the methodology applied up until that time. But to have to speak the message loop to add the editing of properties of the window, I found myself in a quagmire to locate the exact site where to insert the new code. Just at that moment I understood because in Guibuilder Ravamped withdrew all the code that did not belong to the basic structure. This experience led me to adopt a third alternative expressed in the following actions: Convert all pieces of possible codes in functions: to each of these new features, you added a description and document parameters of Estrada, output and global variables used or modified. Organization of code and functions in sections: I understood that it is easier to find, understand and modify a section of code, if this is grouped according to what it does, The separation into Sections also reached to code generated by the GuiBuilder. Use a Database: In reviewing the various codes to modify i found that many of them were very similar, being able to save labor and time, separating the data in the instructions themselves and placing the latter in a local database (see Modifying_db.txt and structure_db.txt) Edition of Properties: While many controls have similar properties, this is not the case for all of them. By this replaced the fields Edit, by a grid, then automated change of each one of them, placed in the Db information on editing mechanism, by default values and classes about which it applies. New main window: It seemed to me that the program should have a separate to the main window of the properties and is remade the menu by placing some of its functions in a toolbar 4) State of the art While the Guibuilder works and generates a correct code, there are many even the facilities that I would like to add to it a full form builder. The functions currently available are: Usable Controls: Button, Checkbox, Radio, Edit, Input, Label, List, combo, Date, TreeView (incomplete), Icon, Pic, Progress Bar, Slider Bar, Group (incomplete) y Choose Color (New). Properties availables: and dependent on the control class chosen, are: Name, Left, Top, Width, BKColor, Color, Image, Style, Tip, Text, State, Cursor, Font (Type, size, color, styles) , Caption, Height, Value Default, Nombre de Clase, Style_ex, Source. Windows Properties: (incomplete) Grid: Enabled / Disabled, automatic alignment, alignment of the current control or all controls. Menu features: with added, enabled, disabled fast (see Menu.txt) Toolbar features: with added, enabled, disabled fast (see Toolbar.txt) Properties: Quick Add (see properties.txt) Debug: In the execution of code compiled or interpreted in a separate window (Open Debugview.exe - included) Debugging Features: display of internal arrays of operation ($MCL[], $Type[], $Grippy[], $CursorInfo[]) Autoit code generation: using loop of messages Generation saved source: code at any time. Possibility to generate codes: in other programming languages In the header of Guibuilder.au3 are the incomplete list and the point’s detected errors not yet corrected. 5) To Next ?. There are many tasks that are still to be carried out, to get to the objective explained in paragraph motivations, even that this form creator is as useful as possible to the developer. I would like to start by modifying the following: Autoit code generation using events. Complete controls disabled Tab, Menu, Context Menu, file etc. Added child windows. Correction of known bugs. Import function of code: after the modifications to it, made by a programer. Complete mass Modification: (Maintenance menu in tools). Shrinking message loop and global variables: the ease of maintenance of the program is inversely proportional to this. Toolbar of Properties: converter of static (actual) to Dynamic. For easy add the new properties. Wanted Beta tester, developers and fresh ideas. Exampe of Independent Debug window. GuiBuilder v1.0.11.zip Regards Daniel1 point
-
My English is not so good. My code is written according to the Java Access Bridge Interface strictly. The Oracle official Document is not detailed enough. So the struct definition is written according to AccessBridgePackages.h, the data definition and function definition is written according to AccessBridgeCalls.h. If you installed accessbridge2_0_2, you will find these two files in src/include directory. During these two parts of coding , the data type conversion is the most confusing work. Firstly, according to AccessBridgeCalls.h, all these data type are same. In Autoit, it is "UINT64". typedef JOBJECT64 AccessibleContext; typedef JOBJECT64 AccessibleText; typedef JOBJECT64 AccessibleValue; typedef JOBJECT64 AccessibleSelection; typedef JOBJECT64 Java_Object; typedef JOBJECT64 PropertyChangeEvent; typedef JOBJECT64 FocusEvent; typedef JOBJECT64 CaretEvent; typedef JOBJECT64 MouseEvent; typedef JOBJECT64 MenuEvent; typedef JOBJECT64 AccessibleTable; typedef JOBJECT64 AccessibleHyperlink; typedef JOBJECT64 AccessibleHypertext; Secondly, how to definite a struct in struct. The C interface code: ****************************************************** * AccessibleAction packages ****************************************************** */ #define MAX_ACTION_INFO 256 #define MAX_ACTIONS_TO_DO 32 // an action assocated with a component typedef struct AccessibleActionInfoTag { wchar_t name[SHORT_STRING_SIZE]; // action name } AccessibleActionInfo; // all of the actions associated with a component typedef struct AccessibleActionsTag { jint actionsCount; // number of actions AccessibleActionInfo actionInfo[MAX_ACTION_INFO]; // the action information } AccessibleActions; // struct for requesting the actions associated with a component typedef struct GetAccessibleActionsPackageTag { long vmID; JOBJECT64 accessibleContext; // the component AccessibleActions rAccessibleActions; // the actions } GetAccessibleActionsPackage; // list of AccessibleActions to do typedef struct AccessibleActionsToDoTag { jint actionsCount; // number of actions to do AccessibleActionInfo actions[MAX_ACTIONS_TO_DO];// the accessible actions to do } AccessibleActionsToDo; // struct for sending an message to do one or more actions typedef struct DoAccessibleActionsPackageTag { long vmID; // the virtual machine ID JOBJECT64 accessibleContext; // component to do the action AccessibleActionsToDo actionsToDo;// the accessible actions to do BOOL rResult; // action return value jint failure; // index of action that failed if rResult is FALSE } DoAccessibleActionsPackage; We just need to implement three of them in Autoit: ;=====================================AccessibleAction================================ Global Const $MAX_ACTION_INFO = 256 Global Const $MAX_ACTIONS_TO_DO = 32 Global Const $tagAccessibleActionInfo = _ "WCHAR name[256]" Local $tag_ActionInfo = "" For $i = 1 To 256 If $tag_ActionInfo = "" Then $tag_ActionInfo = $tagAccessibleActionInfo Else $tag_ActionInfo = $tag_ActionInfo & ";" & $tagAccessibleActionInfo EndIf Next Global Const $tagAccessibleActions = _ "INT actionsCount;" & _ $tag_ActionInfo ; $tAccessibleActionInfo actionInfo[256] Local $tag_Actions = "" For $i = 1 To 32 If $tag_Actions = "" Then $tag_Actions = $tagAccessibleActionInfo Else $tag_Actions = $tag_Actions & ";" & $tagAccessibleActionInfo EndIf Next Global Const $tagAccessibleActionsToDo = _ "INT actionsCount;" & _ $tag_Actions ; $tAccessibleActions actions[32] Thirdly, how to set the data type in DllCall function. If it returns an object, you should use "ptr:cdecl". If the variable is kind of struct such as 'AccessibleContextInfo *info', you should use '"struct*", $info'. If the variable is string such as 'wchar_t *text', you should use '"wstr", $text'. Because in C, a string is an array of char, you must use it's pointer to access it. In the middle of the code, I write some _JAB function to implement some frequently used functions. The most important function is: Func _JAB_getAccessibleContextByFindAll($vmId, $ac, $sName, $sRole) Local $find_ac = 0 Local $iCount =_JAB_getChildrenCount($vmId, $ac) If $iCount = 0 Then Return EndIf For $i = 0 To $iCount - 1 Local $child_ac = __getAccessibleChildFromContext($vmId, $ac, $i) Local $s1 = _JAB_getName($vmId, $child_ac) Local $s3 = _JAB_getRole($vmId, $child_ac) ; consolewrite($child_ac & "|" & $s1 & "," & $s3 & @CRLF) If $s1 = $sName And $s3 = $sRole Then $find_ac = $child_ac ExitLoop Else If $find_ac = 0 Then $find_ac = _JAB_getAccessibleContextByFindAll($vmId, $child_ac, $sName, $sRole) EndIf EndIf Next Return $find_ac EndFunc Due to the lacking of element searching tools in java element tree, I write this recursive function.1 point
-
How to make Toast - New version 2 Aug 18
MONaH-Rasta reacted to Melba23 for a topic
[NEW VERSION] - 2 Aug 18 Added: When specifying the icon to use, if the $vIcon parameter is set to the name of an ico or exe file, the main icon within will be displayed, but if a trailing "|" followed by the icon index is added to the name, that icon from within the file is used New UDF and example in the first post. M231 point -
Writing to cmd
WIHedgehog reacted to Jos for a topic
That is because AutoIt3.exe is not a console program but rather a windows program... and it can only be one at the same time. Jos EDIT: There is NO problem!1 point -
How to make Toast - New version 2 Aug 18
MONaH-Rasta reacted to ResNullius for a topic
Melba23, Had occasion to make use of your very excellent Toast UDF in a recent project. Don't know if's been addressed in the 14 pages of posts so far, but I required the ability to use specific icons from the compiled exe and so I made a slight modification beginning at line 279 of your source where you check to see if an exe or ico file was passed to the function as the $vIcon parameter. ;Replace lines 279 to 286 in 01 April 17 verion of TOAST.AU3 ;Added by ResNullius to accomodate choice of multiple icons in exe, dll If StringInStr($vIcon, "|") Then $iIcon_Style = StringRegExpReplace($vIcon, "(.*)\|", "") $sDLL = StringRegExpReplace($vIcon, "\|.*$", "") Else ;End Added by ResNullius to accomodate numbered icons in exe Switch StringLower(StringRight($vIcon, 3)) Case "exe", "ico" $sDLL = $vIcon $iIcon_Style = 0 Case "bmp", "jpg", "gif", "png" $sImg = $vIcon EndSwitch EndIf EndIf I call it from the compiled script like this: _Toast_Show(@AutoItExe & "|203", "My Program", "My Message",3) ;or _ToastShow("C:\CoolScripts\MyCoolScript.exe|201","My Cool Script", "My Cool Message",3) The pipe symbol "|" is used to separate the file name from the icon's resource/ordinal name. Not tested extensively, but worked a treat for my purposes. Thanks again for all you do for this community!1 point -
How to make Toast - New version 2 Aug 18
MONaH-Rasta reacted to Melba23 for a topic
[NEW VERSION] - 1 Apr 17 Added: Ability to set time taken for Toast to extend and retract (default 1.0/.5 sec) Fixed: An edge case bug where showing a new Toast while the previous was actually retracting caused the new Toast to vanish instantly. Thanks to Danp2 for the report and feature request. New UDF and example in the first post. M231 point -
How to make Toast - New version 2 Aug 18
MONaH-Rasta reacted to Melba23 for a topic
[NEW VERSION] - 2 Jun 14 Some Global variables were renamed in AutoIt v3.3.12.0 - code updated to match. New UDF and zip in first post. M231 point -
How to make Toast - New version 2 Aug 18
MONaH-Rasta reacted to Melba23 for a topic
nitekram, Sorry for the delay in replying - I have been off flying again. That was entirely my fault - I forgot that using Default as a parameter for the $vJust parameter also sets all the others (including the new one) to Default as well. So I was basically over-ruling the parameter I was trying to set! If you use this and it works then all is well: Func _Toast_Set(1, Default, Default, Default, Default, Default, Default, 3) As you say it does I think we can call this a success for you - now I need to work with MilesAhead to get his toolbar playing along nicely with the new code. M231 point -
How to make Toast - New version 2 Aug 18
MONaH-Rasta reacted to Melba23 for a topic
nitekram, I have added a new parameter to tell the UDF if the taskbar is located on a secondary monitor and where that monitor is placed (right/below/left/above) in relation to the main monitor as it became too complex to work it out from the various measurements. So you will need to add a _Toast_Set line like this at the top of the script: Func _Toast_Set(Default, Default, Default, Default, Default, Default, Default, 3) to tell the UDF that you have the taskbar on a secondary monitor to the left of the main monitor. If you need to replace any of the Default parameters then please do so - the important bit is the 3 at the end. Then use this version to test - it gives the correct results when I run it with the data you gave me, but the real test is when you try it: #include-once ; #INDEX# ============================================================================================================ ; Title .........: Toast ; AutoIt Version : 3.3.8.0 ; Language ......: English ; Description ...: Show and hides slice messages from the systray in user defined colours and fonts ; Author(s) .....: Melba23 - using some code from guinness and MilesAhead in _Toast_Locate ; ==================================================================================================================== ;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 ; #INCLUDES# ========================================================================================================= #include <StringSize.au3> #include <GDIPlus.au3> ; #GLOBAL VARIABLES# ================================================================================================= Global $iDef_Toast_Font_Size = _Toast_GetDefFont(0) Global $sDef_Toast_Font_Name = _Toast_GetDefFont(1) Global $hToast_Handle = 0 Global $hToast_Close_X = 9999 Global $iToast_Move = 0 Global $iToast_Style = 1 ; $SS_CENTER Global $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 8) ; $COLOR_WINDOWTEXT = 8 Global $iToast_Header_BkCol = $aRet[0] $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 5) ; $COLOR_WINDOW = 5 Global $iToast_Header_Col = $aRet[0] Global $iToast_Header_Bold = 0 Global $iToast_Message_BkCol = $iToast_Header_Col Global $iToast_Message_Col = $iToast_Header_BkCol Global $iToast_Font_Size = $iDef_Toast_Font_Size Global $sToast_Font_Name = $sDef_Toast_Font_Name Global $iToast_Taskbar = 0 Global $iToast_Timer = 0 Global $iToast_Start = 0 Global $fToast_Close = False ; #CURRENT# ========================================================================================================== ; _Toast_Set: Sets text justification and optionally colours and font, for _Toast_Show function calls ; _Toast_Show: Shows a slice message from the systray ; _Toast_Hide: Hides a slice message from the systray ; ==================================================================================================================== ; #INTERNAL_USE_ONLY#================================================================================================= ; _Toast_Locate: Find Systray and determine Toast start position and movement direction ; _Toast_Timer_Check: Checks whether Toast has timed out or closure [X] clicked ; _Toast_WM_EVENTS: Message handler to check if closure [X] clicked ; _Toast_GetDefFont: Determine system default MsgBox font and size ; _Toast_ShowPNG: Set PNG as image ; _Toast_BitmapCreateDIB: Create bitmap ; ==================================================================================================================== ; #FUNCTION# ========================================================================================================= ; Name...........: _Toast_Set ; Description ...: Sets text justification and optionally colours and font, for _Toast_Show function calls ; Syntax.........: _Toast_Set($vJust, [$iHdr_BkCol, [$iHdr_Col, [$iMsg_BkCol, [$iMsg_Col, [$sFont_Size, [$iFont_Name, [$iTaskbar]]]]]]]) ; Parameters ....: $vJust - 0 = Left justified, 1 = Centred (Default), 2 = Right justified ; Can use $SS_LEFT, $SS_CENTER, $SS_RIGHT ; + 4 = Header text in bold ; >>>>> Setting this parameter to' Default' will reset ALL parameters to default values <<<<< ; >>>>> All optional parameters default to system MsgBox default values <<<<< ; $iHdr_BkCol - [Optional] The colour for the title bar background ; $iHdr_Col - [Optional] The colour for the title bar text ; $iMsg_BkCol - [Optional] The colour for the message background ; $iMsg_Col - [Optional] The colour for the message text ; Omitting a colour parameter or setting it to -1 leaves it unchanged ; Setting a colour parameter to Default resets the system colour ; $iFont_Size - [Optional] The font size in points to use for the Toast ; $sFont_Name - [Optional] The font to use for the Toast ; >>>>> Omitting a font parameter, setting size to -1 or name to "" leaves it unchanged <<<<< ; >>>>> Setting a font parameter to Default resets the system message box font or size <<<<< ; $iTaskbar - [Optional] 0 - Taskbar on main monitor (default) ; 1 - Taskbar on secondary monitor to right ; 2 - Taskbar on secondary monitor below ; 3 - Taskbar on secondary monitor to left ; 4 - Taskbar on secondary monitor above ; +8 - Toolbar docked to taskbar ; Requirement(s).: v3.3.2.0 or higher - AdlibRegister/Unregister used in _Toast_Show ; Return values .: Success - Returns 1 ; Failure - Returns 0 and sets @error to 1 with @extended set to parameter index number ; Author ........: Melba23 ; Example........; Yes ;===================================================================================================================== Func _Toast_Set($vJust, $iHdr_BkCol = -1, $iHdr_Col = -1, $iMsg_BkCol = -1, $iMsg_Col = -1, $iFont_Size = -1, $sFont_Name = "", $iTaskbar = 0) ; Set parameters Switch $vJust Case Default $iToast_Style = 1; $SS_CENTER $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 8) ; $COLOR_WINDOWTEXT = 8 $iToast_Header_BkCol = $aRet[0] $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 5) ; $COLOR_WINDOW = 5 $iToast_Header_Col = $aRet[0] $iToast_Message_BkCol = $iToast_Header_Col $iToast_Message_Col = $iToast_Header_BkCol $sToast_Font_Name = $sDef_Toast_Font_Name $iToast_Font_Size = $iDef_Toast_Font_Size $iToast_Taskbar = 0 Return Case 0, 1, 2, 4, 5, 6 $iToast_Style = $vJust Case -1 ; Do nothing Case Else Return SetError(1, 1, 0) EndSwitch Switch $iHdr_BkCol Case Default $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 8) ; $COLOR_WINDOWTEXT = 8 $iToast_Header_BkCol = $aRet[0] Case 0 To 0xFFFFFF $iToast_Header_BkCol = Int($iHdr_BkCol) Case -1 ; Do nothing Case Else Return SetError(1, 2, 0) EndSwitch Switch $iHdr_Col Case Default $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 5) ; $COLOR_WINDOW = 5 $iToast_Header_Col = $aRet[0] Case 0 To 0xFFFFFF $iToast_Header_Col = Int($iHdr_Col) Case -1 ; Do nothing Case Else Return SetError(1, 3, 0) EndSwitch Switch $iMsg_BkCol Case Default $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 5) ; $COLOR_WINDOW = 5 $iToast_Message_BkCol = $aRet[0] Case 0 To 0xFFFFFF $iToast_Message_BkCol = Int($iMsg_BkCol) Case -1 ; Do nothing Case Else Return SetError(1, 4, 0) EndSwitch Switch $iMsg_Col Case Default $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 8) ; $COLOR_WINDOWTEXT = 8 $iToast_Message_Col = $aRet[0] Case 0 To 0xFFFFFF $iToast_Message_Col = Int($iMsg_Col) Case -1 ; Do nothing Case Else Return SetError(1, 5, 0) EndSwitch Switch $iFont_Size Case Default $iToast_Font_Size = $iDef_Toast_Font_Size Case 8 To 72 $iToast_Font_Size = Int($iFont_Size) Case -1 ; Do nothing Case Else Return SetError(1, 6, 0) EndSwitch Switch $sFont_Name Case Default $sToast_Font_Name = $sDef_Toast_Font_Name Case "" ; Do nothing Case Else If IsString($sFont_Name) Then $sToast_Font_Name = $sFont_Name Else Return SetError(1, 7, 0) EndIf EndSwitch Switch $iTaskbar Case Default $iToast_Taskbar = 0 Case 0 To 4, 8 To 12 If IsInt($iTaskbar) Then $iToast_Taskbar = $iTaskbar Else $iToast_Taskbar = 0 EndIf EndSwitch Return 1 EndFunc ;==>_Toast_Set ; #FUNCTION# ========================================================================================================= ; Name...........: _Toast_Show ; Description ...: Shows a slice message from the systray ; Syntax.........: _Toast_Show($vIcon, $sTitle, $sMessage, [$iDelay [, $fWait [, $fRaw]]]) ; Parameters ....: $vIcon - 0 - No icon, 8 - UAC, 16 - Stop, 32 - Query, 48 - Exclamation, 64 - Information ; The $MB_ICON constant can also be used for the last 4 above ; If set to the name of an exe, the main icon of that exe will be displayed ; If set to the name of an image file, that image will be displayed ; Any other value returns -1, error 1 ; $sTitle - Text to display on Title bar ; $sMessage - Text to display in Toast body ; $iDelay - The delay in seconds before the Toast retracts or script continues (Default = 0) ; If negative, an [X] is added to the title bar. Clicking [X] retracts/continues immediately ; $fWait - True - Script waits for delay time before continuing and Toast remains visible ; False - Script continues and Toast retracts automatically after delay time ; $fRaw - True - Message is not wrapped and Toast expands to show full width ; - False - Message is wrapped if over max preset Toast width ; Requirement(s).: v3.3.1.5 or higher - AdlibRegister/Unregister used in _Toast_Show ; Return values .: Success: Returns 2-element array: [Toast width, Toast height] ; Failure: Returns -1 and sets @error as follows: ; 1 = Toast GUI creation failed ; 2 = Taskbar not found ; 4 = When using Raw, the Toast is too wide for the display ; 3 = StringSize error ; Author ........: Melba23, based on some original code by GioVit for the Toast ; Notes .........; Any visible Toast is retracted by a subsequent _Toast_Hide or _Toast_Show, or clicking a visible [X] ; Example........; Yes ;===================================================================================================================== Func _Toast_Show($vIcon, $sTitle, $sMessage, $iDelay = 0, $fWait = True, $fRaw = False) ; Store current GUI mode and set Message mode Local $nOldOpt = Opt('GUIOnEventMode', 0) ; Retract any Toast already in place If $hToast_Handle <> 0 Then _Toast_Hide() ; Reset non-reacting Close [X] ControlID $hToast_Close_X = 9999 ; Set default auto-sizing Toast widths Local $iToast_Width_max = 500 Local $iToast_Width_min = 150 ; Check for icon Local $iIcon_Style = 0 Local $iIcon_Reduction = 36 Local $sDLL = "user32.dll" Local $sImg = "" If StringIsDigit($vIcon) Then Switch $vIcon Case 0 $iIcon_Reduction = 0 Case 8 $sDLL = "imageres.dll" $iIcon_Style = 78 Case 16 ; Stop $iIcon_Style = -4 Case 32 ; Query $iIcon_Style = -3 Case 48 ; Exclam $iIcon_Style = -2 Case 64 ; Info $iIcon_Style = -5 Case Else Return SetError(1, 0, -1) EndSwitch Else Switch StringLower(StringRight($vIcon, 3)) Case "exe", "ico" $sDLL = $vIcon $iIcon_Style = 0 Case "bmp", "jpg", "gif", "png" $sImg = $vIcon EndSwitch EndIf ; Determine max message width Local $iMax_Label_Width = $iToast_Width_max - 20 - $iIcon_Reduction If $fRaw = True Then $iMax_Label_Width = 0 ; Get message label size Local $aLabel_Pos = _StringSize($sMessage, $iToast_Font_Size, Default, Default, $sToast_Font_Name, $iMax_Label_Width) If @error Then $nOldOpt = Opt('GUIOnEventMode', $nOldOpt) Return SetError(3, 0, -1) EndIf ; Reset text to match rectangle $sMessage = $aLabel_Pos[0] ;Set line height for this font Local $iLine_Height = $aLabel_Pos[1] ; Set label size Local $iLabelwidth = $aLabel_Pos[2] Local $iLabelheight = $aLabel_Pos[3] ; Set Toast size Local $iToast_Width = $iLabelwidth + 20 + $iIcon_Reduction ; Check if Toast will fit on screen If $iToast_Width > @DesktopWidth - 20 Then $nOldOpt = Opt('GUIOnEventMode', $nOldOpt) Return SetError(4, 0, -1) EndIf ; Increase if below min size If $iToast_Width < $iToast_Width_min + $iIcon_Reduction Then $iToast_Width = $iToast_Width_min + $iIcon_Reduction $iLabelwidth = $iToast_Width_min - 20 EndIf ; Set title bar height - with minimum for [X] Local $iTitle_Height = 0 If $sTitle = "" Then If $iDelay < 0 Then $iTitle_Height = 6 Else $iTitle_Height = $iLine_Height + 2 If $iDelay < 0 Then If $iTitle_Height < 17 Then $iTitle_Height = 17 EndIf EndIf ; Set Toast height as label height + title bar + bottom margin Local $iToast_Height = $iLabelheight + $iTitle_Height + 20 ; Ensure enough room for icon if displayed If $iIcon_Reduction Then If $iToast_Height < $iTitle_Height + 42 Then $iToast_Height = $iTitle_Height + 47 EndIf ; Get Toast starting position and direction Local $aToast_Data = _Toast_Locate($iToast_Width, $iToast_Height) ; Create Toast slice with $WS_POPUPWINDOW, $WS_EX_TOOLWINDOW style and $WS_EX_TOPMOST extended style $hToast_Handle = GUICreate("", $iToast_Width, $iToast_Height, $aToast_Data[0], $aToast_Data[1], 0x80880000, BitOR(0x00000080, 0x00000008)) If @error Then $nOldOpt = Opt('GUIOnEventMode', $nOldOpt) Return SetError(1, 0, -1) EndIf GUISetFont($iToast_Font_Size, Default, Default, $sToast_Font_Name) GUISetBkColor($iToast_Message_BkCol) ; Set centring parameter Local $iLabel_Style = 0 ; $SS_LEFT If BitAND($iToast_Style, 1) = 1 Then $iLabel_Style = 1 ; $SS_CENTER ElseIf BitAND($iToast_Style, 2) = 2 Then $iLabel_Style = 2 ; $SS_RIGHT EndIf ; Check installed fonts Local $sX_Font = "WingDings" Local $sX_Char = "x" Local $i = 1 While 1 Local $sInstalled_Font = RegEnumVal("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts", $i) If @error Then ExitLoop If StringInStr($sInstalled_Font, "WingDings 2") Then $sX_Font = "WingDings 2" $sX_Char = "T" EndIf $i += 1 WEnd ; Create title bar if required If $sTitle <> "" Then ; Create disabled background strip GUICtrlCreateLabel("", 0, 0, $iToast_Width, $iTitle_Height) GUICtrlSetBkColor(-1, $iToast_Header_BkCol) GUICtrlSetState(-1, 128) ; $GUI_DISABLE ; Set title bar width to offset text Local $iTitle_Width = $iToast_Width - 10 ; Create closure [X] if needed If $iDelay < 0 Then ; Create [X] Local $iX_YCoord = Int(($iTitle_Height - 17) / 2) $hToast_Close_X = GUICtrlCreateLabel($sX_Char, $iToast_Width - 18, $iX_YCoord, 17, 17) GUICtrlSetFont(-1, 14, Default, Default, $sX_Font) GUICtrlSetBkColor(-1, -2) ; $GUI_BKCOLOR_TRANSPARENT GUICtrlSetColor(-1, $iToast_Header_Col) ; Reduce title bar width to allow [X] to activate $iTitle_Width -= 18 EndIf ; Create Title label with bold text, centred vertically in case bar is higher than line GUICtrlCreateLabel($sTitle, 10, 0, $iTitle_Width, $iTitle_Height, 0x0200) ; $SS_CENTERIMAGE GUICtrlSetBkColor(-1, $iToast_Header_BkCol) GUICtrlSetColor(-1, $iToast_Header_Col) If BitAND($iToast_Style, 4) = 4 Then GUICtrlSetFont(-1, $iToast_Font_Size, 600) Else If $iDelay < 0 Then ; Only need [X] $hToast_Close_X = GUICtrlCreateLabel($sX_Char, $iToast_Width - 18, 0, 17, 17) GUICtrlSetFont(-1, 14, Default, Default, $sX_Font) GUICtrlSetBkColor(-1, -2) ; $GUI_BKCOLOR_TRANSPARENT GUICtrlSetColor(-1, $iToast_Message_Col) EndIf EndIf ; Create icon If $iIcon_Reduction Then Switch StringLower(StringRight($sImg, 3)) Case "bmp", "jpg", "gif" GUICtrlCreatePic($sImg, 10, 10 + $iTitle_Height, 32, 32) Case "png" _Toast_ShowPNG($sImg, $iTitle_Height) Case Else GUICtrlCreateIcon($sDLL, $iIcon_Style, 10, 10 + $iTitle_Height) EndSwitch EndIf ; Create Message label GUICtrlCreateLabel($sMessage, 10 + $iIcon_Reduction, 10 + $iTitle_Height, $iLabelwidth, $iLabelheight) GUICtrlSetStyle(-1, $iLabel_Style) If $iToast_Message_Col <> Default Then GUICtrlSetColor(-1, $iToast_Message_Col) ; Slide Toast Slice into view from behind systray and activate DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hToast_Handle, "int", 1000, "long", $aToast_Data[2]) ; Activate Toast without stealing focus GUISetState(@SW_SHOWNOACTIVATE, $hToast_Handle) ; If script is to pause If $fWait = True Then ; Clear message queue Do Until GUIGetMsg() = 0 ; Begin timeout counter Local $iTimeout_Begin = TimerInit() ; Wait for timeout or closure While 1 If GUIGetMsg() = $hToast_Close_X Or TimerDiff($iTimeout_Begin) / 1000 >= Abs($iDelay) Then ExitLoop WEnd ; If script is to continue and delay has been set ElseIf Abs($iDelay) > 0 Then ; Store timer info $iToast_Timer = Abs($iDelay * 1000) $iToast_Start = TimerInit() ; Register Adlib function to run timer AdlibRegister("_Toast_Timer_Check", 100) ; Register message handler to check for [X] click GUIRegisterMsg(0x0021, "_Toast_WM_EVENTS") ; $WM_MOUSEACTIVATE EndIf ; Reset original mode $nOldOpt = Opt('GUIOnEventMode', $nOldOpt) ; Create array to return Toast dimensions Local $aToast_Data[3] = [$iToast_Width, $iToast_Height, $iLine_Height] Return $aToast_Data EndFunc ;==>_Toast_Show ; #FUNCTION# ======================================================================================================== ; Name...........: _Toast_Hide ; Description ...: Hides a slice message from the systray ; Syntax.........: _Toast_Hide() ; Requirement(s).: v3.3.1.5 or higher - AdlibRegister used in _Toast_Show ; Return values .: Success: Returns 0 ; Failure: If Toast does not exist returns -1 and sets @error to 1 ; Author ........: Melba23 ; Example........; Yes ;===================================================================================================================== Func _Toast_Hide() ; If no Toast to hide, return If $hToast_Handle = 0 Then Return SetError(1, 0, -1) ; Slide Toast back behind systray DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hToast_Handle, "int", 500, "long", $iToast_Move) ; Delete Toast slice GUIDelete($hToast_Handle) ; Set flag for "no Toast" $hToast_Handle = 0 ; Unregister a possible message handler GUIRegisterMsg(0x0021, "") ; $WM_MOUSEACTIVATE ; Unregister a possible Adlib function AdlibUnRegister("_Toast_Timer_Check") ; Clear possible flag $fToast_Close = False EndFunc ;==>_Toast_Hide ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _Toast_Locate ; Description ...: Find Systray and determine Toast start position and movement direction ; Syntax ........: _Toast_Locate($iToast_Width, $iToast_Height) ; Parameters ....: $iToast_Width - required width of slice ; $iToast_Height - required height of slice ; Author ........: Melba23 - using some code from guinness and MilesAhead ; Modified.......: ; Remarks .......: This function is used internally by _Toast_Show ; =============================================================================================================================== Func _Toast_Locate($iToast_Width, $iToast_Height) ; Define return array Local $aToast_Data[3] ; Create struct ;Local $tWorkArea = DllStructCreate("struct;long Left;long Top;long Right;long Bottom;endstruct") If BitAND($iToast_Taskbar, 8) Then ; Docked toolbar $iToast_Taskbar -= 8 #cs ; Get monitor info Local $aMonitors = _WinAPI_EnumDisplayMonitors() $aData = _WinAPI_GetMonitorInfo($aMonitors[$iToast_Taskbar][0]) Local $aScreenSize = Local $aWorkArea[4] = [DllStructGetData($aData[1], 1), _ DllStructGetData($aData[1], 2), _ DllStructGetData($aData[1], 3), _ DllStructGetData($aData[1], 4)] ; Determine direction of Toast motion and starting position If $aWorkArea[3] <> @DesktopHeight Then $iToast_Move = 0x00050004 ; $AW_SLIDE_OUT_BOTTOM $aToast_Data[0] = @DesktopWidth - $iToast_Width - 10 $aToast_Data[1] = $aWorkArea[3] - $iToast_Height - 2 $aToast_Data[2] = 0x00040008 ; $AW_SLIDE_IN_BOTTOM ElseIf $aWorkArea[2] <> @DesktopWidth Then $iToast_Move = 0x00050001 ; $AW_SLIDE_OUT_RIGHT $aToast_Data[0] = $aWorkArea[2] - $iToast_Width - 2 $aToast_Data[1] = @DesktopHeight - $iToast_Height - 10 $aToast_Data[2] = 0x00040002 ; $AW_SLIDE_IN_RIGHT ElseIf $aWorkArea[1] <> 0 Then $iToast_Move = 0x00050008 ; $AW_SLIDE_OUT_TOP $aToast_Data[0] = @DesktopWidth - $iToast_Width - 10 $aToast_Data[1] = $aWorkArea[1] $aToast_Data[2] = 0x00040004 ; $AW_SLIDE_IN_TOP ElseIf $aWorkArea[0] <> 0 Then $iToast_Move = 0x00050002 ; $AW_SLIDE_OUT_LEFT $aToast_Data[0] = $aWorkArea[0] $aToast_Data[1] = @DesktopHeight - $iToast_Height - 10 $aToast_Data[2] = 0x00040001 ; $AW_SLIDE_IN_LEFT EndIf #ce Else ; Find taskbar Local $iPrevMode = Opt("WinTitleMatchMode", 4) Local $aTray_Pos = WinGetPos("[CLASS:Shell_TrayWnd]") Opt("WinTitleMatchMode", $iPrevMode) ; If error in finding systray If Not IsArray($aTray_Pos) Then Return SetError(2, 0, -1) ConsoleWrite("Taskbar: " & $aTray_Pos[0] & " - " & $aTray_Pos[1] & " - " & $aTray_Pos[2] & " - " & $aTray_Pos[3] & @CRLF) ; Get virtual desktop size Local $aRet = DllCall("user32.dll", "int", "GetSystemMetrics", "int", 78) ; $SM_VIRTUALWIDTH Local $iVirtualDesktopWidth = $aRet[0] $aRet = DllCall("user32.dll", "int", "GetSystemMetrics", "int", 79) ; $SM_VIRTUALHEIGHT Local $iVirtualDesktopHeight = $aRet[0] ConsoleWrite("Virtual Destop: " & $iVirtualDesktopWidth & " - " & $iVirtualDesktopHeight & @CRLF) ; Default values for single monitor Local $iLeft = 0, $iRight = @DesktopWidth, $iTop = 0, $iBottom = @DesktopHeight Switch $iToast_Taskbar Case 1 ; Secondary monitor to right $iLeft = @DesktopWidth $iRight = $iVirtualDesktopWidth Case 2 ; Secondary monitor below $iTop = @DesktopHeight $iBottom = $iVirtualDesktopHeight Case 3 ; Secondary monitor to left $iLeft = @DesktopWidth - $iVirtualDesktopWidth $iRight = 0 ConsoleWrite("L/R: " & $iLeft & " - " & $iRight & @CRLF) Case 4 ; Secondary monitor above $iTop = @DesktopHeight - $iVirtualDesktopHeight $iBottom = 0 EndSwitch ; Determine direction of Toast motion and starting position If $aTray_Pos[1] > $iTop Then $iToast_Move = 0x00050004 ; $AW_SLIDE_OUT_BOTTOM $aToast_Data[0] = $iRight - $iToast_Width - 10 $aToast_Data[1] = $aTray_Pos[1] - $iToast_Height - 2 $aToast_Data[2] = 0x00040008 ; $AW_SLIDE_IN_BOTTOM ElseIf $aTray_Pos[0] > $iLeft Then $iToast_Move = 0x00050001 ; $AW_SLIDE_OUT_RIGHT $aToast_Data[0] = $aTray_Pos[0] - $iToast_Width - 2 $aToast_Data[1] = $iBottom - $iToast_Height - 10 $aToast_Data[2] = 0x00040002 ; $AW_SLIDE_IN_RIGHT ElseIf $aTray_Pos[2] > $iRight - 70 Then $iToast_Move = 0x00050008 ; $AW_SLIDE_OUT_TOP $aToast_Data[0] = $iRight - $iToast_Width - 10 $aToast_Data[1] = $aTray_Pos[1] + $aTray_Pos[3] $aToast_Data[2] = 0x00040004 ; $AW_SLIDE_IN_TOP ElseIf $aTray_Pos[3] >= $iBottom Then $iToast_Move = 0x00050002 ; $AW_SLIDE_OUT_LEFT $aToast_Data[0] = $aTray_Pos[0] + $aTray_Pos[2] $aToast_Data[1] = $iBottom - $iToast_Height - 10 $aToast_Data[2] = 0x00040001 ; $AW_SLIDE_IN_LEFT EndIf ConsoleWrite("Toast: " & $aToast_Data[0] & " - " & $aToast_Data[1] & " - " & $iToast_Width & " - " & $iToast_Height & @CRLF) EndIf Return $aToast_Data EndFunc ;==>_Toast_Locate ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _Toast_Timer_Check ; Description ...: Checks whether Toast has timed out or closure [X] clicked ; Syntax ........: _Toast_Timer_Check() ; Author ........: Melba23 ; Modified.......: ; Remarks .......: This function is used internally by _Toast_Show if the Wait parameter is set to False ; =============================================================================================================================== Func _Toast_Timer_Check() ; Return if timeout not elapsed and [X] not clicked If TimerDiff($iToast_Start) < $iToast_Timer And $fToast_Close = False Then Return ; Retract slice _Toast_Hide() EndFunc ;==>_Toast_Timer_Check ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _Toast_WM_EVENTS ; Description ...: Message handler to check if closure [X] clicked ; Author ........: Melba23 ; Modified.......: ; Remarks .......: This function is used internally by _Toast_Show if the Wait parameter is set to False ; =============================================================================================================================== Func _Toast_WM_EVENTS($hWnd, $Msg, $wParam, $lParam) #forceref $wParam, $lParam If $hWnd = $hToast_Handle Then If $Msg = 0x0021 Then ; $WM_MOUSEACTIVATE ; Check mouse position Local $aPos = GUIGetCursorInfo($hToast_Handle) If $aPos[4] = $hToast_Close_X Then $fToast_Close = True EndIf EndIf Return 'GUI_RUNDEFMSG' EndFunc ;==>_Toast_WM_EVENTS ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _Toast_GetDefFont ; Description ...: Determine system default MsgBox font and size ; Syntax ........: _Toast_GetDefFont($iData) ; Parameters ....: $iData - 0 = Font point size, 1 = Font name ; Author ........: Melba23 ; Modified.......: ; Remarks .......: This function is used internally by _Toast functions ; =============================================================================================================================== Func _Toast_GetDefFont($iData) ; Get default system font data Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]") DllStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS)) DllCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0) ; Read font data for MsgBox font Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DllStructGetPtr($tNONCLIENTMETRICS, 15)) Switch $iData Case 0 ; Font size as integer Return Int((Abs(DllStructGetData($tLOGFONT, 1)) + 1) * .75) Case 1 ; Font name Return DllStructGetData($tLOGFONT, 14) EndSwitch EndFunc ;==>_Toast_GetDefFont ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _Toast_ShowPNG ; Description ...: Set PNG as image ; Syntax ........: _Toast_ShowPNG($sImg) ; Parameters ....: $sImg - Path of image file ; Author ........: UEZ ; Modified.......: Melba23 ; Remarks .......: ; =============================================================================================================================== Func _Toast_ShowPNG($sImg, $iTitle_Height) _GDIPlus_Startup() Local $hPic = GUICtrlCreatePic("", 10, 10 + $iTitle_Height, 32, 32) Local $hBitmap = _GDIPlus_BitmapCreateFromFile($sImg) Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", 32, "int", 32, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0) Local $hBitmap_Resized = $aResult[6] Local $hBMP_Ctxt = _GDIPlus_ImageGetGraphicsContext($hBitmap_Resized) DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "handle", $hBMP_Ctxt, "int", 7) _GDIPlus_GraphicsDrawImageRect($hBMP_Ctxt, $hBitmap, 0, 0, 32, 32) Local $hHBitmap = _Toast_BitmapCreateDIB($hBitmap_Resized) _WinAPI_DeleteObject(GUICtrlSendMsg($hPic, 0x0172, 0, $hHBitmap)) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_BitmapDispose($hBitmap_Resized) _GDIPlus_GraphicsDispose($hBMP_Ctxt) _WinAPI_DeleteObject($hHBitmap) _GDIPlus_Shutdown() EndFunc ;==>_Toast_ShowPNG ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: _Toast_BitmapCreateDIB ; Description ...: Create bitmap ; Syntax ........: _Toast_BitmapCreateDIB($hBitmap) ; Parameters ....: $hBitmap - Handle of bitmap ; Author ........: UEZ ; Modified.......: ; Remarks .......: ; =============================================================================================================================== Func _Toast_BitmapCreateDIB($hBitmap) Local $hRet = 0 Local $aRet1 = DllCall($ghGDIPDll, "uint", "GdipGetImageDimension", "ptr", $hBitmap, "float*", 0, "float*", 0) If (@error) Or ($aRet1[0]) Then Return 0 Local $tData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $aRet1[2], $aRet1[3], $GDIP_ILMREAD, $GDIP_PXF32ARGB) Local $pBits = DllStructGetData($tData, "Scan0") If Not $pBits Then Return 0 Local $tBIHDR = DllStructCreate("dword;long;long;ushort;ushort;dword;dword;long;long;dword;dword") DllStructSetData($tBIHDR, 1, DllStructGetSize($tBIHDR)) DllStructSetData($tBIHDR, 2, $aRet1[2]) DllStructSetData($tBIHDR, 3, $aRet1[3]) DllStructSetData($tBIHDR, 4, 1) DllStructSetData($tBIHDR, 5, 32) DllStructSetData($tBIHDR, 6, 0) Local $aRet2 = DllCall("gdi32.dll", "ptr", "CreateDIBSection", "hwnd", 0, "ptr", DllStructGetPtr($tBIHDR), "uint", 0, "ptr*", 0, "ptr", 0, "dword", 0) If (Not @error) And ($aRet2[0]) Then DllCall("gdi32.dll", "dword", "SetBitmapBits", "ptr", $aRet2[0], "dword", $aRet1[2] * $aRet1[3] * 4, "ptr", DllStructGetData($tData, "Scan0")) $hRet = $aRet2[0] EndIf _GDIPlus_BitmapUnlockBits($hBitmap, $tData) Return $hRet EndFunc ;==>_Toast_BitmapCreateDIB Please let me have the console data as usual. I am keeping my fingers firmly crossed! M231 point -
How to make Toast - New version 2 Aug 18
MONaH-Rasta reacted to Melba23 for a topic
Syed23, As so much of the Toast UDF is taken up by code to make the GUI as small as possible, I cannot really see the point in altering it to become very large. I would suggest using something along these lines (credit to Gary Frost): #include-once ; Declare AnimateWindow constants Global Const $AW_FADE_IN = 0x00080000 Global Const $AW_FADE_OUT = 0x00090000 Global Const $AW_EXPLODE = 0x00040010 Global Const $AW_IMPLODE = 0x00050010 Global Const $AW_SLIDE_IN_LEFT = 0x00040001 Global Const $AW_SLIDE_OUT_LEFT = 0x00050002 Global Const $AW_SLIDE_IN_RIGHT = 0x00040002 Global Const $AW_SLIDE_OUT_RIGHT = 0x00050001 Global Const $AW_SLIDE_IN_TOP = 0x00040004 Global Const $AW_SLIDE_OUT_TOP = 0x00050008 Global Const $AW_SLIDE_IN_BOTTOM = 0x00040008 Global Const $AW_SLIDE_OUT_BOTTOM = 0x00050004 Global Const $AW_DIAG_SLIDE_IN_TOPLEFT = 0x00040005 Global Const $AW_DIAG_SLIDE_OUT_TOPLEFT = 0x0005000A Global Const $AW_DIAG_SLIDE_IN_TOPRIGHT = 0x00040006 Global Const $AW_DIAG_SLIDE_OUT_TOPRIGHT = 0x00050009 Global Const $AW_DIAG_SLIDE_IN_BOTTOMLEFT = 0x00040009 Global Const $AW_DIAG_SLIDE_OUT_BOTTOMLEFT = 0x00050006 Global Const $AW_DIAG_SLIDE_IN_BOTTOMRIGHT = 0x0004000A Global Const $AW_DIAG_SLIDE_OUT_BOTTOMRIGHT = 0x00050005 ; #FUNCTION# ========================================================================================================= ; Name...........: _WinAnimate ; Description ...: Animates windows by sliding, fading or exploding in/out ; Syntax.........: _WinAnimate($v_gui, $i_mode, [$i_duration]) ; Parameters ....: $v_gui -> Either handle or title of window to animate ; $i_mode -> $AW constant from above ; $i_duration -> Speed of animation (higher = slower) ; Requirement(s).: v3.2.12.1 or higher ; Return values .: Success: Returns 1 ; Failure: Returns 0, Error 1 = DLL call fail, Error 2 = OS version incapable ; Author ........: Gary Frost ; Example........; Yes ;===================================================================================================================== Func _WinAnimate($h_gui, $i_mode, $i_duration = 1000) DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $h_gui, "int", $i_duration, "long", $i_mode) Local $ai_gle = DllCall('kernel32.dll', 'int', 'GetLastError') If $ai_gle[0] <> 0 Then Return SetError(1, 0, 0) EndIf Return 1 EndFunc ;==> $RetValue = _WinAnimate() ; Example $hwnd = GUICreate("AnimateWindow - Demo", @DesktopWidth, @DesktopHeight - 40, 0, 0) GUISetBkColor(0xFFFF00) $RetValue = _WinAnimate($hwnd, $AW_FADE_IN) ConsoleWrite($RetValue & " " & "Err: " & @error & " " & "Ext: " & @extended & @CRLF) Sleep(1500) $RetValue = _WinAnimate($hwnd, $AW_FADE_OUT) ConsoleWrite($RetValue & " " & "Err: " & @error & " " & "Ext: " & @extended & @CRLF) Sleep(1500) $RetValue = _WinAnimate($hwnd, $AW_EXPLODE) ConsoleWrite($RetValue & " " & "Err: " & @error & " " & "Ext: " & @extended & @CRLF) Sleep(1500) $RetValue = _WinAnimate($hwnd, $AW_IMPLODE) ConsoleWrite($RetValue & " " & "Err: " & @error & " " & "Ext: " & @extended & @CRLF) Sleep(1500) $RetValue = _WinAnimate($hwnd, $AW_SLIDE_IN_LEFT) ConsoleWrite($RetValue & " " & "Err: " & @error & " " & "Ext: " & @extended & @CRLF) Sleep(1500) $RetValue = _WinAnimate($hwnd, $AW_SLIDE_OUT_LEFT) ConsoleWrite($RetValue & " " & "Err: " & @error & " " & "Ext: " & @extended & @CRLF) Sleep(1500) $RetValue = _WinAnimate($hwnd, $AW_SLIDE_IN_RIGHT) ConsoleWrite($RetValue & " " & "Err: " & @error & " " & "Ext: " & @extended & @CRLF) Sleep(1500) $RetValue = _WinAnimate($hwnd, $AW_SLIDE_OUT_RIGHT) ConsoleWrite($RetValue & " " & "Err: " & @error & " " & "Ext: " & @extended & @CRLF) Sleep(1500) $RetValue = _WinAnimate($hwnd, $AW_SLIDE_IN_TOP) ConsoleWrite($RetValue & " " & "Err: " & @error & " " & "Ext: " & @extended & @CRLF) Sleep(1500) $RetValue = _WinAnimate($hwnd, $AW_SLIDE_OUT_TOP) ConsoleWrite($RetValue & " " & "Err: " & @error & " " & "Ext: " & @extended & @CRLF) Sleep(1500) $RetValue = _WinAnimate($hwnd, $AW_SLIDE_IN_BOTTOM) ConsoleWrite($RetValue & " " & "Err: " & @error & " " & "Ext: " & @extended & @CRLF) Sleep(1500) $RetValue = _WinAnimate($hwnd, $AW_SLIDE_OUT_BOTTOM) ConsoleWrite($RetValue & " " & "Err: " & @error & " " & "Ext: " & @extended & @CRLF) Sleep(1500) $RetValue = _WinAnimate($hwnd, $AW_DIAG_SLIDE_IN_TOPLEFT) ConsoleWrite($RetValue & " " & "Err: " & @error & " " & "Ext: " & @extended & @CRLF) Sleep(1500) $RetValue = _WinAnimate($hwnd, $AW_DIAG_SLIDE_OUT_TOPLEFT) ConsoleWrite($RetValue & " " & "Err: " & @error & " " & "Ext: " & @extended & @CRLF) Sleep(1500) $RetValue = _WinAnimate($hwnd, $AW_DIAG_SLIDE_IN_TOPRIGHT) ConsoleWrite($RetValue & " " & "Err: " & @error & " " & "Ext: " & @extended & @CRLF) Sleep(1500) $RetValue = _WinAnimate($hwnd, $AW_DIAG_SLIDE_OUT_TOPRIGHT) ConsoleWrite($RetValue & " " & "Err: " & @error & " " & "Ext: " & @extended & @CRLF) Sleep(1500) $RetValue = _WinAnimate($hwnd, $AW_DIAG_SLIDE_IN_BOTTOMLEFT) ConsoleWrite($RetValue & " " & "Err: " & @error & " " & "Ext: " & @extended & @CRLF) Sleep(1500) $RetValue = _WinAnimate($hwnd, $AW_DIAG_SLIDE_OUT_BOTTOMLEFT) ConsoleWrite($RetValue & " " & "Err: " & @error & " " & "Ext: " & @extended & @CRLF) Sleep(1500) $RetValue = _WinAnimate($hwnd, $AW_DIAG_SLIDE_IN_BOTTOMRIGHT) ConsoleWrite($RetValue & " " & "Err: " & @error & " " & "Ext: " & @extended & @CRLF) Sleep(1500) $RetValue = _WinAnimate($hwnd, $AW_DIAG_SLIDE_OUT_BOTTOMRIGHT) ConsoleWrite($RetValue & " " & "Err: " & @error & " " & "Ext: " & @extended & @CRLF) ExitHave fun! M231 point -
How to make Toast - New version 2 Aug 18
MONaH-Rasta reacted to Melba23 for a topic
Hannes123, I cannot see how to easily modify the existing Toast UDF to do what you want - it would require passing details of the required controls to the UDF to then create these controls on the Toast and to look for their activation within the existing internal GUIGetMsg loop. I can clearly see how it might be done using an array to pass the required data, but I am not prepared to get into such a massive rewrite for what I see as a very specific requirement. However, you can do what I think you require by careful coding within your existing script: #include "Toast.au3" Opt("GUIOnEventMode", 1) HotKeySet("{ESC}", "On_Exit") Global $sMsg, $hProgress, $aRet[2] Global $fClicked = False _Show_Toast() While 1 Sleep(10) WEnd Func _Show_Toast() $sMsg = " " & @CRLF & " " & @CRLF & " " & @CRLF & " " & @CRLF & " " & @CRLF & " " & @CRLF _Toast_Set(Default) ; Show the Toast $aRet = _Toast_Show(0, "Button", $sMsg, 0) ; No delay ; Show the button $hButton = GUICtrlCreateButton("Test", 10, 50, 80, 30) GUICtrlSetOnEvent(-1, "_Clicked") ; Simulate a closure button $hX_Button = GUICtrlCreateButton("X", $aRet[1] - 17, 17, 20, 20) GUICtrlSetOnEvent(-1, "_X_Clicked") ; Start a timer $iBegin = TimerInit() ; Now wait for a preset time or until a button is pressed Do Sleep(10) Until TimerDiff($iBegin) > 20000 Or $fClicked = True ; Reset the flag $fClicked = False _Toast_Hide() EndFunc Func _Clicked() ; Do what you want MsgBox(0, "Clicked", "Button was clicked") ; Set the flag $fClicked = True EndFunc Func _X_Clicked() ; Set the flag $fClicked = True EndFunc Func On_Exit() Exit EndFuncYou create a simulated closure X button to replace the UDF version - this cannot be displayed as I explained above because it pauses the script and the other controls will not appear until the delay is over, at which point the Toast retracts anyway. Unfortunately you cannot place it on the Toast title bar as this would mean overlapping controls and the button not working - and before you ask, the title needs to be enabled or the colours do not display correctly. Is that any help? If not then you are looking at developing your own version of the UDF with the additional parameter(s) necessary to get the additional controls to display and then function within its internal GUIGetMsg loop. If you do decide to go that way, then by all means use the existing UDF as a starting point and I will be more than happy to offer advice if you run into difficulties. M231 point