Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/14/2015 in all areas

  1. Wonderful attitude, I can tell you will go far...
    2 points
  2. qwert

    Simplest Gradient

    This was a bit of a puzzle for me, but with Yashied’s help, I figured it out. I’d been investigating the use of _WinAPI_GradientFill, but found the first couple of rungs of the ladder missing. By that, I mean that the explanations and examples I found were unclear about how to do the simplest gradient of all. It didn’t help that terms like “vertex” and “logical units” were involved. Anyone who had already worked with color fills obviously knew what they meant. I didn’t. So, here’s a modification of one of the very first examples from 2009. It produces a simple 200x600 linear gradient (from one color to another color), as well as the original 400x400 blended gradient (of multiple colors). Note the subtle differences in the DC processing, related to the use of _WinAPI_GetDC(), I believe. (BTW, if anyone sees a way for further simplification, please submit a working replacement example.) Also, I went ahead and made the original gradient frameless and draggable, but only as a way of showing some variety. #Include <GUIConstantsEx.au3> #include <GuiConstants.au3> #Include <WinAPIEx.au3> Global Const $STM_SETIMAGE = 0x0172 Global Const $STM_GETIMAGE = 0x0173 ;======== ; basic 2-color gradient ================ Dim $aVertex[2][3] = [[0, 0, 0x00FFAA], [200, 600, 0x00AA44]] ; blue/green to different blue/green $hDC = _WinAPI_CreateCompatibleDC(0) ; create the bitmap $hBitmap = _WinAPI_CreateBitmap(200, 600, 1, 32) $hSv = _WinAPI_SelectObject($hDC, $hBitmap) _WinAPI_GradientFill($hDC, $aVertex, 0, 1) ; actual fill _WinAPI_SelectObject($hDC, $hSv) _WinAPI_DeleteDC($hDC) $hForm = GUICreate('MyGUI', 200, 600, 300, 100) ; create a GUI for the bitmap GUICtrlCreatePic('', 0, 0, 200, 600) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSendMsg(-1, $STM_SETIMAGE, 0, $hBitmap) GUISetState() ;======== somewhat more complex gradient + draggable =========== Dim $aVertex[6][3] = [[0, 0, 0xFF0000],[400, 400, 0x00FF00],[0, 400, 0x0000FF],[0, 0, 0xFF0000],[400, 0, 0xFFFF00],[400, 400, 0x00FF00]] $hColors = GUICreate('Color Wheel', 400, 400, 600, 200, $WS_POPUP) ; Create square GUI $idPic = GUICtrlCreatePic('', 0, 0, 400, 400, -1, $GUI_WS_EX_PARENTDRAG) $hPic = GUICtrlGetHandle($idPic) $hDC = _WinAPI_GetDC($hPic) ; Create 6-point gradient $hDestDC = _WinAPI_CreateCompatibleDC($hDC) $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, 400, 400) $hDestSv = _WinAPI_SelectObject($hDestDC, $hBitmap) _WinAPI_GradientFill($hDestDC, $aVertex, 0, 2) _WinAPI_GradientFill($hDestDC, $aVertex, 3, 5) _WinAPI_ReleaseDC($hPic, $hDC) _WinAPI_SelectObject($hDestDC, $hDestSv) _WinAPI_DeleteDC($hDestDC) _SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap) ; Set gradient to control Local $hObj = _SendMessage($hPic, $STM_GETIMAGE) If $hObj <> $hBitmap Then _WinAPI_DeleteObject($hBitmap) GUISetState() GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) If ($hWnd = $hColors) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION EndFunc
    1 point
  3. MuffettsMan

    exiting a loop

    ok that was a sad response... sry i'm rambling this works a bit better because i got past the while 1 i mentioned originally: (now you can jump into the second gui and back and still exit etc etc #RequireAdmin #include <WinAPIFiles.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <GDIPlus.au3> #include <Misc.au3> Func _IsChecked($idControlID) Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED EndFunc GUICreate("Driver loader", 500, 200) GUICtrlCreateTab(10, 10, 485, 185) Global $BT1 = GUICtrlCreateButton("Exit", 400, 150, 60) $G1 = GUICtrlCreateTabItem("HP 450G1") Global $chb1 = GUICtrlCreateRadio("LAN", 30, 30) Global $chb2 = GUICtrlCreateRadio("WiFi", 30, 50) Global $chb3 = GUICtrlCreateRadio("Chipset", 30, 70) Global $chb8 = GUICtrlCreateRadio("Media Card", 30, 90) Global $chb4 = GUICtrlCreateRadio("Video", 140, 35) Global $chb5 = GUICtrlCreateRadio("Rapid Storage Technology", 140, 55) Global $chb6 = GUICtrlCreateRadio("3D DriveGuard", 140, 75) Global $chb7 = GUICtrlCreateRadio("USB3", 140, 95) $G2 = GUICtrlCreateTabItem("HP 450G2") GUISetState(@sw_show) While 1 Switch GUIGetMsg() case $chb2 IF _IsChecked($chb2) Then subGUI() EndIf case $chb1 IF _IsChecked($chb1) Then If MsgBox(0, "Install", "To Install Nic Driver press OK") = 1 then lan() EndIf EndIf Case $BT1 Exit EndSwitch WEnd Func subGUI() GUICreate("WiFi", 200, 200) Global $wifi1 = GUICtrlCreateRadio("Intel", 30, 30) Global $wifi2 = GUICtrlCreateRadio("Qualcomm", 30, 50) GUISetState(@sw_show) while 1 Switch GUIGetMsg() $nMsg = GUIGetMsg() Case $GUI_EVENT_CLOSE GUISetState(@sw_hide) Return case $wifi1 If _IsChecked($wifi1) Then wifi11() EndIf case $wifi2 If _IsChecked($wifi2) Then wifi22() EndIf EndSwitch WEnd EndFunc Func wifi11() Run("O:\Drivers\HP\ProBook\450G1\WiFi - Intel\sp69971.exe") EndFunc Func wifi22() Run("O:\Drivers\HP\ProBook\450G1\WiFi - Qualcomm\sp64676.exe") EndFunc Func lan() Run("O:\Drivers\HP\ProBook\450G1\Lan\Install_Win7_7092_02252015\setup.exe") EndFunc
    1 point
  4. JLogan3o13

    Problem with my code

    How do you expect anyone to help you troubleshoot an issue without seeing what you've written? Seriously, think about what you're asking...
    1 point
  5. May I add this must third one : http://www.regular-expressions.info/
    1 point
  6. It's funny how some like to toss out their old reliable, almost like part of the family, OS, and some don't. Perhaps we should do the same with our partners in this throw away society. Also funny how Microsoft have to resort to forcing people to move on ... that should tell you something. They just get more bloated and slower, but we compensate by getting more powerful machines ... catch-22 anyone. Imagine running an older version of Windows on a new machine .... apart from a few compatibility issues, it would run like lightning in comparison. We are forced into much of this, for most people anyway, due to security reasons ... and some greater newer functionality. The truth is though, most people would be well served (aside from security issues) with a much older OS ... especially on a new machine. Most people don't need all the bells and whistles and new functionality. In all reality, it is a kind of rort for most, having to update all the time. For an old bod like me, a part of me still pines for the ease of use of Win 98 SE, though the stability of Win XP was undeniably a dogsend. As much as Win 7 & 8 etc have some great new things, I still prefer Win XP ... offline of course ... especially when it comes to File Search, which was Win 7's greatest let down. So I play on Win 7 and work on Win XP (offline) ... and dabble at will on Win 8 (not often). Each to their own in this ongoing lunacy of the always update regime. P.S. Personally I'd much rather spend my time learning new things rather than having to relearn a new version of something old, and all the hassles that are incumbent with that. Life is too short, to seemingly be re-inventing the wheel all the time. The painful price of progress I guess.
    1 point
  7. @Trong : the help file is good, and the forum too. There are a lot of websites with examples and tools to help with regex. These two websites should help you : - http://www.rexegg.com/ - https://regex101.com/
    1 point
  8. mikell - What do you mean? It picked up the quote when I tested it... Nevermind, missed the fact that the OP wanted to get rid of the quote...
    1 point
  9. @Mikell : yours works because the " is just before a StringReplace( StringRegExpReplace($sPath, '\h*\\+\h*', '\\'), '"', '') )
    1 point
  10. kylomas, you forgot the " $sPath = 'c:\\ Alo ha\Ciao \XinChao"\Hello' msgbox(0, '' , stringregexpreplace($sPath, '(\\?"?\s*\\\s*)', "\\"))
    1 point
  11. another way... local $op = 'c:\\ Alo ha\Ciao \Xi nChao"\ Hello' local $np = stringregexpreplace(stringregexpreplace($op,'\\ +| +\\','\\'),'\\+','\\') ConsoleWrite($op & @LF & $np & @CRLF) kylomas
    1 point
  12. I was referring to the path in the OP, not in general. Obviously I know that there are paths with spaces in them, just not as poorly formatted as the one in the OP. That path has to be coming from somewhere, because that isn't a valid Windows path.
    1 point
  13. That code is broken. (/edit: i mean the code in the OP.) Try this: #include <Array.au3> $letter = StringSplit("Alexander,Elizabeth,Tom,Jerry", ",", 2) For $x In $letter For $y In $letter If StringCompare($x, $y) <> 0 Then ConsoleWrite($x & " and " & $y & @CRLF) EndIf Next Next Note that the code above will list "Tom and Jerry" and "Jerry and Tom" as two separate outcomes. If you don't want that, try: #include <Array.au3> $letter = StringSplit("Alexander,Elizabeth,Tom,Jerry", ",") For $x = 1 to $letter[0] - 1 For $y = $x + 1 to $letter[0] If StringCompare($letter[$x], $letter[$y]) <> 0 Then ConsoleWrite($letter[$x] & " and " & $letter[$y] & @CRLF) EndIf Next Next
    1 point
  14. You need to register a WM_NOTIFY message handler with GuiRegisterMsg(). It doesn't have to be as complicated as the example under that function in the help file, but you do usually need to know enough to extract the useful info from a DllStruct. You would be looking for NM_Click messages from the ListView. If you search on that, you'll find working examples on the forum. Edit: Even better, the example under _GUICtrlListView_Create() as AdmiralAlkex said, but you can simplify it much from there too.
    1 point
  15. Wow, I haven't posted in a LONG time. The info at http://community.bartdesmet.net/blogs/bart...09/23/3554.aspx was helpful in creating the following function (which I've only tested under XP Pro, by the way): ;The following function adds a network place to "My Network Places" ; $networkResource is of the form \\server\share OR http://webserver/share OR ftp://ftp.example.com/ ; $name can be any valid file name, i.e., it Cannot contain the characters \ / : * ? " < > | ; Func _FileCreateNetworkPlace($networkResource, $name) Local $NHItem = @UserProfileDir & "\NetHood\" & $name DirCreate($NHItem) FileSetAttrib($NHItem, "+S") FileCreateShortcut($networkResource, $NHItem&'\target.lnk', "", "", $networkResource) IniWriteSection($NHItem&'\desktop.ini', ".ShellClassInfo", "CLSID2={0AFACED1-E828-11D1-9187-B532F1E9575D}" & @LF & "Flags=2") Local $success = FileSetAttrib($NHItem&'\desktop.ini', "+SH") ;;ShellExecute(@UserProfileDir & "\NetHood\" & $name) ;Open Network Place when Finished... Return $success EndFunc;Example usage _FileCreateNetworkPlace("\\Laptop\Share", "Stuff")
    1 point
  16. rasim

    _GUICtrlStatusBar_SetText

    Example: #include <GuiConstantsEx.au3> #include <GuiStatusBar.au3> #include <WindowsConstants.au3> #include <FontConstants.au3> #include <WinAPI.au3> Global $hFont Dim $aParts[3] = [100, 250] Dim $aPartsText[2] = ["System info", "Current directory"] $hGUI = GUICreate("Statusbar custom font demo", 400, 300) $hStatus = _GUICtrlStatusBar_Create($hGUI, $aParts, $aPartsText) _GUICtrlStatusBar_SetFont($hStatus, 16, 800, 2 + 4, "Tahoma") GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE _WinAPI_DeleteObject($hFont) Func _GUICtrlStatusBar_SetFont($hWnd, $iHeight = 15, $iWeight = 400, $iFontAtrributes = 0, $sFontName = "Arial") $hFont = _WinAPI_CreateFont($iHeight, 0, 0, 0, $iWeight, BitAND($iFontAtrributes, 2), BitAND($iFontAtrributes, 4), _ BitAND($iFontAtrributes, 8), $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, _ $DEFAULT_QUALITY, 0, $sFontName) _SendMessage($hWnd, $WM_SETFONT, $hFont, 1) EndFunc ;==>_GUICtrlStatusBar_SetFont
    1 point
×
×
  • Create New...