Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/17/2021 in all areas

  1. Probably misunderstood you. I thought you were saying that writing batch files evades source control because it “gets them out”. But now I think you’re saying it “checks them out” of SC. Sorry ‘bout that! The hairs went down anyway, on their own
    2 points
  2. Been software packager for a number of years and in my experience when you come across software with no switches, we just repackage the software completely, we install the software, identify the changes on the system (registry, files/folders) and then use something like InnoSetup (free) to recreate the installer, this gives us the benefit of installing/uninstalling silently. Software like InstallShield can also do this for you however it's expensive (we pay approx $20k per license), but this allows us to repackage software as an msi, although we only do this if an exe doesn't have silent switches. The issue with functions like ControlClick, ControlSend etc... is that users can break the install easily. Just my 2 cents.
    2 points
  3. Nine

    Date Range Picker

    In this thread, it was asked if there was a Date Range Picker somewhere. Couldn't find one. With @Zedna calendar with @maniootek proposal, I felt it could be fun to create one. So here it is. Like always, if you have some suggestions, I am open to any. Version 2022-04-10 *Window drag can now be performed anywhere with the background of the GUI (non-control space) * Clicking on the month label, select the whole month Version 2020-12-05 * Standardized presentation of month calendar where column 1 is Sunday and column 7 is Saturday. Version 2020-11-04 * Dates selection using Shift-Click inside a single month or between months * Auto-multi lingual Hope you like it. Date Range Picker.au3
    1 point
  4. DLLCalls using VBScripts Out if the box it is not possible to do DllCalls from VBScripts. But thanks to the +20 year COM Library called DynaWrap this is still possible Anyhow the process of calling Win API functions need some basic knowledge and understanding on how to do this. More specifically the input Data Types parameters used and Calling Formats are key here, as well as the Return Data Types DynaWrap COM Library Keep in mind that this COM Library is a 32Bit only library. Which means that you need to register is using the SysWOW64 regsvr32 But to overcome this annoyance I created RegFree method so you can start using it as a portable COM Library DynaWrap Documentation I created a PDF documention on what I still could find on the internet on how to use the COM Library. Examples The second post will hold some VBScript Examples and an AutoIt Example Attached You will find the PDF and the ZIP File needed to run your code in a portable way. Thanks to the @Professor_Bernd to provide the VBScript code to get the VBScript scripting directory and the Shortcut to run the 32Bit SysWOW64 VBScript host Just drop the VBScript on the 32Bit Shortcut to get going. Source Code Anyhow here you can find the source code of the DynaWrap 32Bit Library. If someone has the C++ Tools to convert it to 64Bit Library that would give a new live to it... http://www.borncity.com/web/WSHBazaar1/WSHDynaCall.htm Interesting reading : https://www.drdobbs.com/windows/an-automation-object-for-dynamic-dll-cal/210200078 DynaCall.zip How to use DllCalls in VBScript using DynaWrap COM Object.pdf
    1 point
  5. How far a cry is it exactly? Consider someone reading this excerpt from a published article from an outside source: What kind of impression would one get after reading that? Certainly formatting a drive is part of configuring a PC. Furthermore, autoit has many examples of people using it to format drives, this one for instance:
    1 point
  6. http://blogs.msdn.com/gstemp/archive/2004/08/11/213028.aspx Optional: specifies whether to return files folders or both $iFlag=0(Default) Return both files and folders $iFlag=1 Return files only $iFlag=2 Return Folders only Autoit_Tree_FileFind.AU3 #Include <Array.au3> Global $FileFind_Array[2] ;TTree_FileFind($szPath = "",$iFlag = 0 ,$extension = "") ;Optional: specifies whether to return files folders or both ;$iFlag=0(Default) Return both files and folders ;$iFlag=1 Return files only ;$iFlag=2 Return Folders only $TIMINT = TimerInit() $TREE_FileFind = Tree_FileFind( "C:\" , 2 , "") ; $iFlag = 0 In C:\ Searching for folders and files takes a long time $milliseconds = TimerDiff($TIMINT) _ArrayDisplay($TREE_FileFind, "Tree_FileFind Return Folders only") MsgBox(0,"Tree_FileFind","AUTOIT ==> milliseconds ==> " & $milliseconds ) $TIMINT = TimerInit() $TREE_FileFind = Tree_FileFind( @ProgramFilesDir , 1 , "exe") $milliseconds = TimerDiff($TIMINT) _ArrayDisplay($TREE_FileFind, "Tree_FileFind Return exe files only") MsgBox(0,"Tree_FileFind","AUTOIT ==> milliseconds ==> " & $milliseconds ) $TIMINT = TimerInit() $TREE_FileFind = Tree_FileFind(@MyDocumentsDir , 0 , "") $milliseconds = TimerDiff($TIMINT) _ArrayDisplay($TREE_FileFind, "Tree_FileFind Return both files and folders") MsgBox(0,"Tree_FileFind","AUTOIT ==> milliseconds ==> " & $milliseconds ) ;Tree_FileFind($szPath = "",$iFlag = 0 ,$extension = "") ;Optional: specifies whether to return files folders or both ;$iFlag=0(Default) Return both files and folders ;$iFlag=1 Return files only ;$iFlag=2 Return Folders only Func Tree_FileFind( $szPath = "" , $iFlag = 0 , $extension = "" ) Local $TREE_Array[1] , $Dirs_Array[1] $Dirs_Array[0] = 0 $TREE_Array[0] = 0 $FileFind_Array[0] = $Dirs_Array $FileFind_Array[1] = $TREE_Array If FileExists($szPath) = 0 Then Return $FileFind_Array[1] $extension = StringUpper($extension) $extensionLen = StringLen($extension) $szPath = StringReplace($szPath , "\\" , "\" ) If StringRight($szPath,1) == "\" Then $szPath = StringTrimRight($szPath,1) $IsRoot = StringLen($szPath) < 3 $Return = FileFind($szPath,$iFlag,$extension,$extensionLen,$IsRoot) IF $Return Then $Dirs_Array = $FileFind_Array[0] $TREE_Array = $FileFind_Array[1] For $i = 1 To $Dirs_Array[0] LoopTree_FileFind($Dirs_Array[$i],$iFlag,$extension,$extensionLen) Next EndIf Return $FileFind_Array[1] EndFunc Func FileFind($szPath,$iFlag,$extension,$extensionLen,$IsRoot = 0) $Dirs_Array = $FileFind_Array[0] $TREE_Array = $FileFind_Array[1] $Dirs_Array[0] = 0 $sFilter = "*.*" if $iFlag = 2 Then $sFilter = "*." if $IsRoot Then FileChangeDir($szPath & "\") Else FileChangeDir($szPath) EndIf $search = FileFindFirstFile($sFilter) If $search = -1 Then Return False While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $file = $szPath & "\" & $file Select Case StringInStr(FileGetAttrib($file),"D") IF $iFlag <> 1 Then ReDim $TREE_Array[$TREE_Array[0] + 2] $TREE_Array[$TREE_Array[0] + 1] = $file $TREE_Array[0] += 1 EndIf If StringInStr(FileGetAttrib($file), "S") Then ContinueLoop ;System folders when searching in them, errors and freezes occur, so ;they are excluded from the search. This happens on some Windows systems if (UBound($Dirs_Array) < $Dirs_Array[0] + 2) Then _ ReDim $Dirs_Array[$Dirs_Array[0] + 2] $Dirs_Array[$Dirs_Array[0] + 1] = $file $Dirs_Array[0] += 1 Case StringInStr(FileGetAttrib($file),"D") = 0 if $iFlag = 2 Then ContinueLoop Select Case $extensionLen If (StringUpper(StringRight($file,$extensionLen)) == $extension) = 0 Then ContinueLoop ReDim $TREE_Array[$TREE_Array[0] + 2] $TREE_Array[$TREE_Array[0] + 1] = $file $TREE_Array[0] += 1 Case $extensionLen = 0 ReDim $TREE_Array[$TREE_Array[0] + 2] $TREE_Array[$TREE_Array[0] + 1] = $file $TREE_Array[0] += 1 EndSelect EndSelect WEnd FileClose($search) FileChangeDir(@SCriptDir) $FileFind_Array[0] = $Dirs_Array $FileFind_Array[1] = $TREE_Array Return True EndFunc Func LoopTree_FileFind($szPath,$iFlag,$extension,$extensionLen) $Return = FileFind($szPath,$iFlag,$extension,$extensionLen) IF $Return Then $Dirs_Array = $FileFind_Array[0] For $i = 1 To $Dirs_Array[0] LoopTree_FileFind($Dirs_Array[$i],$iFlag,$extension,$extensionLen) Next EndIf Return $FileFind_Array[1] EndFunc
    1 point
  7. @therks I understood what you mean. I should have something that could help you, but now it's late and I need to sleep, so I'm gonna help you tomorrow
    1 point
  8. WinMove($myWindow, "", -10000, -10000) Can you still see $myWindow?
    1 point
  9. If I were an admin the hairs on my neck would be sticking straight up after reading that. OTOH, as a developer I can only say: Right On!
    1 point
  10. Probably because child windows created with $WS_EX_MDICHILD or $WS_CHILD don't behave the same way at all. The script below corresponds to your initial script, plus 2 label controls added (1 in each Tab control) #include <GUIConstantsEx.au3> #include "GUIScrollbars_Ex.au3" Dim $tabWindows[2] $hGui = GUICreate("Scrollable tabs", 640, 480, -1, -1, _ $WS_CLIPCHILDREN + $WS_MINIMIZEBOX + $WS_CAPTION + $WS_POPUP + $WS_SYSMENU) GUICtrlCreateLabel("Label on main gui", 5, 5, Default, 20) $tabs = GUICtrlCreateTab(5, 25, 630, 450) GUICtrlCreateTabItem("Tab 1") GUICtrlCreateLabel("Label in Tab1", 100, 100) GUICtrlCreateTabItem("Tab 2") GUICtrlCreateLabel("Label in Tab2", 150, 150) GUICtrlCreateTabItem("") ; end tabitem definition $pos = ControlGetPos($hGui, "", $tabs) $tabWindows[0] = GUICreate("test", $pos[2] - 10, $pos[3] - 30, 7, 50, $WS_POPUP, $WS_EX_MDICHILD, $hGui) ; $tabWindows[0] = GUICreate("test", $pos[2] - 10, $pos[3] - 30, 7, 50, $WS_CHILD, -1, $hGUI) GUISetBkColor(0xffffff) GUICtrlCreateLabel("Label in Child1",10,10) $tabWindows[1] = GUICreate("test", $pos[2] - 10, $pos[3] - 30, 7, 50, $WS_POPUP, $WS_EX_MDICHILD, $hGui) ; $tabWindows[1] = GUICreate("test", $pos[2] - 10, $pos[3] - 30, 7, 50, $WS_CHILD, -1, $hGUI) GUISetBkColor(0xffffff) GUICtrlCreateLabel("Label in Child2", 10, 50) GUICtrlSetTip(-1, "Label hint") GUISetState(@SW_SHOW, $hGui) _GUIScrollbars_Generate($tabWindows[1], 500, 1000) ; This is the current active tab $iLastTab = GUICtrlRead($tabs) GUISetState(@SW_SHOW, $tabWindows[$iLastTab]) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $tabs $currentTab = GUICtrlRead($tabs) If $currentTab <> $iLastTab Then GUISetState(@SW_HIDE, $tabWindows[$iLastTab]) GUISetState(@SW_SHOW, $tabWindows[$currentTab]) $iLastTab = $currentTab ; EndIf EndSwitch WEnd 1) When you run the script like this : $tabWindows[0] = GUICreate("test", $pos[2] - 10, $pos[3] - 30, 7, 50, $WS_POPUP, $WS_EX_MDICHILD, $hGui) ; $tabWindows[0] = GUICreate("test", $pos[2] - 10, $pos[3] - 30, 7, 50, $WS_CHILD, -1, $hGUI) ... $tabWindows[1] = GUICreate("test", $pos[2] - 10, $pos[3] - 30, 7, 50, $WS_POPUP, $WS_EX_MDICHILD, $hGui) ; $tabWindows[1] = GUICreate("test", $pos[2] - 10, $pos[3] - 30, 7, 50, $WS_CHILD, -1, $hGUI) Then the labels displayed are the Child windows labels and the scrollbar is visible in Tab2, which means that the child windows created with $WS_EX_MDICHILD are in the foreground. Unfortunately they grab focus from parent and you don't want this behavior in your 1st post. 2) When you run the script like that : ; $tabWindows[0] = GUICreate("test", $pos[2] - 10, $pos[3] - 30, 7, 50, $WS_POPUP, $WS_EX_MDICHILD, $hGui) $tabWindows[0] = GUICreate("test", $pos[2] - 10, $pos[3] - 30, 7, 50, $WS_CHILD, -1, $hGUI) ... ; $tabWindows[1] = GUICreate("test", $pos[2] - 10, $pos[3] - 30, 7, 50, $WS_POPUP, $WS_EX_MDICHILD, $hGui) $tabWindows[1] = GUICreate("test", $pos[2] - 10, $pos[3] - 30, 7, 50, $WS_CHILD, -1, $hGUI) Then the labels displayed are the Tab labels and the scrollbar is not visible in Tab2, which means that the child windows created with $WS_CHILD are in the background, covered by the Parent Tab control. This gave me the idea to create a Tab control having width = 0 and height = 0, so there will be no overlapping at all between the Tab control and the $WS_CHILD windows. Gladly it worked fine and the "grab focus" issue was solved too. This is because you use a constant (50) for the Y position of the Child Windows, while I use the variable $iHtabs (Tab control height) to calculate precisely the Y position of the Child windows, so they won't overlap the Tab control : $pos = ControlGetPos($hGui, "", $tabs) Local $iHtabs = $pos[3] $tabWindows[0] = GUICreate("test", 600, 400, $iXtabs +2, $iYtabs + $iHtabs +1, $WS_CHILD, -1 , $hGUI)
    1 point
  11. Hi E1M1 I got a result which looks promising, based on pure Child windows (the ones created with $WS_CHILD style) As you noticed, the other kind of Child windows (the ones created with $WS_EX_MDICHILD extended style) grab focus when you click on controls they contain, which seems a normal behavior as they are totally separate windows. Here is a reworked version of your script. There's a hidden button when you scroll down in Tab2 : #include <GUIConstantsEx.au3> #include "GUIScrollbars_Ex.au3" Dim $tabWindows[2] $hGui = GUICreate("Scrollable tabs", 640, 480, -1, -1, _ $WS_CLIPCHILDREN + $WS_MINIMIZEBOX + $WS_CAPTION + $WS_POPUP + $WS_SYSMENU) GUICtrlCreateLabel("Label on main gui", 5, 5, Default, 20) Local $iXtabs = 5, $iYtabs = 25 $tabs = GUICtrlCreateTab($iXtabs, $iYtabs, 0 ,0) GUICtrlCreateTabItem("Tab 1") GUICtrlCreateTabItem("Tab 2") GUICtrlCreateTabItem("") ; end tabitem definition $pos = ControlGetPos($hGui, "", $tabs) Local $iHtabs = $pos[3] $tabWindows[0] = GUICreate("test", 600, 400, $iXtabs +2, $iYtabs + $iHtabs +1, $WS_CHILD, -1 , $hGUI) GUISetBkColor(0xffffff) GUICtrlCreateLabel("Hello World!", 10, 10) $tabWindows[1] = GUICreate("test", 600, 400, $iXtabs +2, $iYtabs + $iHtabs +1, $WS_CHILD, -1 , $hGUI) GUISetBkColor(0xffffff) GUICtrlCreateLabel("Label", 10, 10, 30, 25) GUICtrlSetTip(-1, "Label hint") $idButton = GUICtrlCreateButton("Hidden", 290, 650, 80, 30) _GUIScrollbars_Generate($tabWindows[1], 800, 1000) GUISetState(@SW_SHOW, $hGui) ; This is the current active tab $iLastTab = GUICtrlRead($tabs) GUISetState(@SW_SHOW, $tabWindows[$iLastTab]) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $tabs $currentTab = GUICtrlRead($tabs) If $currentTab <> $iLastTab Then GUISetState(@SW_HIDE, $tabWindows[$iLastTab]) GUISetState(@SW_SHOW, $tabWindows[$currentTab]) $iLastTab = $currentTab EndIf Case $idButton MsgBox($MB_TOPMOST, "Hidden Button", "Pressed") EndSwitch WEnd To make it convenient for our readers, I attach below Melba23's original UDF named GUIScrollbars_Ex.au3 (original dated 05/13/2018) as found in his thread. GUIScrollbars_Ex.au3
    1 point
  12. zackrspv

    IECreate2

    The _IE*() UDF is awesome, dont get me wrong, I adore them, and use them every day lol. But, sometimes, with some sites, some content, some items, it is not possible to actually use an embedded IE to accomplish the mission that you want. For example, creating dynamic IFrames and DIV's within IFRAMES, or accessing local sites through a connected local DNS VPN (it's rather complex lol). So, i needed a way to get around that. It's great that IE has a -k function (-k = kiosk mode). Using this method, you can actually create a method for usage. Here's an example #Include <WindowsConstants.au3> #include <WinAPI.au3> #Include <Constants.au3> local $pid, $hHandle, $hGUI, $sURL, $xHeight, $xWidth $sURL = "www.google.com" $xWidth = 1024 $xHeight = 768 $hGUI = GUICreate("Test", $xWidth, $xHeight) _IECreate2($xWidth, $xHeight, $hGUI) func _IECreate2($xWidth, $xHeight, $hGUI) $pid = Run(@ProgramFilesDir&"\internet explorer\iexplore.exe -k "&$sURL, "", @SW_HIDE) Sleep(2000) $hHandle = _ProcessGetHWnd($pid) GUISetState(@SW_SHOW, $hGUI) _WinAPI_SetParent($hHandle, $hGUI) _WinAPI_MoveWindow($hHandle, 0, 0, 1024, 768, True) _WinAPI_SetWindowLong($hHandle, $GWL_STYLE, $WS_POPUP+$WS_VISIBLE) Send("{F5}") EndFunc Func _ProcessGetHWnd($iPid, $iOption = 1, $sTitle = "", $iTimeout = 2000) Local $aReturn[1][1] = [[0]], $aWin, $hTimer = TimerInit() While 1 $aWin = WinList($sTitle) For $i = 1 To $aWin[0][0] If $iPid = WinGetProcess($aWin[$i][1]) Then If $iOption = 1 OR ($iOption = 0 And $aWin[$i][0] <> "") Then Return $aWin[$i][1] ElseIf $iOption = 2 Then ReDim $aReturn[UBound($aReturn) + 1][2] $aReturn[0][0] += 1 $aReturn[$aReturn[0][0]][0] = $aWin[$i][0] $aReturn[$aReturn[0][0]][1] = $aWin[$i][1] EndIf EndIf Next If $iOption = 2 And $aReturn[0][0] > 0 Then Return $aReturn If TimerDiff($hTimer) > $iTimeout Then ExitLoop Sleep(Opt("WinWaitDelay")) WEnd SetError(1) Return 0 EndFunc ;==>_ProcessGetHWnd Do Sleep(200) Until GUIGetMsg() = -3 ProcessClose($pid) You can replace the SEND() function with some _IE*() commands to attach to the embeded IE control and initiate a redraw/repait/refresh, but the SEND is quicker, imho. What it does: * Creates a full IE instance * Embeds the IE instance to a GUI window * Stops flickering on display by not showing the GUI window until the the IE is created. Hope it's of use >_< Just thought i'd post.
    1 point
  13. UEZ

    Image in traytip?

    Here another way to create a fake traytip with option to display an image within. This is an alpha version and just a proof of concept (needs still a lot of work)! ;coded by UEZ build 2013-05-13 alpha version #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GDIPlus.au3> #include <StaticConstants.au3> _GDIPlus_Startup() Global $sText = "This is a fake traytip" & @CRLF & _ "created with GDI+ :-)" & @CRLF & @CRLF & _ "Coded by UEZ 2013" Global $hImage = _GDIPlus_ImageLoadFromFile("c:\Program Files (x86)\AutoIt3\Examples\GUI\Merlin.gif") _GDIPlus_CreateTrayTip($sText, "Information", $hImage) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() Func _GDIPlus_CreateTrayTip($sText, $sHeader, $hImage = 0, $sFont = "Arial", $fFontSize = 14, $iFontColor = 0xFF000000) Local $iBGColor = 0xFFFFFFFF Local $hPath = DllCall($ghGDIPDll, "uint", "GdipCreatePath", "int", 0, "int*", 0) $hPath = $hPath[2] Local $hFamily = _GDIPlus_FontFamilyCreate($sFont) Local $tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0) ;measure text size DllCall($ghGDIPDll, "uint", "GdipAddPathString", "handle", $hPath, "wstr", $sHeader, "int", -1, "handle", $hFamily, "int", 0, "float", $fFontSize + 4, "struct*", $tLayout, "handle", 0) DllStructSetData($tLayout, "Y", $fFontSize * 2) DllCall($ghGDIPDll, "uint", "GdipAddPathString", "handle", $hPath, "wstr", $sText, "int", -1, "handle", $hFamily, "int", 0, "float", $fFontSize, "struct*", $tLayout, "handle", 0) Local $tRectF = DllStructCreate($tagGDIPRECTF) DllCall($ghGDIPDll, "uint", "GdipGetPathWorldBounds", "handle", $hPath, "struct*", $tRectF, "handle", 0, "handle", 0) ;create bitmap Local $iW = Floor(DllStructGetData($tRectF, 3)) + 90, $iH = Floor(DllStructGetData($tRectF, 4)) + $fFontSize + 15, $iPenSize = 1 Local $hBitmap = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iW + $iPenSize, "int", $iH + $iPenSize + 20, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0) $hBitmap = $hBitmap[6] Local $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hCtxt, 2) DllCall($ghGDIPDll, "uint", "GdipSetTextRenderingHint", "handle", $hCtxt, "int", 4) DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "handle", $hCtxt, "int", 7) DllCall($ghGDIPDll, "uint", "GdipResetPath", "handle", $hPath) Local $iWin = 1, $bVisible = False, $iPosX Local $iIconIndex = _SysTrayIconIndex(@AutoItPID, 2, $iWin) Local $aPosIcon = _SysTrayGetButtonInfo($iIconIndex, $iWin, 4) If $iIconIndex > -1 Then $bVisible = True $iPosX = $aPosIcon[0] $iPosWinX = $aPosIcon[0] $iPosWinY = $aPosIcon[1] Else Local $aTaskbar = WinGetPos("[CLASS:Shell_TrayWnd;INSTANCE:1]", "") $iPosWinX = @DesktopWidth - $iW - 30 $iPosWinY = $aTaskbar[1] EndIf ;draw ballon Local $iX = 0, $iY = 0, $iRadius = 20, $iDX, $iLimit DllCall($ghGDIPDll, "uint", "GdipAddPathArc", "handle", $hPath, "float", $iX + $iW - ($iRadius * 2), "float", $iY, "float", $iRadius * 2, "float", $iRadius * 2, "float", 270, "float", 90) DllCall($ghGDIPDll, "uint", "GdipAddPathArc", "handle", $hPath, "float", $iX + $iW - ($iRadius * 2), "float", $iY + $iH - ($iRadius * 2), "float", $iRadius * 2, "float", $iRadius * 2, "float", 0, "float", 90) If $bVisible > 0 Then $iDX = @DesktopWidth - ($iPosX + $iW + $iRadius + $iPenSize) If $iDX < 0 Then $iDX *= -1.15 If $iDX > ($iW - $iRadius * 3) Then $iDX = $iW - $iRadius * 3 If $iDX < $iRadius * 2 Then $iDX = 2 * $iRadius + 4 ElseIf $iDX > $iW / 2 Then $iDX = $iW / 2 EndIf DllCall($ghGDIPDll, "uint", "GdipAddPathLine", "handle", $hPath, "float", $iX + $iW - ($iRadius * 2), "float", $iY + $iH, "float", $iX + $iRadius + $iDX, "float", $iY + $iH) DllCall($ghGDIPDll, "uint", "GdipAddPathLine", "handle", $hPath, "float", $iX + $iRadius + $iDX, "float", $iY + $iH, "float", $iX + $iRadius + $iDX - 20, "float", $iY + $iH + 20) DllCall($ghGDIPDll, "uint", "GdipAddPathLine", "handle", $hPath, "float", $iX + $iRadius + $iDX - 20, "float", $iY + $iH + 20, "float", $iX + $iRadius + $iDX - 20, "float", $iY + $iH) EndIf DllCall($ghGDIPDll, "uint", "GdipAddPathArc", "handle", $hPath, "float", $iX, "float", $iY + $iH - ($iRadius * 2), "float", $iRadius * 2, "float", $iRadius * 2, "float", 90, "float", 90) DllCall($ghGDIPDll, "uint", "GdipAddPathArc", "handle", $hPath, "float", $iX, "float", $iY, "float", $iRadius * 2, "float", $iRadius * 2, "float", 180, "float", 90) DllCall($ghGDIPDll, "uint", "GdipClosePathFigure", "handle", $hPath) Local $hPen = _GDIPlus_PenCreate(0xFF000000, $iPenSize) DllCall($ghGDIPDll, "uint", "GdipDrawPath", "handle", $hCtxt, "handle", $hPen, "handle", $hPath) Local $hBrush = _GDIPlus_BrushCreateSolid($iBGColor) DllCall($ghGDIPDll, "uint", "GdipFillPath", "handle", $hCtxt, "handle", $hBrush, "handle", $hPath) DllCall($ghGDIPDll, "uint", "GdipResetPath", "handle", $hPath) ;draw text _GDIPlus_BrushSetSolidColor($hBrush, 0xFF0000FF) DllStructSetData($tLayout, "X", 60) DllStructSetData($tLayout, "Y", 10) DllCall($ghGDIPDll, "uint", "GdipAddPathString", "handle", $hPath, "wstr", $sHeader, "int", -1, "handle", $hFamily, "int", 0, "float", $fFontSize + 4, "struct*", $tLayout, "handle", 0) DllCall($ghGDIPDll, "uint", "GdipFillPath", "handle", $hCtxt, "handle", $hBrush, "handle", $hPath) DllCall($ghGDIPDll, "uint", "GdipResetPath", "handle", $hPath) _GDIPlus_BrushSetSolidColor($hBrush, $iFontColor) DllStructSetData($tLayout, "Y", $fFontSize * 2 + 10) DllCall($ghGDIPDll, "uint", "GdipAddPathString", "handle", $hPath, "wstr", $sText, "int", -1, "handle", $hFamily, "int", 0, "float", $fFontSize, "struct*", $tLayout, "handle", 0) DllCall($ghGDIPDll, "uint", "GdipFillPath", "handle", $hCtxt, "handle", $hBrush, "handle", $hPath) If $hImage Then _GDIPlus_GraphicsDrawImageRect($hCtxt, $hImage, $iRadius, $iRadius, 32, 32) DllCall($ghGDIPDll, "uint", "GdipDeletePath", "handle", $hPath) _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrush) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_GraphicsDispose($hCtxt) Local $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) $iW += $iPenSize $iH += $iPenSize + 20 ;create GUI Local $hGUI = GUICreate("", $iW, $iH, -1, -1, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOPMOST + $WS_EX_TOOLWINDOW), $iBGTColor = 0x010101 GUISetBkColor($iBGTColor) Local $iPic = GUICtrlCreatePic("", 0, 0, $iW, $iH) GUICtrlSetState(-1, $GUI_DISABLE) Local $iSizeBtn = 18 ;~ Local $iBtn = GUICtrlCreateButton("X", $iW - $iRadius - $iSizeBtn, $iRadius, $iSizeBtn, $iSizeBtn, BitOR($BS_CENTER,$BS_VCENTER,$BS_FLAT)) Local $iLabel = GUICtrlCreateLabel("X", $iW - $iSizeBtn - 4, $iSizeBtn, $iSizeBtn, $iSizeBtn, $SS_SIMPLE + $SS_CENTER) GUICtrlSetBkColor(-1, -2) Local $hB = GUICtrlSendMsg($iPic, 0x0172, 0, $hHBitmap) If $hB Then _WinAPI_DeleteObject($hB) _WinAPI_SetLayeredWindowAttributes($hGUI, $iBGTColor, 0x00) Local $aWin = WinGetPos($hGUI) WinMove($hGUI, "", $iPosWinX - ($iRadius + $iDX - 30), $iPosWinY - $iH + 20) GUISetState() For $i = 0 To 0xFF _WinAPI_SetLayeredWindowAttributes($hGUI, $iBGTColor, $i) Sleep(10) Next Local $iTimer = TimerInit(), $iTimerWait = 5 Do Switch GUIGetMsg() Case $iLabel, $GUI_EVENT_CLOSE ExitLoop EndSwitch If TimerDiff($iTimer) > $iTimerWait * 1000 Then ExitLoop Until False For $i = 0xFF To 0 Step - 2 _WinAPI_SetLayeredWindowAttributes($hGUI, $iBGTColor, $i) Sleep(10) Next GUIDelete($hGUI) _WinAPI_DeleteObject($hHBitmap) EndFunc #region interanl functions #region _Systray (Author: Tuape, Modified: Erik Pilsits -> build 5/13/2013) Func _SysTrayIconCount($iWin = 1) Local Const $TB_BUTTONCOUNT = 1048 Local $hWnd = _FindTrayToolbarWindow($iWin) If $hWnd = -1 Then Return -1 Local $count = DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $hWnd, "uint", $TB_BUTTONCOUNT, "wparam", 0, "lparam", 0) If @error Then Return -1 Return $count[0] EndFunc ;==>_SysTrayIconCount Func _SysTrayIconTitles($iWin = 1) Local $count = _SysTrayIconCount($iWin) If $count <= 0 Then Return -1 Local $titles[$count] For $i = 0 To $count - 1 $titles[$i] = WinGetTitle(_SysTrayIconHandle($i, $iWin)) Next Return $titles EndFunc ;==>_SysTrayIconTitles Func _SysTrayIconPids($iWin = 1) Local $count = _SysTrayIconCount($iWin) If $count <= 0 Then Return -1 Local $processes[$count] For $i = 0 To $count - 1 $processes[$i] = WinGetProcess(_SysTrayIconHandle($i, $iWin)) Next Return $processes EndFunc ;==>_SysTrayIconPids Func _SysTrayIconProcesses($iWin = 1) Local $pids = _SysTrayIconPids($iWin) If Not IsArray($pids) Then Return -1 Local $processes[UBound($pids)] Local $list = ProcessList() For $i = 0 To UBound($pids) - 1 For $j = 1 To $list[0][0] If $pids[$i] = $list[$j][1] Then $processes[$i] = $list[$j][0] ExitLoop EndIf Next Next Return $processes EndFunc ;==>_SysTrayIconProcesses Func _SysTrayIconIndex($test, $mode = 0, $iWin = 1) Local $ret = -1, $compare = -1 If $mode < 0 Or $mode > 2 Or Not IsInt($mode) Then Return -1 Switch $mode Case 0 $compare = _SysTrayIconProcesses($iWin) Case 1 $compare = _SysTrayIconTitles($iWin) Case 2 $compare = _SysTrayIconPids($iWin) EndSwitch If Not IsArray($compare) Then Return -1 For $i = 0 To UBound($compare) - 1 If $compare[$i] = $test Then $ret = $i ExitLoop EndIf Next Return $ret EndFunc ;==>_SysTrayIconIndex Func _SysTrayGetButtonInfo($iIndex, $iWin = 1, $iInfo = 1) Local Const $TB_GETBUTTON = 1047 Local Const $TB_GETITEMRECT = 1053 Local Const $ACCESS = BitOR(0x0008, 0x0010, 0x0400) Local $TBBUTTON If @OSArch = "X86" Then $TBBUTTON = DllStructCreate("int iBitmap;int idCommand;byte fsState;byte fsStyle;byte bReserved[2];dword dwData;int iString") Else $TBBUTTON = DllStructCreate("int iBitmap;int idCommand;byte fsState;byte fsStyle;byte bReserved[6];uint64 dwData;int64 iString") EndIf Local $TRAYDATA If @OSArch = "X86" Then $TRAYDATA = DllStructCreate("hwnd hwnd;uint uID;uint uCallbackMessage;dword Reserved[2];handle hIcon") Else $TRAYDATA = DllStructCreate("uint64 hwnd;uint uID;uint uCallbackMessage;dword Reserved[2];uint64 hIcon") EndIf Local $trayHwnd = _FindTrayToolbarWindow($iWin) If $trayHwnd = -1 Then Return SetError(1, 0, -1) Local $return, $err = 0 Local $ret = DllCall("user32.dll", "dword", "GetWindowThreadProcessId", "hwnd", $trayHwnd, "dword*", 0) If @error Or Not $ret[2] Then SetError(2, 0, -1) Local $pId = $ret[2] Local $procHandle = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $ACCESS, "bool", False, "dword", $pId) If @error Or Not $procHandle[0] Then Return SetError(3, 0, -1) Local $lpData = DllCall("kernel32.dll", "ptr", "VirtualAllocEx", "handle", $procHandle[0], "ptr", 0, "ulong", DllStructGetSize($TBBUTTON), "dword", 0x1000, "dword", 0x04) If Not @error And $lpData[0] Then $ret = DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $trayHwnd, "uint", $TB_GETBUTTON, "wparam", $iIndex, "lparam", $lpData[0]) If Not @error And $ret[0] Then DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", $procHandle[0], "ptr", $lpData[0], "struct*", $TBBUTTON, "ulong", DllStructGetSize($TBBUTTON), "ulong*", 0) Switch $iInfo Case 2 DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", $procHandle[0], "ptr", DllStructGetData($TBBUTTON, 6), "struct*", $TRAYDATA, "ulong", DllStructGetSize($TRAYDATA), "ulong*", 0) $return = $TRAYDATA Case 3 $return = "" If BitShift(DllStructGetData($TBBUTTON, 7), 16) <> 0 Then Local $intTip = DllStructCreate("wchar[1024]") DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", $procHandle[0], "ptr", DllStructGetData($TBBUTTON, 7), "struct*", $intTip, "ulong", DllStructGetSize($intTip), "ulong*", 0) $return = DllStructGetData($intTip, 1) EndIf Case 4 If Not BitAND(DllStructGetData($TBBUTTON, 3), 8) Then Local $pos[2], $RECT = DllStructCreate("int;int;int;int") DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $trayHwnd, "uint", $TB_GETITEMRECT, "wparam", $iIndex, "lparam", $lpData[0]) DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", $procHandle[0], "ptr", $lpData[0], "struct*", $RECT, "ulong", DllStructGetSize($RECT), "ulong*", 0) $ret = DllCall("user32.dll", "int", "MapWindowPoints", "hwnd", $trayHwnd, "ptr", 0, "struct*", $RECT, "uint", 2) $pos[0] = DllStructGetData($RECT, 1) $pos[1] = DllStructGetData($RECT, 2) $return = $pos Else $return = -1 EndIf Case Else $return = $TBBUTTON EndSwitch Else $err = 5 EndIf DllCall("kernel32.dll", "bool", "VirtualFreeEx", "handle", $procHandle[0], "ptr", $lpData[0], "ulong", 0, "dword", 0x8000) Else $err = 4 EndIf DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $procHandle[0]) If $err Then Return SetError($err, 0, -1) Else Return $return EndIf EndFunc ;==>_SysTrayGetButtonInfo Func _SysTrayIconHandle($iIndex, $iWin = 1) Local $TRAYDATA = _SysTrayGetButtonInfo($iIndex, $iWin, 2) If @error Then Return SetError(@error, 0, -1) Else Return Ptr(DllStructGetData($TRAYDATA, 1)) EndIf EndFunc ;==>_SysTrayIconHandle Func _FindTrayToolbarWindow($iWin = 1) Local $hWnd, $ret = -1 If $iWin = 1 Then $hWnd = DllCall("user32.dll", "hwnd", "FindWindow", "str", "Shell_TrayWnd", "ptr", 0) If @error Then Return -1 $hWnd = DllCall("user32.dll", "hwnd", "FindWindowEx", "hwnd", $hWnd[0], "hwnd", 0, "str", "TrayNotifyWnd", "ptr", 0) If @error Then Return -1 If @OSVersion <> "WIN_2000" Then $hWnd = DllCall("user32.dll", "hwnd", "FindWindowEx", "hwnd", $hWnd[0], "hwnd", 0, "str", "SysPager", "ptr", 0) If @error Then Return -1 EndIf $hWnd = DllCall("user32.dll", "hwnd", "FindWindowEx", "hwnd", $hWnd[0], "hwnd", 0, "str", "ToolbarWindow32", "ptr", 0) If @error Then Return -1 $ret = $hWnd[0] ElseIf $iWin = 2 Then $hWnd = DllCall("user32.dll", "hwnd", "FindWindow", "str", "NotifyIconOverflowWindow", "ptr", 0) If @error Then Return -1 $hWnd = DllCall("user32.dll", "hwnd", "FindWindowEx", "hwnd", $hWnd[0], "hwnd", 0, "str", "ToolbarWindow32", "ptr", 0) If @error Then Return -1 $ret = $hWnd[0] EndIf Return $ret EndFunc ;==>_FindTrayToolbarWindow #endregion _Systray #endregion Has anybody an idea how to get the position of the tray icon in the taskbar to position the fake traytip appropriately? Added _Systray UDF to get the tray icon position. Br, UEZ
    1 point
  14. _WinAPI_GetDlgCtrlID()
    1 point
×
×
  • Create New...