Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/07/2024 in all areas

  1. Maybe posting a specific question without unnecessary code increase the chances that you will receive a fast answer from other users. Anyway, here is a demo that should help you. Make the necessary changes to fit your project. #include <GDIPlus.au3> _GDIPlus_Startup() Global $hDisplay = _GDIPlus_BitmapCreateFromScan0(178, 146) Global $hGraphics1 = _GDIPlus_ImageGetGraphicsContext($hDisplay) Global $hColor = _GDIPlus_BitmapCreateFromScan0(178, 146) Global $hGraphics2 = _GDIPlus_ImageGetGraphicsContext($hColor) Global $hTransparent = _GDIPlus_BitmapCreateFromFile(@ScriptDir & '\transparent.bmp') Global $hGUI, $cPic, $cSlider, $hSlider, $cDummy $hGUI = GUICreate('Example', 198, 250) $cPic = GUICtrlCreatePic('', 10, 10, 178, 146) $cSlider = GUICtrlCreateSlider(10, 165, 178, 40) $hSlider = GUICtrlGetHandle($cSlider) $cColor = GUICtrlCreateInput('D62828', 10, 215, 178, 25, 0x01) $cDummy = GUICtrlCreateDummy() GUICtrlSetLimit($cSlider, 255, 0) GUICtrlSetFont($cColor, 12) GUICtrlSetData($cSlider, 127) GUISetState(@SW_SHOW, $hGUI) GUIRegisterMsg(0x0114, 'WM_HSCROLL') UpdateColor() While True Switch GUIGetMsg() Case $cDummy If GUICtrlRead($cDummy) = $cSlider Then UpdateColor() Case -3 ExitLoop EndSwitch WEnd _GDIPlus_GraphicsDispose($hGraphics1) _GDIPlus_GraphicsDispose($hGraphics2) _GDIPlus_BitmapDispose($hTransparent) _GDIPlus_BitmapDispose($hColor) _GDIPlus_BitmapDispose($hDisplay) _GDIPlus_Shutdown() Func UpdateColor() Local $sColor = GUICtrlRead($cColor) Local $iAlpha = GUICtrlRead($cSlider) _GDIPlus_GraphicsDrawImageRect($hGraphics1, $hTransparent, 0, 0, 178, 146) _GDIPlus_GraphicsClear($hGraphics2, '0x' & Hex($iAlpha, 2) & $sColor) _GDIPlus_GraphicsDrawImageRect($hGraphics1, $hColor, 0, 0, 178, 146) ImageToCtrl($hDisplay, $cPic) GUICtrlSetTip($cSlider, $iAlpha) EndFunc Func ImageToCtrl($hBitmap, $cCtrl) Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _WinAPI_DeleteObject(GUICtrlSendMsg($cCtrl, 0x0172, 0, $hHBITMAP)) _WinAPI_DeleteObject($hHBITMAP) EndFunc Func WM_HSCROLL($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Switch $lParam Case $hSlider GUICtrlSendToDummy($cDummy, $cSlider) EndSwitch EndFunc
    1 point
  2. Well I can be like a dog with a bone sometimes. I worry at it until I succeed. I finally got aria2 to work, and yes it was Win 7 32 bit related. Another search on my socket error, eventually brought me to the following posted issue. https://github.com/aria2/aria2/issues/1801 So going by that I grabbed a static version of aria2, and tried that. That failed with a certificate error. So as I had also read how to provide the certificate on the command-line, I did that ... and whamo it worked. $params = $aria2 & ' -c -d "' & $downfold & '" -o "' & $file & '" -x ' & $threads & ' --ca-certificate="' & $cert & '" "' & $URL & '"' $pid = RunWait($params, "", @SW_SHOW) I'll provide the full script, once I have tidied a few things up, but could not contain my excitement right now, so had to share. Anyway, once again a BIG THANKS to my buddy @TheDcoder for his original suggestion and command-line and helpful comments along the way at various stages. We got there in the end ... what a journey.
    1 point
  3. water

    Install Windows Service

    He started his post with "I know it's old". I think in this case it is a good idea to post his finding in an rather old thread for completeness. So everyone searching for "Services" finds this thread (amongst others) and gets help in solving this problem. Or should he have created a new thread for this few lines?
    1 point
  4. If you are lazy enough to learn WM (like me ) then you can try this: #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> $hGUI = GUICreate("Test", 280, 250) $cListView = GUICtrlCreateListView("Column 0|Column 1|Column 2", 10, 10, 260, 160) For $i = 0 To 5 GUICtrlCreateListViewItem("Item " & $i & "0|Item " & $i & "1|Item " & $i & "2", $cListView) Next GUISetState() Local $winHandle = GUICtrlGetHandle ( $hGUI ) While 1 $nMsg = GUIGetMsg() If $nMsg = $GUI_EVENT_PRIMARYDOWN Then $handleOfObject = GUIGetCursorInfo ( $winHandle ) if Not @error Then If $handleOfObject[4] = $cListView Then $nMsg = $cListView EndIf EndIf Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $cListView $iIndex = _GUICtrlListView_GetSelectionMark($cListView) $text = _GUICtrlListView_GetItemTextString($cListView, $iIndex ) MsgBox(64,"Item text",$text) EndSwitch WEnd
    1 point
  5. Process CPU Usage Trackers As yet another alternative to the Performance Counters UDF, I've created this UDF to allow easy tracking of one or more processes's CPU usage. While this has obviously been done before, I haven't seen it done the way I've created it. Basically, just as the Performance Counters had Process Counter objects, so this too has Process Usage trackers. They are relatively simple to use, and require very little interaction other than invoking the functions. To create a new tracker object, call one of these: _ProcessUsageTracker_Create() ; Single process tracker _ProcessesUsageTracker_Create() ; Multiple processes tracker The multiple-process tracker requires addition of processes, which can be done one of 2 ways: _ProcessesUsageTracker_Add() ; add a single process _ProcessesUsageTracker_AddMultiple() ; multiple processes in a ProcessList-style array After the usage tracker object has been created, stats can be collected via one of two calls: _ProcessUsageTracker_GetUsage() ; single process - returns a percentage _ProcessesUsageTracker_GetUsage() ; multiple Processes - returns an array of %'s Basically the main loop of the program can be filled with 'GetUsage' calls without juggling anything around. If a process dies out, an @error code will be returned in the single-process version. The multiple-process tracker version however lets you retain dead processes in the list although their process handles will be closed. These can be alternatively cleared up on each call to 'GetUsage' (setting $bRemoveDead to True), or you can opt to clean them up with the following call: _ProcessesUsageTracker_RemoveDead() ; Removes any dead processes from the tracker object Finally, to destroy the trackers and close handles, just call the appropriate function: _ProcessUsageTracker_Destroy() _ProcessesUsageTracker_Destroy() That's about it. More info is in the headers. Here's an example of a single process cpu usage tracker: ; ======================================================================================================== ; <Process_CPUUsageExample.au3> ; ; Example usage of <Process_CPUUsage.au3> ; ; Author: Ascend4nt ; ======================================================================================================== #include "Process_CPUUsage.au3" ; -------------------- HOTKEY FUNCTION & VARIABLE -------------------- Global $bHotKeyPressed=False Func _EscPressed() $bHotKeyPressed=True EndFunc ; -------------------- MAIN PROGRAM CODE -------------------- HotKeySet("{Esc}", "_EscPressed") Local $hSplash, $sSplashText Local $sProcess, $aProcUsage, $fUsage ; Regular Process: ;~ $sProcess = "firefox.exe" ;~ $sProcess = "sp2004.exe" ; Stress Prime 2004 ; Protected Process (opens a different way): ;~ $sProcess = "audiodg.exe" ; Processes Requiring elevated privilege (will fail even with limited access rights): ;~ $sProcess = "CTAudSvc.exe" $sProcess = InputBox("Enter Process Name", "Process Name:", "", "", 320, 140) If @error Or $sProcess = "" Then Exit $aProcUsage = _ProcessUsageTracker_Create($sProcess) If @error Then Exit ConsoleWrite("Error calling _ProcessUsageTracker_Create(): " & @error & ", @extended = " & @extended & @CRLF) Sleep(250) $hSplash=SplashTextOn("Process CPU Usage Information", "", 360, 20 + 60, Default, Default, 16, Default, 12) ; Start loop Do $sSplashText="" $fUsage = _ProcessUsageTracker_GetUsage($aProcUsage) If @error Then ConsoleWrite("Error from _ProcessUsageTracker_GetUsage(): " & @error & ", @extended = " &@extended & @CRLF) ExitLoop EndIf $sSplashText &= "'"&$sProcess&"' CPU usage: " & $fUsage & " %" & @CRLF $sSplashText &= @CRLF & "[Esc] exits" ControlSetText($hSplash, "", "[CLASS:Static; INSTANCE:1]", $sSplashText) Sleep(500) Until $bHotKeyPressed _ProcessUsageTracker_Destroy($aProcUsage) _ Multiple processes example, which is best used with something like 'chrome' which spawns a number of processes with the same name: ; ======================================================================================================== ; <Processes_CPUUsageExample.au3> ; ; Example usage of <Processes_CPUUsage.au3> ; ; Author: Ascend4nt ; ======================================================================================================== #include "Processes_CPUUsage.au3" ; -------------------- HOTKEY FUNCTION & VARIABLE -------------------- Global $bHotKeyPressed=False Func _EscPressed() $bHotKeyPressed=True EndFunc ; -------------------- MAIN PROGRAM CODE -------------------- HotKeySet("{Esc}", "_EscPressed") Local $hSplash, $sSplashText Local $sProcess, $aProcList, $aProcUsage, $aPercents, $nPercents ; Regular Process: ;~ $sProcess = "firefox.exe" ;~ $sProcess = "sp2004.exe" ; Stress Prime 2004 ; Protected Process (opens a different way): ;~ $sProcess = "audiodg.exe" ; Processes Requiring elevated privilege (will fail even with limited access rights): ;~ $sProcess = "CTAudSvc.exe" $sProcess = InputBox("Enter Process Name", "Process Name:", "", "", 320, 140) If @error Or $sProcess = "" Then Exit $aProcUsage = _ProcessesUsageTracker_Create() _ProcessesUsageTracker_Add($aProcUsage, "sp2004.exe") _ProcessesUsageTracker_Add($aProcUsage, "CPUStabTest.exe") $aProcList = ProcessList("chrome.exe") _ProcessesUsageTracker_AddMultiple($aProcUsage, $aProcList) _ProcessesUsageTracker_Add($aProcUsage, $sProcess) _ProcessesUsageTracker_Add($aProcUsage, "audiodg.exe") Sleep(250) $hSplash=SplashTextOn("Process CPU Usage Information", "", 380, 24 + 15*2 + $aProcUsage[0][0]*15, Default, Default, 16+4, "Lucida Console", 11) ; Start loop Do ; DEBUG: Interrupt to allow multiple process termination ;MsgBox(0, "Next usage", "Next usage time..") $sSplashText="" $aPercents = _ProcessesUsageTracker_GetUsage($aProcUsage, True) ; True = Remove dead $nPercents = @extended If @error Then ConsoleWrite("Error from _ProcessesUsageTracker_GetUsage(): " & @error & ", @extended = " &@extended & @CRLF) ExitLoop EndIf For $i = 0 To $nPercents - 1 $sSplashText &= "'"&$aProcUsage[$i+1][0]&"' [PID #"&$aProcUsage[$i+1][1]&"] CPU usage: " & $aPercents[$i] & " %" & @CRLF Next $sSplashText &= @CRLF & "[Esc] exits" ControlSetText($hSplash, "", "[CLASS:Static; INSTANCE:1]", $sSplashText) Sleep(500) Until $bHotKeyPressed _ProcessesUsageTracker_Destroy($aProcUsage) ProcessCPUUsage.zip
    1 point
×
×
  • Create New...