-
Posts
7,092 -
Joined
-
Days Won
156
Content Type
Forums
Downloads
Forum Articles
Events
Everything posted by Nine
-
In this thread it was discussed about fading out a label from dark to white. So I suggested to use an ownerdraw label to perform such a task. After a bit of searching, I did not find good example, on this forum, of doing it with a label. So there you go : ; From Nine #include <WinAPIDiag.au3> #include <GDIPlus.au3> #include <GUIConstants.au3> ; Blend - Fade - Text - OWNERDRAW - label Opt("MustDeclareVars", True) Global Const $tagDRAWITEMSTRUCT = "uint CtlType;uint CtlID;uint itemID;uint itemAction;uint itemState;hwnd hwndItem;hwnd hDC;" & $tagRECT & ";ulong_ptr itemData;" Global Const $SS_OWNERDRAW = 0x0D Example() Func Example() _GDIPlus_Startup() Local $hGUI = GUICreate("Example", 400, 200, -1, -1, $WS_OVERLAPPEDWINDOW) GUISetBkColor(0xFFFF00) Local $idLabel = GUICtrlCreateLabel("", 75, 20, 250, 40, $SS_OWNERDRAW) GUIRegisterMsg($WM_DRAWITEM, WM_DRAWITEM) GUISetState() While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idLabel ConsoleWrite("Label was clicked" & @CRLF) EndSwitch WEnd _GDIPlus_Shutdown() EndFunc ;==>Example Func WM_DRAWITEM($hWnd, $iMsg, $wParam, $lParam) Local $tData = DllStructCreate($tagDRAWITEMSTRUCT, $lParam) Local $hGraphic = _GDIPlus_GraphicsCreateFromHDC($tData.hdc) Local $hBrush = _GDIPlus_LineBrushCreate(0, 20, $tData.right, 20, 0xFF606060, 0xFFFFFFFF) Local $hFormat = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($hFormat, 1) Local $hFamily = _GDIPlus_FontFamilyCreate("Arial") Local $hFont = _GDIPlus_FontCreate($hFamily, 28, 2) Local $tLayout = _GDIPlus_RectFCreate(0, Int(($tData.bottom - 40) / 2), $tData.right, 40) Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, "AutoIt Rulez !", $hFont, $tLayout, $hFormat) _GDIPlus_GraphicsClear($hGraphic, 0xFFFF0000) _GDIPlus_GraphicsDrawStringEx($hGraphic, "AutoIt Rulez !", $hFont, $aInfo[0], $hFormat, $hBrush) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_FontDispose($hFont) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphic) Return $GUI_RUNDEFMSG EndFunc ;==>WM_DRAWITEM
-
Just remove that line : $sOut = StringRegExpReplace($sOut, '^"(.*?)"$', "$1") ; double-quotes
-
#include <GUIConstants.au3> #include <GuiTreeView.au3> #include <GuiImageList.au3> GUICreate("Icon Test", 300, 300) Local $idTreeView = GUICtrlCreateTreeView(10, 10, 280, 280) GUISetState() Local $hImageList = _GUIImageList_Create(16, 16, 5, 3) Local $idxFolder = _GUIImageList_AddIcon($hImageList, "shell32.dll", 4) Local $idxApp = _GUIImageList_AddIcon($hImageList, "shell32.dll", 2) _GUICtrlTreeView_SetNormalImageList(GUICtrlGetHandle($idTreeView), $hImageList) Local $h1 = _GUICtrlTreeView_Add($idTreeView, 0, "Category", $idxFolder) _GUICtrlTreeView_AddChild($idTreeView, $h1, "App", $idxApp) While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop WEnd Win10.
-
label with gradually fading text - how?
Nine replied to orbs's topic in AutoIt General Help and Support
sorry to say but WM_SIZE is not even registered -
oh you mean that only 2 double-quotes should result in single double-quotes ? That is quite easy to modify, try it, and come back if can't find a solution.
-
label with gradually fading text - how?
Nine replied to orbs's topic in AutoIt General Help and Support
Like I already told you, the more you ask, the more complex the code is becoming. It is totally normal that the graphic disappears. In this case you would need to define the label as $SS_OWNERDRAW. Then move the graphic creation of the label in DRAWITEM window proc. Try it, let me know if you need more help. To set background color (previously stated) of the label, you could use _GDIPlus_GraphicsClear($hGraphic, 0xFFFF0000) -
Here my take on it : ; From Nine #include <Constants.au3> Local $sText = IniReadEx("Test.ini", "Section", "cle1", Null) ConsoleWrite("[" & $sText & "]" & @CRLF) $sText = IniReadEx("Test.ini", "Section", "cle2") ConsoleWrite("[" & $sText & "]" & @CRLF) $sText = IniReadEx("Test.ini", "Section", "heure") ConsoleWrite("[" & $sText & "]" & @CRLF) $sText = IniReadEx("Test.ini", "Section", "boot") ConsoleWrite("[" & $sText & "]" & @CRLF) $sText = IniReadEx("Test.ini", "Section", "Log") ConsoleWrite("[" & $sText & "]" & @CRLF) $sText = IniReadEx("Test.ini", "Section", "New", "$disk$\%username%\@scriptname@") ConsoleWrite("[" & $sText & "]" & @CRLF) Func IniReadEx($sFileName, $sSection, $sKey, $sDefault = Null) Local $sOut = IniRead($sFileName, $sSection, $sKey, $sDefault) If $sOut == $sDefault Then IniWrite($sFileName, $sSection, $sKey, $sDefault) $sOut = StringRegExpReplace($sOut, "\h*;.*", "") ; comment $sOut = StringRegExpReplace($sOut, '^"(.*?)"$', "$1") ; double-quotes Local $aText = StringRegExp($sOut, '@\w+?@', $STR_REGEXPARRAYGLOBALMATCH) ; autoit macro If Not @error Then For $sMacro In $aText $sOut = StringReplace($sOut, $sMacro, Execute(StringTrimRight($sMacro, 1))) Next EndIf $aText = StringRegExp($sOut, '\$\w+?\$', $STR_REGEXPARRAYGLOBALMATCH) ; other key If Not @error Then For $sSecKey In $aText $sOut = StringReplace($sOut, $sSecKey, IniReadEx($sFileName, $sSection, StringReplace($sSecKey, "$", ""))) Next EndIf $aText = StringRegExp($sOut, "%\w+?%", $STR_REGEXPARRAYGLOBALMATCH) ; environment If Not @error Then For $sEnv In $aText $sOut = StringReplace($sOut, $sEnv, EnvGet(StringReplace($sEnv, "%", ""))) Next EndIf Return $sOut EndFunc ;==>IniReadEx With this ini file : [Section] cle1=test1 ; comment cle2="Test2" ; comment with tab heure=@HOUR@:@MIN@:@SEC@ disk=W: boot=$disk$\test\boot\@username@ Log=%ProgramData%\AutoIt\@username@\log ; plus a comment
-
The guy didn't find the time to read the replies of his thread. Hope is not a method, but it sure is a base of resilience...
-
It is kind of strange that your company is asking someone to perform a task that he has absolutely no idea where to start to. Makes me wonder if your superior is so incompetent that he did not realize he was giving you a job that you could not even described correctly.
-
The only use for "text" argument that truly matters is when you have 2 windows with identical titles and you want to distinguish between them based on its content. Take the following example, I don't have to use the "text" parameter for all win* and control* functions until I have 2 windows with identical title. Then I can distinguish them by their content : Run("notepad") ; start first instance WinWaitActive("Sans titre") ; don't need to specify any text since there is only 1 window with that title ControlSend("Sans titre", "", "Edit1", "123") Run("notepad") ; start second instance WinWaitActive("Sans titre") ; again only 1 window with that title since first change title to add * (no need for text) ControlSend("Sans titre", "", "Edit1", "456") ControlSend("*Sans titre", "123", "", "^s") ; now we got 2 windows with identical titles -- need to specify text to refer to the right window WinWait("Enregistrer sous") ; no need for text as this is a unique window title ControlClick("Enregistrer sous", "", 2) ; id 2 = cancel Sorry my Notepad is in french ! ps. I always prefer using handle instead of title, there's a reduced chance of creating a bug with handle cause they are uniquely defined.
-
label with gradually fading text - how?
Nine replied to orbs's topic in AutoIt General Help and Support
Try this version : ; From Nine #include <WinAPIDiag.au3> #include <GDIPlus.au3> #include <GUIConstants.au3> ; Blend - Fade - Text Opt("MustDeclareVars", True) Example() Func Example() _GDIPlus_Startup() Local $hGUI = GUICreate("Example", 400, 400) GUISetBkColor(0xFFFF00) Local $idLabel = GUICtrlCreateLabel("", 75, 20, 250, 40) Local $hLabel = GUICtrlGetHandle($idLabel) GUISetState() Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hLabel) Local $hBrush = _GDIPlus_LineBrushCreate(0, 20, 250, 20, 0xFF606060, 0xFFFFFFFF) Local $hFormat = _GDIPlus_StringFormatCreate() Local $hFamily = _GDIPlus_FontFamilyCreate("Arial") Local $hFont = _GDIPlus_FontCreate($hFamily, 28, 2) Local $tLayout = _GDIPlus_RectFCreate(0, 0, 250, 40) Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, "AutoIt Rulez !", $hFont, $tLayout, $hFormat) ;_WinAPI_DisplayStruct($aInfo[0], $tagGDIPRECTF) _GDIPlus_GraphicsDrawStringEx($hGraphic, "AutoIt Rulez !", $hFont, $aInfo[0], $hFormat, $hBrush) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_RESTORE _GDIPlus_GraphicsDrawStringEx($hGraphic, "AutoIt Rulez !", $hFont, $aInfo[0], $hFormat, $hBrush) Case $idLabel ConsoleWrite("Label was clicked" & @CRLF) EndSwitch WEnd _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_FontDispose($hFont) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc ;==>Example -
label with gradually fading text - how?
Nine replied to orbs's topic in AutoIt General Help and Support
You will need to learn GDI+. The more you want the more complex it will become. Good luck. ps. you can use the hwnd of a label instead of the hwnd of the GUI. -
Ok it seems all the controls have the id of 1. Maybe you should try to loop until you get a valid handle of the control. You are currently looking at the activation of the window, but maybe the control is not available yet. Try this : $WindowTitle = "Npcap " & $Version & " Setup" $hWnd = WinGetHandle($WindowTitle) ConsoleWrite($hWnd & @CRLF) While Not ControlGetHandle($hWnd, "", "Button2") Sleep(100) WEnd ControlClick($hWnd, "", "Button2")
-
True. For all Control* functions it doesn't say it is optional. It is not optional in terms of skipping it. It is optional (check examples of Control* functions) in the sense that you must provide a string, but most of the time, it is going to be empty... However, it is clearly stated that the second parameter of many Win* functions is optional (meaning that you can skip it).
-
I believe you will need to rethink your design. You could add a suffix to your function name and use something like this to execute them : Call ("DoThis_" & $PC, $param1, $param2) Also in terms of maintainability, it should be easier to put all the functions into a single include as you do not have to open multiple files to make a modification...
-
Use my gif animation
-
label with gradually fading text - how?
Nine replied to orbs's topic in AutoIt General Help and Support
Yes it is just an example. I made it like that to simplify the code. To color the background, replace the line with yellow color : _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFF00) -
label with gradually fading text - how?
Nine replied to orbs's topic in AutoIt General Help and Support
Here one way : ; From Nine #include <GDIPlus.au3> #include <GUIConstants.au3> Opt("MustDeclareVars", True) Example() Func Example() _GDIPlus_Startup() Local $hGUI = GUICreate("Example", 400, 400) GUISetState() Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF) Local $hBrush = _GDIPlus_LineBrushCreate(50, 200, 320, 200, 0xFF000000, 0xFFFFFFFF) Local $hFormat = _GDIPlus_StringFormatCreate() Local $hFamily = _GDIPlus_FontFamilyCreate("Arial") Local $hFont = _GDIPlus_FontCreate($hFamily, 28, 2) Local $tLayout = _GDIPlus_RectFCreate(80, 100, 320, 40) Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, "AutoIt Rulez !", $hFont, $tLayout, $hFormat) _GDIPlus_GraphicsDrawStringEx($hGraphic, "AutoIt Rulez !", $hFont, $aInfo[0], $hFormat, $hBrush) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_FontDispose($hFont) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc ;==>Example