Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/18/2020 in all areas

  1. Just made a proof of concept how to communicate between AutoIt and VBS. It is based on Named Pipes. My client (VBS) written in AutoIt only uses a COM object available, so it must be a no brainer to translate it into VBS. Not sure it will be fast enough, but at least now you have a potential solution. Server (AutoIt) : #include <NamedPipes.au3> #include <Constants.au3> #include <WinAPIFiles.au3> Local $hNamedPipe = _NamedPipes_CreateNamedPipe("\\.\pipe\pipename", 2, 1) ConsoleWrite ($hNamedPipe & @CRLF) $test = _NamedPipes_ConnectNamedPipe($hNamedPipe) ConsoleWrite ($test & @CRLF) Local $tBuffer = DllStructCreate("char Text[" & 100 & "]"), $iRead, $iWritten $pBuffer = DllStructGetPtr($tBuffer) $bSuccess = _WinAPI_ReadFile($hNamedPipe, $pBuffer, 100, $iRead) ConsoleWrite (DllStructGetData($tBuffer, "Text") & @CRLF) _NamedPipes_DisconnectNamedPipe ($hNamedPipe) $test = _NamedPipes_ConnectNamedPipe($hNamedPipe) ConsoleWrite ($test & @CRLF) DllStructSetData($tBuffer, "Text", "Reponse" & @CRLF) $bSuccess = _WinAPI_WriteFile($hNamedPipe, $pBuffer, 9, $iWritten) If Not $bSuccess Then ConsoleWrite (_WinAPI_GetLastError() & @CRLF) ConsoleWrite ($bSuccess & @CRLF) _NamedPipes_DisconnectNamedPipe ($hNamedPipe) Client (VBS) : Local $oFileSys = ObjCreate("Scripting.FileSystemObject") $oTSF = $oFileSys.OpenTextFile("\\.\pipe\pipename", 2, True, 0) $oTSF.WriteLine("Ceci est un test") $oTSF.Close Sleep (50) $oTSF = $oFileSys.OpenTextFile("\\.\pipe\pipename", 1, True, 0) $sText = $oTSF.Readline() $oTSF.Close() MsgBox (0,"",$sText & @CRLF)
    2 points
  2. Nope, haven't heard about COVID ?
    1 point
  3. well yes when the title changes while working with it e.g. or you have another title e.g. when you start your script next time EDIT: also when the title exist 2 times
    1 point
  4. care with [CLASS:#32770] because much apps have this class...
    1 point
  5. 64 bits handle ? Not the same handle ? No wonder it doesn't work... Seems there is more than 1 windows #32770. Check with WinList. I remember seeing something similar in the past, but just can remember what was the solution...
    1 point
  6. Always preferable to use handle over title. Try to get control handle with this : Local $hCtrl = ControlGetHandle($hWnd, "", 1148) ConsoleWrite ("control = " & $hCtrl & @CRLF) If that doesn't work, try #RequireAdmin (one never knows)
    1 point
  7. Put some error handling after each statement (return value & @error). ConsoleWrite the content of all variables after they are set. This way you will have a better idea if there is an error somewhere or if a variable is badly set.
    1 point
  8. matwachich, UDF-created controls cannot use the GUICtrl* functions as they are not created by AutoIt and so do not exist within the AutoIt native control array. I do not see how such controls could be added to this internal AutoIt array once created and so they can never be actioned as native-created controls. And I have never had any problem resizing UDF-created controls using the disabled label method. Can you give us an example script where it all goes wrong for you? M23
    1 point
  9. The actual loop. “If's” are not loops. This, OTOH, loops forever: While True If WinExists("MagTek HID Secure Card Reader Authenticator API Setup") Then WinActivate("MagTek HID Secure Card Reader Authenticator API Setup") Sleep(2000) MouseClick('primary', 152, 220, 1, 0) WinWait("Microsoft Visual C++ 2010 X86 Redistributable Setup") MouseClick('primary', 52, 265, 1, 0) Sleep(2000) MouseClick('primary', 365, 446, 1, 0) WinWait("Microsoft Visual C++ 2010 x86 Redistributable Setup", "Installation Is Complete") WinActivate("Microsoft Visual C++ 2010 x86 Redistributable Setup", "Installation Is Complete") MouseClick('primary', 439, 446, 1, 0) EndIf Sleep(1000) WEnd Change the While True to whatever condition you want to exit the loop.
    1 point
  10. pixelsearch

    RichEdit resize

    Hi everybody, I would like to revive this thread for 2 reasons : 1) In case jcpetu (OP) still got his issue unsolved, maybe the solution below could work for him. 2) To share with you an alternate way of resizing UDF-created controls, without using the "disabled label way" described in this thread (though it worked fine for me). All credits go to MrCreatoR's UDF GUICtrlSetResizingEx.au3 version 1.3 found in this link. For the record, I discovered MrCreatoR's UDF just now, after having read this new thread from matwachich in this link. So here is jcpetu's code, simplified, with 1 line only to resize the RichEdit controls and it worked great for me, with lesser (apparent) code. Fingers crossed for you, jcpetu #include <GUIConstantsEx.au3> #include <GuiRichEdit.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include 'GUICtrlSetResizingEx.au3' ; https://www.autoitscript.com/forum/topic/202781-guictrlsetresizing-on-udf-createwindowex-created-controls/?tab=comments#comment-1455745 Opt('GUIOnEventMode', 1) Opt('GUICloseOnESC', 0) Global $GuiMain, $GUIversion = 'Rich Edit Resize', $DeskW = @DesktopWidth - 20, $DeskH = @DesktopHeight - 80 Global $I1, $I2, $Edit1, $Edit2 $GuiMain = GUICreate($GUIversion, $DeskW, $DeskH, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX)) ; GUISetBkColor(0xC4C4C4) ; Just so you can see the RichEdits GUISetOnEvent($GUI_EVENT_CLOSE, 'CloseApp') $I1 = GUICtrlCreateInput('', 66, 30, 581, 31) GUICtrlSetResizing(-1, 1) $I2 = GUICtrlCreateInput('', 66, 70, 581, 31) GUICtrlSetResizing(-1, 1) $Edit1 = _GUICtrlRichEdit_Create($GuiMain, '', 10, 140, ($DeskW / 2) - 10, 320, BitOR($ES_MULTILINE, $WS_HSCROLL, $WS_VSCROLL)) _GUICtrlSetResizingEx($Edit1, $GUI_DOCKAUTO) $Edit2 = _GUICtrlRichEdit_Create($GuiMain, '', ($DeskW / 2) + 10, 140, ($DeskW / 2) - 15, 320, BitOR($ES_MULTILINE, $WS_HSCROLL, $WS_VSCROLL)) _GUICtrlSetResizingEx($Edit2, $GUI_DOCKAUTO) $LV1 = GUICtrlCreateListView("", 8, 480, $DeskW - 18, 161, -1, BitOR($LVS_EX_CHECKBOXES, $LVS_EX_SUBITEMIMAGES, $LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT, $LVS_EX_HEADERDRAGDROP, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)) GUICtrlSetResizing(-1, 1) _GUICtrlListView_AddColumn(-1, "#", 30, 1) _GUICtrlListView_AddColumn(-1, "Date", 110, 2) _GUICtrlListView_AddColumn(-1, "Time", 110, 2) _GUICtrlListView_AddColumn(-1, "Event", 110, 2) GUISetState(@SW_SHOW, $GuiMain) While 1 Sleep(10) WEnd Func CloseApp() _GUICtrlRichEdit_Destroy($Edit1) _GUICtrlRichEdit_Destroy($Edit2) GUIDelete($GuiMain) Exit EndFunc ;==>CloseApp To make it easier for you to run the script, I attach below MrCreatoR's UDF GUICtrlSetResizingEx.au3 (version 1.3 dated 09/22/2015), it's the original UDF as found in his archive file : GUICtrlSetResizingEx.au3
    1 point
  11. You can also use the popular program 7-Zip. It is free, even for commercial use. Here is a syntax example : ; Description : ; You will need the latest commandline tools of 7-Zip and the file 7z.dll ; 7za.exe : without GUI ; 7zG.exe : with GUI (optional) : ; useful for larger amounts of data to display the running process. ; 7z.dll ; 7-zip.chm : Helpfile (optional) ; ; ==> I have attached the required programs, see : 7-Zip-Files-Version1900.zip Global $s7ZipDir, $sCommand, $sSourceDir, $sDestDir, $sZIPFile, $sPassword $s7ZipDir = @ScriptDir ; directory where the tools and the .dll are located $sZIPFile = "Test.zip" ; name of the .zip file $sSourceDir = @ScriptDir & '\source' ; *** just an example $sDestDir = @ScriptDir & '\destination' ; *** just an example $sPassword = 'password' ; Example 1 : Create a password protected .zip file ; -> in case you want a GUI : ; ---> replace 7za.exe with 7zG.exe ; ---> replace @SW_HIDE with @SW_SHOW $sCommand = $s7ZipDir & '\7za.exe a -y -tzip "' & $sZIPFile & '" "' & $sSourceDir & '" -p' & $sPassword & ' -mem=AES256' RunWait ($sCommand, "", @SW_HIDE) ; Example 2 : Unzip a password protected .zip file $sCommand = $s7ZipDir & '\7za.exe x "' & $sZIPFile & '" -o"' & $sDestDir & '" -aoa -p' & $sPassword & ' -y' RunWait ($sCommand, "", @SW_HIDE) If @error Then MsgBox(BitOR(4096, 16), "Error : ", "Unable to unzip the file") EndIf EDIT : For the test, create a subfolder \source in the script directory and copy some files into it. 7-Zip-Files-Version1900.zip
    1 point
  12. Concerning this "hovering" script, this will be my final post in Melba23's thread because I'm afraid we are now polluting a bit his thread, which is initially dedicated to GUIListViewEx. In this final post, I'll present the last version of the script, which adds a "fine tuning" to the hovering process. Using MouseGetPos(), WinGetPos(), WinGetClientSize() not forgetting the LV header height (which gladly doesn't change during an eventual LV resize), all of them mixed did a fine job. Now the tooltip (cell "Mary 10" or "Mary 30") immediately disappears as soon as you hover the mouse... * over an eventual LV scrollbar (horizontal or vertical) * over the listview header area #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include "GUIListViewEx.au3" #include <Array.au3> ; Just for display in example Global $iCount_Left = 20, $iCount_Right = 40, $vData, $aRet, $iEditMode = 0 ; Create GUI $hGUI = GUICreate("LVEx Example 4", 640, 430) ; Create Left ListView GUICtrlCreateLabel("Native ListView", 10, 5, 300, 35) $cListView_Left = GUICtrlCreateListView("Tom|Dick|Harry", 10, 40, 250, 300, $LVS_SHOWSELALWAYS) _GUICtrlListView_SetExtendedListViewStyle($cListView_Left, $LVS_EX_FULLROWSELECT) _GUICtrlListView_SetColumnWidth($cListView_Left, 0, 83) _GUICtrlListView_SetColumnWidth($cListView_Left, 1, 83) _GUICtrlListView_SetColumnWidth($cListView_Left, 2, 83) ; Create initial array, replacement array and fill Left listview Global $aLV_List_Left[$iCount_Left + 1] = [$iCount_Left] Global $aLV_List_Left_Replace[$iCount_Left + 1] = [$iCount_Left] For $i = 1 To UBound($aLV_List_Left) - 1 $aLV_List_Left[$i] = "Tom " & $i - 1 & "|Dick " & $i - 1 & "|Harry " & $i - 1 GUICtrlCreateListViewItem($aLV_List_Left[$i], $cListView_Left) $aLV_List_Left_Replace[$i] = "Bill " & $i - 1 & "|Ben " & $i - 1 & "|Bessie " & $i - 1 Next ; Initiate LVEx - count parameter set - blue insert mark- no drag image $iLV_Left_Index = _GUIListViewEx_Init($cListView_Left, $aLV_List_Left, 1, 0x0000FF, False) ; All columns editable _GUIListViewEx_SetEditStatus($iLV_Left_Index, "*") ; Create Right ListView GUICtrlCreateLabel("UDF ListView", 380, 5, 300, 35) $hListView_Right = _GUICtrlListView_Create($hGUI, "Peter|Paul|Mary", 380, 40, 250, 300, BitOR($LVS_SHOWSELALWAYS, $LVS_REPORT, $WS_BORDER)) ;<========================================== $iHeaderHeight = _WinAPI_GetWindowHeight(_GUICtrlListView_GetHeader($hListView_Right)) ;<========================================== _GUICtrlListView_SetExtendedListViewStyle($hListView_Right, BitOr($LVS_EX_FULLROWSELECT, $LVS_EX_HEADERDRAGDROP)) _GUICtrlListView_SetColumnWidth($hListView_Right, 0, 83) _GUICtrlListView_SetColumnWidth($cListView_Left, 1, 83) _GUICtrlListView_SetColumnWidth($cListView_Left, 2, 83) _GUICtrlListView_SetInsertMarkColor($hListView_Right, 0) ; Fill listview For $i = 0 To $iCount_Right - 1 _GUICtrlListView_AddItem($hListView_Right, "Peter " & $i) _GUICtrlListView_AddSubItem($hListView_Right, $i, "Paul " & $i, 1) _GUICtrlListView_AddSubItem($hListView_Right, $i, "Mary " & $i, 2) Next ; Read ListView content into an array $aLV_List_Right = _GUIListViewEx_ReadToArray($hListView_Right, 0) ; Initiate LVEx - no count - green insert parameter - no drag image $iLV_Right_Index = _GUIListViewEx_Init($hListView_Right, $aLV_List_Right, 0, 0x00FF00) ; Create Edit Mode Combos GUICtrlCreateLabel("Edit Modes", 280, 50, 60, 20) GUICtrlCreateLabel("0" & @CRLF & "1" & @CRLF & "2" & @CRLF & "3", 280, 70, 10, 80) GUICtrlCreateLabel(": Single Edit" & @CRLF & ": Exit Edge" & @CRLF & ": Stay Edge" & @CRLF & ": Loop Edge", 290, 70, 65, 80) GUICtrlCreateLabel("Row Mode", 280, 140, 60, 20) $cCombo_Row = GUICtrlCreateCombo("", 280, 160, 75, 20, 0x3) ; $CBS_DROPDOWNLIST GUICtrlSetData($cCombo_Row, "0|1|2|3", 0) GUICtrlCreateLabel("Col Mode", 280, 200, 60, 20) $cCombo_Col = GUICtrlCreateCombo("", 280, 220, 75, 20, 0x3) ; $CBS_DROPDOWNLIST GUICtrlSetData($cCombo_Col, "0|1|2|3", 0) GUICtrlCreateLabel("ESC Mode", 280, 260, 75, 20) $cCombo_Reset = GUICtrlCreateCombo("", 280, 280, 75, 20, 0x3) ; $CBS_DROPDOWNLIST GUICtrlSetData($cCombo_Reset, "Exit Edit|Reset All", "Exit Edit") ; Create buttons $cInsert_Button = GUICtrlCreateButton("Insert", 10, 350, 200, 30) $cDelete_Button = GUICtrlCreateButton("Delete", 10, 390, 200, 30) $cReset_Button = GUICtrlCreateButton("Reset Left", 220, 350, 200, 70) $cDisplay_Left_Button = GUICtrlCreateButton("Show Left", 430, 350, 100, 30) $cDisplay_Right_Button = GUICtrlCreateButton("Show Right", 530, 350, 100, 30) $cExit_Button = GUICtrlCreateButton("Exit", 430, 390, 200, 30) GUISetState() ; Register for dragging and editing _GUIListViewEx_MsgRegister() ; Set the right ListView as active _GUIListViewEx_SetActive(2) Switch _GUIListViewEx_GetActive() Case 0 $sMsg = "No ListView is active" Case 1 $sMsg = "The LEFT ListView is active" & @CRLF & "<--------------------------" Case 2 $sMsg = "The RIGHT ListView is active" & @CRLF & "---------------------------->" EndSwitch MsgBox(0, "Active ListView", $sMsg) MsgBox(0, "Dragging", "You can drag and reorder the headers on the right-hand ListView" & @CRLF & "---------------------------->") ;<============================================== $bToolTip = False ; False = no tooltip displayed ;<============================================== While 1 Switch GUIGetMsg() ;<================================================================ Case $GUI_EVENT_MOUSEMOVE Local $aMPos = MouseGetPos() Local $aLVPos = WinGetPos($hListView_Right) Local $aLVCli = WinGetClientSize($hListView_Right) If $aMPos[0] < $aLVPos[0] OR $aMPos[0] > $aLVPos[0] + $aLVCli[0] _ OR $aMPos[1] <= $aLVPos[1] + $iHeaderHeight OR $aMPos[1] > $aLVPos[1] + $aLVCli[1] Then If $bToolTip Then ; a test is better than hundreds of useless forced ToolTip("") ToolTip("") $bToolTip = False EndIf ContinueLoop EndIf Local $aHit = _GUICtrlListView_SubItemHitTest($hListView_Right) If ($aHit[0] = 10 Or $aHit[0] = 30) And $aHit[1] = 2 Then ; item 10 or 30 / subitem 2 ToolTip("Infos Mary " & $aHit[0] & " displayed here...") $bToolTip = True Else If $bToolTip Then ; a test is better than hundreds of useless forced ToolTip("") ToolTip("") $bToolTip = False EndIf EndIf ;<================================================================ Case $GUI_EVENT_CLOSE, $cExit_Button Exit Case $cInsert_Button ; Prepare data for insertion Switch $aGLVEx_Data[0][1] Case 1 ; Array format with single column native ListView Global $vData[1] = ["Tom " & $iCount_Left] $iCount_Left += 1 _GUIListViewEx_Insert($vData) Case 2 ; String format with single column UDF ListView $vData = "Peter " & $iCount_Right $iCount_Right += 1 _GUIListViewEx_Insert($vData) EndSwitch Case $cDelete_Button _GUIListViewEx_Delete() Case $cReset_Button ; Note parameter required for each step ; Remove current ListView from UDF _GUIListViewEx_Close($iLV_Left_Index) ; UDF index ; Delete all items _GUICtrlListView_DeleteAllItems($cListView_Left) ; ControlID/handle ; Refill the ListView with new data For $i = 1 To UBound($aLV_List_Left_Replace) - 1 GUICtrlCreateListViewItem($aLV_List_Left_Replace[$i], $cListView_Left) ; ControlID/handle Next ; Re-initiate ListView $iLV_Left_Index = _GUIListViewEx_Init($cListView_Left, $aLV_List_Left_Replace, 1, 0x0000FF, False) ; ControlID/handle ; Reset all columns editable _GUIListViewEx_SetEditStatus($iLV_Left_Index, "*") ; UDF index Case $cDisplay_Left_Button $aLV_List_Left = _GUIListViewEx_ReturnArray($iLV_Left_Index) If Not @error Then _ArrayDisplay($aLV_List_Left, "Returned Left") Else MsgBox(0, "Left", "Empty Array") EndIf Case $cDisplay_Right_Button $aLV_List_Right = _GUIListViewEx_ReturnArray($iLV_Right_Index) If Not @error Then _ArrayDisplay($aLV_List_Right, "Returned Right") Else MsgBox(0, "Right", "Empty Array") EndIf Case $cCombo_Row Switch GUICtrlRead($cCombo_Row) Case 0 GUICtrlSetData($cCombo_Col, 0) Case Else If GUICtrlRead($cCombo_Col) = 0 Then GUICtrlSetData($cCombo_Col, GUICtrlRead($cCombo_Row)) EndIf EndSwitch $iEditMode = Number(GUICtrlRead($cCombo_Row) & GUICtrlRead($cCombo_Col)) Case $cCombo_Col Switch GUICtrlRead($cCombo_Col) Case 0 GUICtrlSetData($cCombo_Row, 0) Case Else If GUICtrlRead($cCombo_Row) = 0 Then GUICtrlSetData($cCombo_Row, GUICtrlRead($cCombo_Col)) EndIf EndSwitch $iEditMode = Number(GUICtrlRead($cCombo_Row) & GUICtrlRead($cCombo_Col)) Case $cCombo_Reset ; Toggle edit mode value to switch ESC modes $iEditMode *= -1 EndSwitch $vRet = _GUIListViewEx_EventMonitor($iEditMode) ; Use combos to change EditMode If @error Then MsgBox($MB_SYSTEMMODAL, "Error", "Event error: " & @error) EndIf Switch @extended Case 0 ; No event detected Case 1 If $vRet = "" Then MsgBox($MB_SYSTEMMODAL, "Edit", "Edit aborted" & @CRLF) Else _ArrayDisplay($vRet, "ListView " & _GUIListViewEx_GetActive() & " content edited", Default, 8) EndIf Case 2 If $vRet = "" Then MsgBox($MB_SYSTEMMODAL, "Header edit", "Header edit aborted" & @CRLF) Else _ArrayDisplay($vRet, "ListView " & _GUIListViewEx_GetActive() & " header edited", Default, 8) EndIf Case 3 MsgBox($MB_SYSTEMMODAL, "Sorted", "ListView: " & $vRet & @CRLF) Case 4 MsgBox($MB_SYSTEMMODAL, "Dragged", "From : To" & @CRLF & $vRet & @CRLF) EndSwitch WEnd Maybe a simpler script could be placed in the Example forum because it seems to be an interesting feature, not too hard to script, you just need $iHeaderHeight, $bToolTip (12/18/2020) and Case $GUI_EVENT_MOUSEMOVE + a headache for the crucial line (guess which one !) For the record, I also tested this script on the listview placed at the left (native-created) with a resizable GUI ($WS_SIZEBOX style) and the "$GUI_DOCKAUTO resize mode" applied to the left LV control. Then after having resized the GUI by dragging its bottom right corner, hovering the mouse over a "tooltipped cell" in the now-resized left listview, well it still worked like a charm... just like our "Mary 10" and "Mary 30" in the listview placed at the right ! Mission accomplished Edit : 12/18/2020 : improvement by adding a flag $bToolTip (False = no tooltip actually displayed, True = a tooltip is actually displayed) Edit : 12/19/2020 : as discussed a few lines above, a simpler script concerning this listview hovering process has just been added in the Example forum in this link. Thanks Melba23 for your patience and please delete/move whatever you want that isn't related to GUIListViewEx, in the recent posts of your thread.
    1 point
  13. @KaFu You don't need to use Eval at all: #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) #Region ### START Koda GUI section ### Form= Global $frmLabels = GUICreate("Labels", 405, 293, 302, 218) GUISetOnEvent($GUI_EVENT_CLOSE, "ExitApplication") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### _CreateLabels() _GetLabelTexts() Func ExitApplication() GUIDelete($frmLabels) Exit EndFunc Func _CreateLabels() For $i = 1 To 10 Step 1 Assign("lblLabel" & $i, GUICtrlCreateLabel("Some text " & $i, 8, 8 + ($i * 20), 100, 20), $ASSIGN_FORCEGLOBAL) GUICtrlSetFont(-1, 10, 800, 0, "Arial") GUICtrlSetColor(-1, (Mod($i, 2) = 0 ? 0x00FF00 : 0xFF0000)) Next EndFunc Func _GetLabelTexts() Local $strLabel For $i = 1 To 10 Step 1 $strLabel = Eval("lblLabel" & $i) ConsoleWrite($strLabel & " " & GUICtrlRead($strLabel) & @CRLF) Next EndFunc While 1 Sleep(100) WEnd
    1 point
  14. TanerJames

    GDI PLus Progress bar

    Hi, I don't know GDI plus Can we make the corners of the progress bar ellipse and outer contours? Thanks. ;coded by UEZ build 2013-08-15 #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPISys.au3> #include <GDIPlus.au3> _GDIPlus_Startup() Global Const $STM_SETIMAGE = 0x0172; $IMAGE_BITMAP = 0 Global $iW = 400, $iH = 25, $iBGColor = 0xFFFFFF Global Const $hGUI = GUICreate("Strip Progressbar", 600, 100) GUISetBkColor(0x404040) Global Const $iPic = GUICtrlCreatePic("", 150, 37, $iW, $iH) GUICtrlSetState(-1, $GUI_DISABLE) Global $iBtn = GUICtrlCreateButton("Start", 40, 20, 60, 60) GUISetState() Global $hHBmp_BG, $hB, $iSleep = 30 Global $fPerc, $fPercPrev, $iLoop, $aPos, $iPosX, $iPosY Global $aColors[7][2] = [[0xFFEE5F5B, 0xFFF07673],[0xFFABCC04, 0xFFBBD636],[0xFF78CCEE, 0xFF93D6F1],[0xFFFFBB58, 0xFFFFC97A],[0xFFFF6677, 0xFFFF8795],[0xFF78CCEE, 0xFFFFC97A],[0xFF78CCEE, 0xe8e5d9]] Global $iRandom, $iColorTP, $hTooltip _Init() Global $iDeltaX = _WinAPI_GetSystemMetrics(7) Global $iDeltaY = _WinAPI_GetSystemMetrics(4) + _WinAPI_GetSystemMetrics(33) Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ToolTip("") GUIRegisterMsg($WM_TIMER, "") _WinAPI_DeleteObject($hHBmp_BG) _GDIPlus_Shutdown() GUIDelete() Exit Case $iBtn $fPerc = 0 $iRandom = Random(0, UBound($aColors) - 1, 1) $iColorTP = BitShift(BitAND(BitAND(0x00FFFFFF, $aColors[$iRandom][1]), 0xFF), -16) + BitAND(0x0000FF00, $aColors[$iRandom][1]) + BitShift(BitAND(BitAND(0x00FFFFFF, $aColors[$iRandom][1]), 0xFF0000), 16) ;convert to BGR GUIRegisterMsg($WM_TIMER, "PlayAnim") DllCall("user32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", $iSleep, "int", 0) EndSwitch Until False Func _Init() $hHBmp_BG = _GDIPlus_StripProgressbar(0, $iW, $iH, 0xFF000000 + $iBGColor, $aColors[$iRandom][0], $aColors[$iRandom][1], "") $hB = GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_BG) If $hB Then _WinAPI_DeleteObject($hB) _WinAPI_DeleteObject($hHBmp_BG) EndFunc ;==>_Init Func PlayAnim() Local $sText = "Loading...", $i, $iCalc1, $iCalc2 $fPerc += 0.5 If $fPerc >= 100.5 Then GUIRegisterMsg($WM_TIMER, "") $sText = "Done" EndIf $iLoop = $fPerc - $fPercPrev $fPercPrev = $fPerc For $i = $iLoop To 0 Step - 1 $iCalc1 = ($fPerc - $i) $hHBmp_BG = _GDIPlus_StripProgressbar($iCalc1, $iW, $iH, 0xFF000000 + $iBGColor, $aColors[$iRandom][0], $aColors[$iRandom][1], $sText) $hB = GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_BG) If $hB Then _WinAPI_DeleteObject($hB) _WinAPI_DeleteObject($hHBmp_BG) $aPosCtrl = ControlGetPos($hGUI, 0, $iPic) $aPosGUI = WinGetPos($hGUI) $iPosX = $aPosCtrl[0] + $aPosGUI[0] + $iDeltaX $iPosY = $aPosCtrl[1] + $aPosGUI[1] + $aPosCtrl[3] + $iDeltaY - 2 If $iCalc1 >= 100.5 Then $iCalc1 = 100 $iCalc2 = $iPosX + ($fPerc - $i) / 100 * $iW - 1 If $iCalc2 >= $iPosX + $iW Then $iCalc2 = $iPosX + $iW ToolTip(StringFormat("%02d %", $iCalc1), $iCalc2, $iPosY, "", "", 3) $hTooltip = WinGetHandle(StringFormat("%02d %", ($fPerc - $i))) DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", $hTooltip, "wstr", "", "wstr", "") DllCall("user32.dll", "int", "SendMessage", "hwnd", $hTooltip, "int", 1043, "int", $iColorTP, "int", 0) Next If $fPerc >= 100.5 Then Sleep(750) ToolTip("") EndIf EndFunc ;==>PlayAnim Func _GDIPlus_StripProgressbar($fPerc, $iW, $iH, $iBgColorGui = 0xFFF0F0F0, $iFgColor = 0xFFEE5F5B, $iBGColor = 0xFFF07673, $sText = "Loading...", $iTextColor = 0x000000, $iDir = -1, $iSpeed = 1, $sFont = "Arial", $bFlip = False, $bHBitmap = True) If $fPerc < 0 Then $fPerc = 0 If $fPerc > 100 Then $fPerc = 100 Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local Const $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetPixelOffsetMode($hCtxt, $GDIP_PIXELOFFSETMODE_HIGHQUALITY) _GDIPlus_GraphicsClear($hCtxt, $iBgColorGui) Local $iWidth = $iH * 2, $iLen = $iWidth / 2, $iY Local $hBmp = _GDIPlus_BitmapCreateFromScan0($iWidth, $iH) Local Const $hCtxt_Bmp = _GDIPlus_ImageGetGraphicsContext($hBmp) _GDIPlus_GraphicsSetPixelOffsetMode($hCtxt_Bmp, $GDIP_PIXELOFFSETMODE_HIGHQUALITY) Local $hPen = _GDIPlus_PenCreate($iFgColor), $iPenSize = Int($iH / 12) Local $hPen2 = _GDIPlus_PenCreate(0x50000000, $iPenSize) _GDIPlus_GraphicsClear($hCtxt_Bmp, $iBGColor) Local Static $iX = 0 For $iY = 0 To $iH - 1 Switch $iDir Case 1 _GDIPlus_GraphicsDrawLine($hCtxt_Bmp, $iX + $iY, $iY, $iX + $iY + $iLen, $iY, $hPen) _GDIPlus_GraphicsDrawLine($hCtxt_Bmp, $iX + $iY - 2 * $iLen, $iY, $iX + $iY - 1 * $iLen, $iY, $hPen) Case Else _GDIPlus_GraphicsDrawLine($hCtxt_Bmp, -$iX + $iY, $iY, -$iX + $iY + $iLen, $iY, $hPen) _GDIPlus_GraphicsDrawLine($hCtxt_Bmp, -$iX + $iY + 2 * $iLen, $iY, -$iX + $iY + 3 * $iLen, $iY, $hPen) EndSwitch Next Local $tPoint1 = DllStructCreate("float;float") Local $tPoint2 = DllStructCreate("float;float") DllStructSetData($tPoint1, 1, $iW / 2) ;x1 DllStructSetData($tPoint2, 1, $iW / 2) ;x2 Local $hLineBrush If $bFlip Then _GDIPlus_GraphicsDrawLine($hCtxt_Bmp, 0, 0, $iWidth, 0, $hPen2) DllStructSetData($tPoint1, 2, $iH / 3) ;y1 DllStructSetData($tPoint2, 2, $iH * 2 / 3) ;y2 $hLineBrush = DllCall($__g_hGDIPDll, "uint", "GdipCreateLineBrush", "struct*", $tPoint1, "struct*", $tPoint2, "uint", 0x00FFFFFF, "uint", 0xB0FFFFFF, "int", 0, "int*", 0) $hLineBrush = $hLineBrush[6] _GDIPlus_GraphicsFillRect($hCtxt_Bmp, 0, $iH * 2 / 3 + 1, $iW, $iH / 3, $hLineBrush) Else _GDIPlus_GraphicsDrawLine($hCtxt_Bmp, 0, $iH - $iPenSize / 2, $iWidth, $iH - $iPenSize / 2, $hPen2) DllStructSetData($tPoint1, 2, 0) ;y1 DllStructSetData($tPoint2, 2, $iH / 3) ;y2 $hLineBrush = DllCall($__g_hGDIPDll, "uint", "GdipCreateLineBrush", "struct*", $tPoint1, "struct*", $tPoint2, "uint", 0xB0FFFFFF, "uint", 0x00FFFFFF, "int", 0, "int*", 0) $hLineBrush = $hLineBrush[6] _GDIPlus_GraphicsFillRect($hCtxt_Bmp, 0, 0, $iW, $iH / 3, $hLineBrush) EndIf $iX = Mod($iX + $iSpeed, $iWidth) Local $hTextureBrush = _GDIPlus_TextureCreate($hBmp) _GDIPlus_GraphicsFillRect($hCtxt, 0, 0, $fPerc / 100 * $iW, $iH, $hTextureBrush) If $bFlip Then _GDIPlus_ImageRotateFlip($hBitmap, 6) _GDIPlus_GraphicsSetTextRenderingHint($hCtxt, 4) Local $hBrush = _GDIPlus_BrushCreateSolid(0x40000000 + $iTextColor) Local $hFormat = _GDIPlus_StringFormatCreate() Local $hFamily = _GDIPlus_FontFamilyCreate($sFont) Local $hFont = _GDIPlus_FontCreate($hFamily, $iH * 3 / 5, 2) Local $tLayout = _GDIPlus_RectFCreate(0, 0, $iW, $iH) _GDIPlus_StringFormatSetAlign($hFormat, 1) _GDIPlus_GraphicsDrawStringEx($hCtxt, $sText, $hFont, $tLayout, $hFormat, $hBrush) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hBrush) _GDIPlus_PenDispose($hPen) _GDIPlus_PenDispose($hPen2) _GDIPlus_GraphicsDispose($hCtxt) _GDIPlus_GraphicsDispose($hCtxt_Bmp) _GDIPlus_BitmapDispose($hBmp) _GDIPlus_BrushDispose($hTextureBrush) _GDIPlus_BrushDispose($hLineBrush) If $bHBitmap Then Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) Return $hHBITMAP EndIf Return $hBitmap EndFunc ;==>_GDIPlus_StripProgressbar;coded by UEZ build 2013-08-15
    1 point
  15. funkey

    GDI PLus Progress bar

    Easy way around without GDIPlus: ;coded by UEZ build 2013-08-15 #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPISys.au3> #include <GDIPlus.au3> _GDIPlus_Startup() Global Const $STM_SETIMAGE = 0x0172; $IMAGE_BITMAP = 0 Global $iW = 400, $iH = 25, $iBGColor = 0xFFFFFF Global Const $hGUI = GUICreate("Strip Progressbar", 600, 100) GUISetBkColor(0x404040) Global $iBtn = GUICtrlCreateButton("Start", 40, 20, 60, 60) #Region new from funkey Global Const $hHelp = GUICreate("", $iW, $iH, 150, 37, $WS_CHILD, 0, $hGui) Global Const $iPic = GUICtrlCreatePic("", 0, 0, $iW, $iH) _WinAPI_SetParent($hHelp, $hGui) Global $hRgn = _WinAPI_CreateRoundRectRgn(0, 0, $iW, $iH, 20, 20) _WinAPI_SetWindowRgn($hHelp, $hRgn) #EndRegion GUICtrlSetState(-1, $GUI_DISABLE) GUISetState(@SW_SHOW, $hHelp) GUISetState(@SW_SHOW, $hGUI) Global $hHBmp_BG, $hB, $iSleep = 30 Global $fPerc, $fPercPrev, $iLoop, $aPos, $iPosX, $iPosY Global $aColors[7][2] = [[0xFFEE5F5B, 0xFFF07673],[0xFFABCC04, 0xFFBBD636],[0xFF78CCEE, 0xFF93D6F1],[0xFFFFBB58, 0xFFFFC97A],[0xFFFF6677, 0xFFFF8795],[0xFF78CCEE, 0xFFFFC97A],[0xFF78CCEE, 0xe8e5d9]] Global $iRandom, $iColorTP, $hTooltip _Init() Global $iDeltaX = _WinAPI_GetSystemMetrics(7) Global $iDeltaY = _WinAPI_GetSystemMetrics(4) + _WinAPI_GetSystemMetrics(33) Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ToolTip("") GUIRegisterMsg($WM_TIMER, "") _WinAPI_DeleteObject($hHBmp_BG) _GDIPlus_Shutdown() GUIDelete() Exit Case $iBtn $fPerc = 0 $iRandom = Random(0, UBound($aColors) - 1, 1) $iColorTP = BitShift(BitAND(BitAND(0x00FFFFFF, $aColors[$iRandom][1]), 0xFF), -16) + BitAND(0x0000FF00, $aColors[$iRandom][1]) + BitShift(BitAND(BitAND(0x00FFFFFF, $aColors[$iRandom][1]), 0xFF0000), 16) ;convert to BGR GUIRegisterMsg($WM_TIMER, "PlayAnim") DllCall("user32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", $iSleep, "int", 0) EndSwitch Until False Func _Init() $hHBmp_BG = _GDIPlus_StripProgressbar(0, $iW, $iH, 0xFF000000 + $iBGColor, $aColors[$iRandom][0], $aColors[$iRandom][1], "") $hB = GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_BG) If $hB Then _WinAPI_DeleteObject($hB) _WinAPI_DeleteObject($hHBmp_BG) EndFunc ;==>_Init Func PlayAnim() Local $sText = "Loading...", $i, $iCalc1, $iCalc2 $fPerc += 0.5 If $fPerc >= 100.5 Then GUIRegisterMsg($WM_TIMER, "") $sText = "Done" EndIf $iLoop = $fPerc - $fPercPrev $fPercPrev = $fPerc For $i = $iLoop To 0 Step - 1 $iCalc1 = ($fPerc - $i) $hHBmp_BG = _GDIPlus_StripProgressbar($iCalc1, $iW, $iH, 0xFF000000 + $iBGColor, $aColors[$iRandom][0], $aColors[$iRandom][1], $sText) $hB = GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_BG) If $hB Then _WinAPI_DeleteObject($hB) _WinAPI_DeleteObject($hHBmp_BG) $aPosCtrl = ControlGetPos($hGUI, 0, $iPic) $aPosGUI = WinGetPos($hGUI) $iPosX = $aPosCtrl[0] + $aPosGUI[0] + $iDeltaX $iPosY = $aPosCtrl[1] + $aPosGUI[1] + $aPosCtrl[3] + $iDeltaY - 2 If $iCalc1 >= 100.5 Then $iCalc1 = 100 $iCalc2 = $iPosX + ($fPerc - $i) / 100 * $iW - 1 If $iCalc2 >= $iPosX + $iW Then $iCalc2 = $iPosX + $iW ToolTip(StringFormat("%02d %", $iCalc1), $iCalc2, $iPosY, "", "", 3) $hTooltip = WinGetHandle(StringFormat("%02d %", ($fPerc - $i))) DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", $hTooltip, "wstr", "", "wstr", "") DllCall("user32.dll", "int", "SendMessage", "hwnd", $hTooltip, "int", 1043, "int", $iColorTP, "int", 0) Next If $fPerc >= 100.5 Then Sleep(750) ToolTip("") EndIf EndFunc ;==>PlayAnim Func _GDIPlus_StripProgressbar($fPerc, $iW, $iH, $iBgColorGui = 0xFFF0F0F0, $iFgColor = 0xFFEE5F5B, $iBGColor = 0xFFF07673, $sText = "Loading...", $iTextColor = 0x000000, $iDir = -1, $iSpeed = 1, $sFont = "Arial", $bFlip = False, $bHBitmap = True) If $fPerc < 0 Then $fPerc = 0 If $fPerc > 100 Then $fPerc = 100 Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local Const $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetPixelOffsetMode($hCtxt, $GDIP_PIXELOFFSETMODE_HIGHQUALITY) _GDIPlus_GraphicsClear($hCtxt, $iBgColorGui) Local $iWidth = $iH * 2, $iLen = $iWidth / 2, $iY Local $hBmp = _GDIPlus_BitmapCreateFromScan0($iWidth, $iH) Local Const $hCtxt_Bmp = _GDIPlus_ImageGetGraphicsContext($hBmp) _GDIPlus_GraphicsSetPixelOffsetMode($hCtxt_Bmp, $GDIP_PIXELOFFSETMODE_HIGHQUALITY) Local $hPen = _GDIPlus_PenCreate($iFgColor), $iPenSize = Int($iH / 12) Local $hPen2 = _GDIPlus_PenCreate(0x50000000, $iPenSize) _GDIPlus_GraphicsClear($hCtxt_Bmp, $iBGColor) Local Static $iX = 0 For $iY = 0 To $iH - 1 Switch $iDir Case 1 _GDIPlus_GraphicsDrawLine($hCtxt_Bmp, $iX + $iY, $iY, $iX + $iY + $iLen, $iY, $hPen) _GDIPlus_GraphicsDrawLine($hCtxt_Bmp, $iX + $iY - 2 * $iLen, $iY, $iX + $iY - 1 * $iLen, $iY, $hPen) Case Else _GDIPlus_GraphicsDrawLine($hCtxt_Bmp, -$iX + $iY, $iY, -$iX + $iY + $iLen, $iY, $hPen) _GDIPlus_GraphicsDrawLine($hCtxt_Bmp, -$iX + $iY + 2 * $iLen, $iY, -$iX + $iY + 3 * $iLen, $iY, $hPen) EndSwitch Next Local $tPoint1 = DllStructCreate("float;float") Local $tPoint2 = DllStructCreate("float;float") DllStructSetData($tPoint1, 1, $iW / 2) ;x1 DllStructSetData($tPoint2, 1, $iW / 2) ;x2 Local $hLineBrush If $bFlip Then _GDIPlus_GraphicsDrawLine($hCtxt_Bmp, 0, 0, $iWidth, 0, $hPen2) DllStructSetData($tPoint1, 2, $iH / 3) ;y1 DllStructSetData($tPoint2, 2, $iH * 2 / 3) ;y2 $hLineBrush = DllCall($__g_hGDIPDll, "uint", "GdipCreateLineBrush", "struct*", $tPoint1, "struct*", $tPoint2, "uint", 0x00FFFFFF, "uint", 0xB0FFFFFF, "int", 0, "int*", 0) $hLineBrush = $hLineBrush[6] _GDIPlus_GraphicsFillRect($hCtxt_Bmp, 0, $iH * 2 / 3 + 1, $iW, $iH / 3, $hLineBrush) Else _GDIPlus_GraphicsDrawLine($hCtxt_Bmp, 0, $iH - $iPenSize / 2, $iWidth, $iH - $iPenSize / 2, $hPen2) DllStructSetData($tPoint1, 2, 0) ;y1 DllStructSetData($tPoint2, 2, $iH / 3) ;y2 $hLineBrush = DllCall($__g_hGDIPDll, "uint", "GdipCreateLineBrush", "struct*", $tPoint1, "struct*", $tPoint2, "uint", 0xB0FFFFFF, "uint", 0x00FFFFFF, "int", 0, "int*", 0) $hLineBrush = $hLineBrush[6] _GDIPlus_GraphicsFillRect($hCtxt_Bmp, 0, 0, $iW, $iH / 3, $hLineBrush) EndIf $iX = Mod($iX + $iSpeed, $iWidth) Local $hTextureBrush = _GDIPlus_TextureCreate($hBmp) _GDIPlus_GraphicsFillRect($hCtxt, 0, 0, $fPerc / 100 * $iW, $iH, $hTextureBrush) If $bFlip Then _GDIPlus_ImageRotateFlip($hBitmap, 6) _GDIPlus_GraphicsSetTextRenderingHint($hCtxt, 4) Local $hBrush = _GDIPlus_BrushCreateSolid(0x40000000 + $iTextColor) Local $hFormat = _GDIPlus_StringFormatCreate() Local $hFamily = _GDIPlus_FontFamilyCreate($sFont) Local $hFont = _GDIPlus_FontCreate($hFamily, $iH * 3 / 5, 2) Local $tLayout = _GDIPlus_RectFCreate(0, 0, $iW, $iH) _GDIPlus_StringFormatSetAlign($hFormat, 1) ;Center text _GDIPlus_GraphicsDrawStringEx($hCtxt, $sText, $hFont, $tLayout, $hFormat, $hBrush) ;Loading text _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hBrush) _GDIPlus_PenDispose($hPen) _GDIPlus_PenDispose($hPen2) _GDIPlus_GraphicsDispose($hCtxt) _GDIPlus_GraphicsDispose($hCtxt_Bmp) _GDIPlus_BitmapDispose($hBmp) _GDIPlus_BrushDispose($hTextureBrush) _GDIPlus_BrushDispose($hLineBrush) If $bHBitmap Then Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) Return $hHBITMAP EndIf Return $hBitmap EndFunc ;==>_GDIPlus_StripProgressbar;coded by UEZ build 2013-08-15 Not ideal code part for border: #Region new from funkey Global Const $hHelp = GUICreate("", $iW + 16, $iH + 7, 150, 47, $WS_CHILD, 0, $hGui) GUISetBkColor(0x000000) Global Const $iPic = GUICtrlCreatePic("", 8, 3, $iW , $iH) _WinAPI_SetParent($hHelp, $hGui) Global $hRgn = _WinAPI_CreateRoundRectRgn(0, 0, $iW + 16, $iH + 7, 20, 20) _WinAPI_SetWindowRgn($hHelp, $hRgn) #EndRegion Better solution for border: #Region new from funkey Global Const $hHelp1 = GUICreate("", $iW + 6, $iH + 6, 150, 47, $WS_CHILD, 0, $hGui) _WinAPI_SetParent($hHelp1, $hGui) GUISetBkColor(0x000000) Global Const $hHelp2 = GUICreate("", $iW, $iH, 3, 3, $WS_CHILD, 0, $hHelp1) _WinAPI_SetParent($hHelp2, $hHelp1) Global Const $iPic = GUICtrlCreatePic("", 0, 0, $iW , $iH) Global $hRgn1 = _WinAPI_CreateRoundRectRgn(0, 0, $iW + 6, $iH + 6, 25, 25) Global $hRgn2 = _WinAPI_CreateRoundRectRgn(0, 0, $iW, $iH, 20, 20) _WinAPI_SetWindowRgn($hHelp1, $hRgn1) _WinAPI_SetWindowRgn($hHelp2, $hRgn2) #EndRegion
    1 point
  16. Attached my old UDF for this (but works even on new versions). Don't remember why i didn't posted it here before. GUICtrlSetResizingEx_1.3.zip
    1 point
  17. Melba23

    No checkbox text color

    ineedh3lp, You need to remove the theme from the control before you can colour it: #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $msg GUICreate("My GUI color text") ; will create a dialog box that when displayed is centered Local $hCheckbox = GUICtrlCreateCheckbox ("my Red checkbox text", 10, 20) DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($hCheckbox), "wstr", 0, "wstr", 0) GUICtrlSetColor(-1, 0xff0000) ; Red GUISetState() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd EndFunc ;==>Example All clear? M23
    1 point
×
×
  • Create New...