Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/02/2020 in all areas

  1. Sure ... banned permanently! 🤐 Jos
    3 points
  2. After seeing a number of threads talking about how to exchange efficiently messages between processes (Inter Process Communication), I decided to create a framework using Windows Messages WM_COPYDATA. What is new with this UDF you ask ? Well it will depends how familiar you are with IPC. One thing is sure, the simplicity of use and the fabulous speed are amazing. This is based on a Clients-Server approach. You can have an unlimited number of clients talking with a single server. You will have to define the protocol of communication between them, but the code you have to create is incredibly low. The UDF proposes 2 simple message properties of communication. The first (called data) is based on a number. You can decide what value 1,2,3, etc. means between your client and server. Server will react upon the value of the data field. Second, there is a string field where you can inscribe additional information on request, and where the server will respond to client request (if necessary). Here are the functions that I have wrapped around this : Func _WCD_CreateServer Func _WCD_CreateClient Func _WCD_GetServerHandle Func _WCD_IsServerAvailable Func _WCD_Send Func _WCD_WM_COPYDATA_CLIENT_HANDLER Func _WCD_Client_GetResponse Func _WCD_WM_COPYDATA_SERVER_HANDLER Func _WCD_Server_PeekRequest Func _WCD_Server_GetRequest Func _WCD_Server_IsRequestAvail Here an example of the server : #include <Constants.au3> #include <GUIConstants.au3> #include "WCD_IPC.au3" Opt ("MustDeclareVars", 1) $_WCD_Verbose = False ; make it True if you want to follow the convos. False is by default. Local $hServer = _WCD_CreateServer () Local $aReq, $iData While True If _WCD_Server_IsRequestAvail () Then $aReq = _WCD_Server_GetRequest () $iData = @extended Switch $iData Case 1 ; who are you _WCD_Send($hServer, $aReq[0], $iData, @ComputerName) Case 2 Switch Number($aReq[1]) Case 1 _WCD_Send($hServer, $aReq[0], $iData, @IPAddress1) Case 2 _WCD_Send($hServer, $aReq[0], $iData, @IPAddress2) Case 3 _WCD_Send($hServer, $aReq[0], $iData, @IPAddress3) Case 4 _WCD_Send($hServer, $aReq[0], $iData, @IPAddress4) Case Else _WCD_Send($hServer, $aReq[0], $iData, "Invalid parameter") EndSwitch EndSwitch EndIf Sleep (100) WEnd And the client : #include <Constants.au3> #include <GUIConstants.au3> #include "WCD_IPC.au3" Opt ("MustDeclareVars", 1) $_WCD_Verbose = True ; as for the server, you can decide to make client verbose or not Global $hWnd = _WCD_CreateClient ("Test WCD Client") Global $hWndServer = _WCD_GetServerHandle () _WCD_Send($hWnd, $hWndServer, 1) ; simple request - who are you ? Local $sString = WaitForResponse () ConsoleWrite ($sString & @CRLF) _WCD_Send($hWnd, $hWndServer, 2, "5") ; adding text to a more complex request $sString = WaitForResponse () ConsoleWrite ($sString & @CRLF) Func WaitForResponse () Local $sResp While _WCD_IsServerAvailable () $sResp = _WCD_Client_GetResponse () If $sResp <> "" Then Return $sResp Sleep (100) WEnd EndFunc As always, let me know if you got issues, comments, suggestions. I will be glad to answer. Version 2020-06-27 * Allows processes with different levels of privilege to communicate with each other WCD_IPC.au3
    2 points
  3. Was getting confused reading these it seems that there are two things going on here. A slowdown in general with Win10 and PeekMessage. And another that is nothing to do with Win10 and just a general slowdown with OnEventModes? I just had a look at the GuiOnEvent code and there is the allocation of a string structure each call which when I remove it seems to completely remove the delay so I'll look at fixing that.
    2 points
  4. Trong

    Image Search UDF

    Version 2021.8.30.2

    10,235 downloads

    Use MouseClick() need: #RequireAdmin Dll is already integrated in UDF ! ; #INDEX# =============================================================== ; Title .........: ImageSearch ; AutoIt Version : 3.x ; Language ......: English ; Description ...: Check image Appears or Not and Return the position of an image on the desktop ; Author(s) .....: Dao Van Trong - TRONG.LIVE ; ======================================================================= ; #CURRENT# ============================================================= ; _ImageSearch ; _ImageSearch_Area ; _ImageSearch_Wait ; _ImageSearch_WaitArea ; ======================================================================== ;========================================================================= ; ; Author:...........: AutoIT VietNam : Dao Van Trong - TRONG.LIVE ; Description:......: Check image Appears or Not ; Find and return the position of an image on the desktop ; Syntax:........... _ImageSearch_Area, _ImageSearch ; Parameter(s):..... $_ImagePath: The image to locate on the desktop ; May be a list of image by delimited by "|" ; i.e: $_ImagePath = "image1.bmp|image2.bmp|image3.bmp" ; $P_x1 $P_y1: Position of 1st point ; $P_x2 $P_y2: Position of 2nd point - Default is last botton right of desktop ; $_Tolerance: 0 for no tolerance (0-255). Needed when colors of image differ from desktop. e.g GIF ; $_CenterPos: boolen. True will return $array[1] x $array[2] is center of image found. ; False will return top-left position ; Return Value(s):.. Return an array has 3 item ; On Success: $array[0] 1 ; On Failure: $array[0] 0 ; DLL not found or other error: $array[0] -1 ; $array[1] x $array[2]: position of image what found on desktop ; ; Note:............. Use _ImageSearch to search the entire desktop ; _ImageSearch_Area to specify a desktop region to search ; $_ImagePath with more item need more time appear on screen before function can detect. ; Decrease sleep time in the loop to detect faster. But less performance. I.e CPULoad increased ; ;======================================================================== EG 1: ;~ Opt("MustDeclareVars", 1) ;~ #AutoIt3Wrapper_UseX64=y ;~ #AutoIt3Wrapper_Change2CUI=y #RequireAdmin #include "_ImageSearch_UDF.au3" HotKeySet("{Esc}", "_Exit") ; Press ESC for exit Func _Exit() Exit 0 EndFunc ;==>_Exit Global Const $Ask_On_Found = 0 Global Const $Mouse_Move_On_Found = 1 Global Const $Mouse_Click_On_Found = 0 Global Const $iSleep_Time=500 Global $sCount = 0, $_Image_1 = @ScriptDir & "\example.bmp" ; First, use this function to create a file bmp, maybe a desktop icon for example') MsgBox(64 + 262144, 'ImageSearch', 'At first, create a file bmp,' & @CRLF & 'photos that will search on the screen!') _ImageSearch_Create_BMP($_Image_1) ConsoleWrite("! Search for images: " & $_Image_1 & @CRLF & '! Searching on the screen ...' & @CRLF) While 1 ToolTip('(Press ESC for EXIT) Searching ...', 1, 1) Sleep($iSleep_Time) $sCount += 1 Local $return = _ImageSearch($_Image_1) If $return[0] = 1 Then ConsoleWrite('- [' & $sCount & '] Image found:' & " X=" & $return[1] & " Y=" & $return[2] & @CRLF) If $Mouse_Move_On_Found Then MouseMove($return[1], $return[2]) Sleep($iSleep_Time) EndIf If $Mouse_Click_On_Found Then MouseClick("left", $return[1], $return[2]) ToolTip('(Press ESC for EXIT) - [' & $sCount & "] Image found:" & " X=" & $return[1] & " Y=" & $return[2], 1, 1) If $Ask_On_Found Then Local $ask = MsgBox(6 + 262144, 'Success [' & $sCount & ']', 'Image found:' & " X=" & $return[1] & " Y=" & $return[2]) If $ask = 2 Or $ask = 3 Or $ask = 5 Or $ask = 7 Then Exit ;No, Abort, Cancel, and Ignore If $ask = 10 Then _ImageSearch_Create_BMP($_Image_1) ; Continue ;Try Again EndIf EndIf Sleep(200) WEnd Video demo: [+] When any problem or error occurs, please make sure that:- Downloaded and used the latest version.- Set screen Screen Scale and layout = 100%- Installed display driver.- Tried turning off the antivirus- Full installation: Microsoft Visual C++ Redistributable 2005->2022 [+] You can download the AIO version of the Visual C++ Redistributable here: -> https://www.mediafire.com/file/0ak8dcj9mdn7nyq/VisualCppRedist_AIO_2005-2022_x86_x64_%5Btrong.live%5D.zip/file -> FOR Windows XP: https://www.mediafire.com/file/5m5lnr1kfg73tc9/VisualCppRedist_AIO_2005-2019_x86_XP_%5Btrong.live%5D.zip/file <!> Password for Extract: trong.live [+] The last full version of SCITE4AutoIT supports windows XP: https://www.autoitscript.com/autoit3/scite/download/archive/v19.1127.1402.0-SciTE4AutoIt3.exe
    1 point
  5. This is an update or derivative work of Beege 's Scrolling Line Graph UDF https://www.autoitscript.com/forum/topic/109599-scrolling-line-graph-udf I noticed a few issues for my use case with the UDF one being that adding a sample required updating the waveform High CPU usage went hand in hand with that requirement Another issue was just how long updating took to complete I've hopefully rectified that with this version There are a few changes (only 1 line per graph for instance) The addition of a function AddSample (uses graphics paths to speed up drawing samples on update) Gridlines are only generated once A sample finished line can be added UpdateGraph allows you to compress the discarded portion of the graph (it looks kinda cool but uses more CPU) Lower Cpu usage Uses real Control Ids - it is a label control underneath so you get click events and can display text when control is disabled Example (Waveform.au3) Example 2 (peak.au3) UDF Updated: Previous Downloads [38 / 38/ 0] SSLG.au3 waveform.au3 Peak.au3
    1 point
  6. therks

    Floating Clock Screensaver

    It seems there are not many screensavers here in the examples forum. Thought maybe I could share mine. I'll admit some of the code is sloppy, global vars declared in functions, etc. But I started writing it almost 10 years ago and I just don't have the motivation to clean it up and rewrite from scratch. 😅 Maybe some day.. but for now, here's the code: ; Big thanks to UEZ (AutoIt forums) for his help with the GDI programming. #NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=FloatingClock.ico #AutoIt3Wrapper_Outfile=FloatingClock.scr #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Res_Fileversion=1.0.1.3 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=n #AutoIt3Wrapper_Run_Before=IF "%fileversion%" NEQ "" COPY "%in%" "%scriptdir%\%scriptfile% (v%fileversion%).au3" #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstants.au3> #include <EditConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Math.au3> #Include <GDIPlus.au3> #include <Misc.au3> #include <Color.au3> #include <WinAPIProc.au3> #include <WinAPISys.au3> Global $IS_PREVIEW = False Global $TARGET_SPEED = 0.2, $DRIFT_SPEED = 100, $VELOC_DECAY = 1.01, $PROX_RADIUS = 100 Global $TIME_STRING[8], $TEXT_WIDTH, $TEXT_HEIGHT Global Enum $TP_X, $TP_Y, $TP_W, $TP_H, $TP_CHAR, $TP_UB Global $TIME_PIECES[8][$TP_UB] Global Enum $TG_X, $TG_Y, $TG_XVEL, $TG_YVEL, $TG_UB Global $TARGET_FOLLOW[$TG_UB], $TARGET_RANDOM[2] Global $CANVAS_X = _WinAPI_GetSystemMetrics($SM_XVIRTUALSCREEN) Global $CANVAS_Y = _WinAPI_GetSystemMetrics($SM_YVIRTUALSCREEN) Global $CANVAS_WIDTH = _WinAPI_GetSystemMetrics($SM_CXVIRTUALSCREEN) Global $CANVAS_HEIGHT = _WinAPI_GetSystemMetrics($SM_CYVIRTUALSCREEN) Global Enum $SET_REGKEY, $SET_ANTIALIAS, $SET_REFRESH, $SET_RAINBOW, $SET_STATIC, $SET_24HOUR, $SET_UB Global $SETTINGS[$SET_UB] = [ 'HKCU\Software\therkSoft\FloatingClock' ] If @Compiled Then If $CmdLine[0] Then Switch StringLeft($CmdLine[1], 2) Case '/p' If $CmdLine[0] > 1 Then _PreviewSaver($CmdLine[2]) ElseIf StringTrimLeft($CmdLine[1], 3) Then _PreviewSaver(StringTrimLeft($CmdLine[1], 3)) Else Exit EndIf Case '/s' _Singleton('FloatingClock.main') _MainSaver() Case Else _Config() EndSwitch Else _Config() EndIf Else _Config() GUIDelete() Sleep(500) _MainSaver() EndIf Func _Config() _LoadSettings() Local $iStaticColorSel Local $hGUIConfig = GUICreate('Floating Clock Config', 210, 160, Default, Default, BitOR($WS_CAPTION, $WS_POPUP, $WS_SYSMENU)) GUICtrlCreateGroup('Text color:', 5, 5, 200, 50) Local $ra_RainbowColor = GUICtrlCreateRadio('Rainbow', 25, 25, 70, 20) If $SETTINGS[$SET_RAINBOW] Then GUICtrlSetState(-1, $GUI_CHECKED) Local $ra_StaticColor = GUICtrlCreateRadio('Static: ', 100, 25, 50, 20) If Not $SETTINGS[$SET_RAINBOW] Then GUICtrlSetState(-1, $GUI_CHECKED) Local $bt_StaticColor = GUICtrlCreateButton('', 150, 25, 30, 20) GUICtrlSetBkColor(-1, $SETTINGS[$SET_STATIC]) Local $ch_AntiAlias = GUICtrlCreateCheckbox('Anti-alias text', 5, 60, 100, 20) If $SETTINGS[$SET_ANTIALIAS] Then GUICtrlSetState(-1, $GUI_CHECKED) Local $ch_24Hour = GUICtrlCreateCheckbox('24 hour clock', 105, 60, 100, 20) If $SETTINGS[$SET_24HOUR] Then GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateLabel('Animation refresh rate:', 5, 85, 110, 20, $SS_CENTERIMAGE) Local $in_Refresh = GUICtrlCreateInput($SETTINGS[$SET_REFRESH], 115, 85, 30, 20, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER, $ES_RIGHT)) GUICtrlCreateLabel(' (ms)', 145, 85, 25, 20, $SS_CENTERIMAGE) Local $bt_OK = GUICtrlCreateButton('OK', 80, 115, 60, 25) GUICtrlSetState(-1, $GUI_DEFBUTTON) Local $bt_Cancel = GUICtrlCreateButton('Cancel', 145, 115, 60, 25) GUICtrlCreateLabel(' Version: ' & FileGetVersion(@ScriptFullPath) & ' ', 0, 145, 210, 15, BitOR($SS_SUNKEN, $SS_CENTERIMAGE, 0)) GUICtrlSetFont(-1, 7) GUISetState() While 1 Local $iGM = GUIGetMsg() Switch $iGM Case $bt_StaticColor ControlClick($hGUIConfig, '', $ra_StaticColor) $iStaticColorSel = _ChooseColor(2, $SETTINGS[$SET_STATIC], 2, $hGUIConfig) If $iStaticColorSel <> -1 Then $SETTINGS[$SET_STATIC] = $iStaticColorSel GUICtrlSetBkColor($bt_StaticColor, $SETTINGS[$SET_STATIC]) EndIf Case $bt_OK $SETTINGS[$SET_REFRESH] = Int(GUICtrlRead($in_Refresh)) If $SETTINGS[$SET_REFRESH] < 0 Then $SETTINGS[$SET_REFRESH] = 1 $SETTINGS[$SET_ANTIALIAS] = 0 If BitAND(GUICtrlRead($ch_AntiAlias), $GUI_CHECKED) Then $SETTINGS[$SET_ANTIALIAS] = 1 $SETTINGS[$SET_RAINBOW] = 0 If BitAND(GUICtrlRead($ra_RainbowColor), $GUI_CHECKED) Then $SETTINGS[$SET_RAINBOW] = 1 $SETTINGS[$SET_24HOUR] = 0 If BitAND(GUICtrlRead($ch_24Hour), $GUI_CHECKED) Then $SETTINGS[$SET_24HOUR] = 1 RegWrite($SETTINGS[$SET_REGKEY], 'Refresh', 'REG_DWORD', $SETTINGS[$SET_REFRESH]) RegWrite($SETTINGS[$SET_REGKEY], 'AntiAlias', 'REG_DWORD', $SETTINGS[$SET_ANTIALIAS]) RegWrite($SETTINGS[$SET_REGKEY], 'Rainbow', 'REG_DWORD', $SETTINGS[$SET_RAINBOW]) RegWrite($SETTINGS[$SET_REGKEY], 'Static', 'REG_DWORD', $SETTINGS[$SET_STATIC]) RegWrite($SETTINGS[$SET_REGKEY], '24Hour', 'REG_DWORD', $SETTINGS[$SET_24HOUR]) ExitLoop Case $bt_Cancel, $GUI_EVENT_CLOSE Exit EndSwitch WEnd EndFunc Func _PreviewSaver($iHandle) While WinExists('[CLASS:AutoIt v3 GUI; TITLE:FloatingClock.preview]') WinClose('[last]') WEnd _LoadSettings() Global $hWndCanvas = HWnd($iHandle) Local $aWinPos = WinGetPos($hWndCanvas) If @error Then Exit $CANVAS_WIDTH = $aWinPos[2] $CANVAS_HEIGHT = $aWinPos[3] $PROX_RADIUS = 10 Global $IS_PREVIEW = $hWndCanvas _Setup() AdlibRegister('_DrawingProcess', $SETTINGS[$SET_REFRESH]) GUICreate('FloatingClock.preview', 400, 100) Local $iParentProc = _WinAPI_GetParentProcess(@AutoItPID), $aChildProcs While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch $aChildProcs = _WinAPI_EnumChildProcess($iParentProc) If Not @error And $aChildProcs[0][0] > 1 Then Exit WEnd EndFunc Func _MainSaver() _LoadSettings() Global $hWndCanvas = GUICreate('', $CANVAS_WIDTH, $CANVAS_HEIGHT, $CANVAS_X, $CANVAS_Y, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) GUISetCursor(16, 1) _Setup() Sleep(500) GUISetState(@SW_SHOW) AdlibRegister('_DrawingProcess', $SETTINGS[$SET_REFRESH]) While 1 Sleep(10000) WEnd EndFunc Func _Setup() _GDIPlus_Startup() Global Const $hDC = _WinAPI_GetWindowDC($hWndCanvas) Global Const $hDC_backbuffer = _WinAPI_CreateCompatibleDC($hDC) Global Const $hBitmap_backbuffer = _WinAPI_CreateCompatibleBitmap($hDC, $CANVAS_WIDTH, $CANVAS_HEIGHT) Global Const $DC_obj = _WinAPI_SelectObject($hDC_backbuffer, $hBitmap_backbuffer) Global Const $hBackbuffer = _GDIPlus_GraphicsCreateFromHDC($hDC_backbuffer) If $SETTINGS[$SET_ANTIALIAS] Then _GDIPlus_GraphicsSetTextRenderingHint($hBackbuffer, 4) ; Anti-alias font? Global Const $hBrush_Clear = _GDIPlus_BrushCreateSolid(0xFF000000) Global Const $hBrush_Draw = _GDIPlus_BrushCreateSolid(BitOR(0xFF000000, $SETTINGS[$SET_STATIC])) Global Const $hPen_Draw = _GDIPlus_PenCreate(0xFFFFFFFF) Global Const $hFormat = _GDIPlus_StringFormatCreate(0x4004) _GDIPlus_StringFormatSetAlign($hFormat, 0) Global Const $hFamily = _GDIPlus_FontFamilyCreate('Arial') Global Const $hFont = _GDIPlus_FontCreate($hFamily, $CANVAS_HEIGHT / 8, 0) Global Const $tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0) OnAutoItExitRegister('_Exit') Local $colon = _GDIPlus_GraphicsMeasureString($hBackbuffer, ':', $hFont, $tLayout, $hFormat) $TEXT_HEIGHT = DllStructGetData($colon[0], 'Height') $colon = DllStructGetData($colon[0], 'Width') Local $num = _GDIPlus_GraphicsMeasureString($hBackbuffer, '8', $hFont, $tLayout, $hFormat) $num = DllStructGetData($num[0], 'Width') $TEXT_WIDTH = ($colon * 2 + $num * 5) * 0.6 + $num $TARGET_FOLLOW[$TG_X] = Random(0, $CANVAS_WIDTH - $TEXT_WIDTH, 1) $TARGET_FOLLOW[$TG_Y] = Random(0, $CANVAS_HEIGHT - $TEXT_HEIGHT, 1) $TARGET_FOLLOW[$TG_X] = ($CANVAS_WIDTH - $TEXT_WIDTH) / 2 $TARGET_FOLLOW[$TG_Y] = ($CANVAS_HEIGHT - $TEXT_HEIGHT) / 2 For $i = 0 To 7 $TIME_PIECES[$i][$TP_X] = ($CANVAS_WIDTH - $num) / 2 $TIME_PIECES[$i][$TP_Y] = ($CANVAS_HEIGHT - $TEXT_HEIGHT) / 2 Next _TargetRandomize() _GDIPlus_GraphicsFillRect($hBackbuffer, 0, 0, $CANVAS_WIDTH, $CANVAS_HEIGHT, $hBrush_Clear) EndFunc Func _DrawingProcess() If Not $IS_PREVIEW Then If _WinAPI_GetIdleTime() < 500 Then _Exit() Else If Not WinExists($IS_PREVIEW) Then _Exit() EndIf _TargetFollowing() _TimePieceMove() _WinAPI_BitBlt($hDC, 0, 0, $CANVAS_WIDTH, $CANVAS_HEIGHT, $hDC_backbuffer, 0, 0, $SRCCOPY) ; Copy buffer to main EndFunc Func _TargetRandomize() Global $TARGET_RANDOM[2] = [ Random(0, $CANVAS_WIDTH - $TEXT_WIDTH, 1), Random(0, $CANVAS_HEIGHT - $TEXT_HEIGHT, 1) ] EndFunc Func _TargetFollowing() Local $xDiff = $TARGET_RANDOM[$TG_X] - $TARGET_FOLLOW[$TG_X] Local $yDiff = $TARGET_RANDOM[$TG_Y] - $TARGET_FOLLOW[$TG_Y] If Sqrt($xDiff ^ 2 + $yDiff ^ 2) < $PROX_RADIUS Then _TargetRandomize() EndIf $TARGET_FOLLOW[$TG_XVEL] += $xDiff * $TARGET_SPEED /1000 $TARGET_FOLLOW[$TG_YVEL] += $yDiff * $TARGET_SPEED /1000 If ($xDiff < 0 And $TARGET_FOLLOW[$TG_XVEL] > 0) Or ($xDiff > 0 And $TARGET_FOLLOW[$TG_XVEL] < 0) Then $TARGET_FOLLOW[$TG_XVEL] /= $VELOC_DECAY EndIf If ($yDiff < 0 And $TARGET_FOLLOW[$TG_YVEL] > 0) Or ($yDiff > 0 And $TARGET_FOLLOW[$TG_YVEL] < 0) Then $TARGET_FOLLOW[$TG_YVEL] /= $VELOC_DECAY EndIf $TARGET_FOLLOW[$TG_X] += $TARGET_FOLLOW[$TG_XVEL] $TARGET_FOLLOW[$TG_Y] += $TARGET_FOLLOW[$TG_YVEL] If $TARGET_FOLLOW[$TG_X] > $CANVAS_WIDTH - $TEXT_WIDTH And $TARGET_FOLLOW[$TG_XVEL] > 0 Then $TARGET_FOLLOW[$TG_XVEL] *= -1 $TARGET_FOLLOW[$TG_X] = $CANVAS_WIDTH - $TEXT_WIDTH ElseIf $TARGET_FOLLOW[$TG_X] < 0 And $TARGET_FOLLOW[$TG_XVEL] < 0 Then $TARGET_FOLLOW[$TG_XVEL] *= -1 $TARGET_FOLLOW[$TG_X] = 0 EndIf If $TARGET_FOLLOW[$TG_Y] > $CANVAS_HEIGHT - $TEXT_HEIGHT And $TARGET_FOLLOW[$TG_YVEL] > 0 Then $TARGET_FOLLOW[$TG_YVEL] *= -1 $TARGET_FOLLOW[$TG_Y] = $CANVAS_HEIGHT - $TEXT_HEIGHT ElseIf $TARGET_FOLLOW[$TG_Y] < 0 And $TARGET_FOLLOW[$TG_YVEL] < 0 Then $TARGET_FOLLOW[$TG_YVEL] *= -1 $TARGET_FOLLOW[$TG_Y] = 0 EndIf EndFunc Func _TimePieceMove() Local $iHour = Int(@HOUR) If Not $SETTINGS[$SET_24HOUR] Then If $iHour = 0 Then $iHour = 12 If $iHour > 12 Then $iHour -= 12 EndIf Local $sTimeString = StringFormat('%2s:%02d:%02d', $iHour, @MIN, @SEC) $TIME_STRING = StringSplit($sTimeString, '', 2) If UBound($TIME_STRING) <> 8 Then AdlibUnRegister('_DrawingProcess') MsgBox(0x42010, 'Error parsing time string.', '$sTimeString = "' & $sTimeString & '" (' & StringLen($sTimeString) & ')') Exit EndIf ; Clear previous drawing For $idx = 0 To 7 _GDIPlus_GraphicsFillRect($hBackbuffer, $TIME_PIECES[$idx][$TP_X], $TIME_PIECES[$idx][$TP_Y], $TIME_PIECES[$idx][$TP_W], $TIME_PIECES[$idx][$TP_H], $hBrush_Clear) Next _StringPlace(0, $TARGET_FOLLOW[$TG_X], $TARGET_FOLLOW[$TG_Y]) For $i = 1 To 7 _StringPlace($i, $TIME_PIECES[$i-1][$TP_X] + $TIME_PIECES[$i-1][$TP_W] * 0.6, $TIME_PIECES[$i-1][$TP_Y]) Next EndFunc Func _StringPlace($idx, $x, $y) Local $aHSL[3] = [ 240, 240, 240 ] If $TIME_STRING[$idx] = ' ' Then $TIME_STRING[$idx] = '' $TIME_PIECES[$idx][$TP_CHAR] = $TIME_STRING[$idx] Local $aMeasure = _GDIPlus_GraphicsMeasureString($hBackbuffer, $TIME_PIECES[$idx][$TP_CHAR], $hFont, $tLayout, $hFormat) $TIME_PIECES[$idx][$TP_W] = DllStructGetData($aMeasure[0], 'Width') $TIME_PIECES[$idx][$TP_H] = DllStructGetData($aMeasure[0], 'Height') $TIME_PIECES[$idx][$TP_X] += ($x - $TIME_PIECES[$idx][$TP_X]) * $DRIFT_SPEED /1000 $TIME_PIECES[$idx][$TP_Y] += ($y - $TIME_PIECES[$idx][$TP_Y]) * $DRIFT_SPEED /1000 DllStructSetData($aMeasure[0], 'x', $TIME_PIECES[$idx][$TP_X]) DllStructSetData($aMeasure[0], 'y', $TIME_PIECES[$idx][$TP_Y]) If $SETTINGS[$SET_RAINBOW] Then $aHSL[0] = $TIME_PIECES[$idx][$TP_X] / $CANVAS_WIDTH * 480 $aHSL[2] = 200 - ($TIME_PIECES[$idx][$TP_Y] / $CANVAS_HEIGHT * 160) ; Range: 200-40 top-bottom Local $iBrushColor = _ColorSetRGB(_ColorConvertHSLtoRGB($aHSL)) _GDIPlus_BrushSetSolidColor($hBrush_Draw, 0xFF000000 + $iBrushColor) EndIf _GDIPlus_GraphicsDrawStringEx($hBackbuffer, $TIME_PIECES[$idx][$TP_CHAR], $hFont, $aMeasure[0], $hFormat, $hBrush_Draw) Return $aMeasure[0] EndFunc Func _LoadSettings() $SETTINGS[$SET_ANTIALIAS] = RegRead($SETTINGS[$SET_REGKEY], 'AntiAlias') If @error Then $SETTINGS[$SET_ANTIALIAS] = 1 $SETTINGS[$SET_REFRESH] = RegRead($SETTINGS[$SET_REGKEY], 'Refresh') If @error Then $SETTINGS[$SET_REFRESH] = 10 $SETTINGS[$SET_RAINBOW] = RegRead($SETTINGS[$SET_REGKEY], 'Rainbow') If @error Then $SETTINGS[$SET_RAINBOW] = 1 $SETTINGS[$SET_STATIC] = RegRead($SETTINGS[$SET_REGKEY], 'Static') If @error Then $SETTINGS[$SET_STATIC] = 0xffffff $SETTINGS[$SET_24HOUR] = RegRead($SETTINGS[$SET_REGKEY], '24Hour') If @error Then $SETTINGS[$SET_24HOUR] = 1 EndFunc Func _Exit() _GDIPlus_GraphicsFillRect($hBackbuffer, 0, 0, $CANVAS_WIDTH, $CANVAS_HEIGHT, $hBrush_Clear) _WinAPI_BitBlt($hDC, 0, 0, $CANVAS_WIDTH, $CANVAS_HEIGHT, $hDC_backbuffer, 0, 0, $SRCCOPY) ; Copy buffer to main AdlibUnRegister('_DrawingProcess') _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hBrush_Draw) _GDIPlus_GraphicsDispose($hBackbuffer) _WinAPI_SelectObject($hDC, $DC_obj) _WinAPI_DeleteDC($hDC_backbuffer) _WinAPI_DeleteObject($hBitmap_backbuffer) _WinAPI_ReleaseDC($hWndCanvas, $hDC) _GDIPlus_Shutdown() Exit EndFunc
    1 point
  7. UEZ

    Floating Clock Screensaver

    It can be that _WinAPI_GetSystemMetrics() is not dpi aware. Then you will get wrong values. Currently I cannot test multi monitor with different dpi settings.
    1 point
  8. So I did encounter a problem, @UEZ. When triggered manually everything worked fine, but when triggered by the system AutoIt can't find the "Program Manager" window. So I grabbed the dimensions using _WinAPI_GetSystemMetrics instead.
    1 point
  9. The display is not performed correctly : #include <GUIConstants.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <WinAPI.au3> HotKeySet("{END}", "Quit") OnAutoItExitRegister("CleanUp") Global $hImage, $GFC, $iInd = 0 Global $hGUI = GUICreate("", 400, 500, -1, -1, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOPMOST) GUISetBkColor(0x00FFFF) Global $IMG_Ctrl = GUICtrlCreatePic("", 10, 10, -1, -1, -1, $GUI_WS_EX_PARENTDRAG) _WinAPI_SetLayeredWindowAttributes($hGUI, 0x00FFFF) GifInit() AdlibRegister (_Draw_Timer, 80) GUISetState(@SW_SHOW) While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then Quit() WEnd Func _Draw_Timer() If $iInd = $GFC Then $iInd = 0 GifDrawFrame($iInd) $iInd += 1 EndFunc ;==>_Draw_Timer Func Quit() Exit EndFunc ;==>Quit Func CleanUp() _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() EndFunc ;==>CleanUp Func GifInit() _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\xmas tree.gif") $GFC = _GDIPlus_ImageGetFrameCount($hImage, $GDIP_FRAMEDIMENSION_TIME) EndFunc ;==>GifInit Func GifDrawFrame($i) _GDIPlus_ImageSelectActiveFrame($hImage, $GDIP_FRAMEDIMENSION_TIME, $i) Local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _SetBitmapToCtrl($IMG_Ctrl, $hBitmap) _WinAPI_DeleteObject($hBitmap) EndFunc ;==>GifDrawFrame Func _SetBitmapToCtrl($CtrlId, $hBitmap) Local $hWnd = GUICtrlGetHandle($CtrlId) If $hWnd = 0 Then Return SetError(1, 0, 0) Local $hPrev = _SendMessage($hWnd, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap) If @error Then Return SetError(2, 0, 0) If $hPrev Then _WinAPI_DeleteObject($hPrev) Return 1 EndFunc ;==>_SetBitmapToCtrl xmas tree.zip
    1 point
  10. Melba23

    Daniel_FUD

    This (now ex)member has gained an unfortunate reputation on other fora of asking for help via PM and attaching a script which, when run, tries to steal your account information/credentials, etc for a whole list of applications before sending them to the OP. If you have received a PM from this (ex)member asking for help with a script DO NOT RUN IT - just delete the PM and/or the downloaded script ASAP. M23
    1 point
  11. Nine

    Advanced login form

    With my code, I see the changes occurring in the fields. If you want to set value like you did, you need to fire events : $oObject.fireEvent("OnChange") $oObject.fireEvent("OnClick")
    1 point
  12. A simpler way, if it's okay for you to set a property value by passing "strings" to a function instead of using a single string in an Execute () statement, then you can use a "magic" way provided by a magical girl, @trancexx, published at this link: here I simply wrapped his magic potion within this function: Func _SetProperty($oObj, $sProperty, $vData) ; by Trancexx ; https://www.autoitscript.com/forum/topic/200129-set-object-properties-with-propertyname-and-value-taken-from-an-array/?do=findComment&comment=1436379 ; Some constants used in code Const $tagIUnknown = "QueryInterface hresult(ptr;ptr*);" & _ "AddRef dword();" & _ "Release dword();" Const $tagIDispatch = $tagIUnknown & _ "GetTypeInfoCount hresult(dword*);" & _ "GetTypeInfo hresult(dword;dword;ptr*);" & _ "GetIDsOfNames hresult(struct*;struct*;dword;dword;struct*);" & _ "Invoke hresult(uint;struct*;dword;word;struct*;struct*;ptr;uint*);" Const $DISPID_PROPERTYPUT = -3 Const $DISPATCH_PROPERTYPUT = 4 Const $LOCALE_SYSTEM_DEFAULT = 0x800 Const $tIID_NULL = DllStructCreate("byte[16]") Const $tagDISPPARAMS = "ptr rgvarg;ptr rgdispidNamedArgs;uint cArgs;uint cNamedArgs;" Const $VT_I4 = 3 Const $tVARIANT = "word vt;word r1;word r2;word r3;ptr data; ptr" Const $sIID_IDispatch = "{00020400-0000-0000-C000-000000000046}" ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ; Superposed object on top of the original one Local $oObjMy = ObjCreateInterface($oObj, $sIID_IDispatch, $tagIDispatch, False) ; Collect ID number of the function/property/method, whatever $tDisp = DllStructCreate("dword") $tName = DllStructCreate("ptr") $tN = DllStructCreate("wchar[" & StringLen($sProperty) + 1 & "]") DllStructSetData($tN, 1, $sProperty) DllStructSetData($tName, 1, DllStructGetPtr($tN)) $oObjMy.GetIDsOfNames($tIID_NULL, $tName, 1, $LOCALE_SYSTEM_DEFAULT, $tDisp) ; Tadaaa! $iDispId = DllStructGetData($tDisp, 1) ; Now build disp parameters $tDISPPARAMS = DllStructCreate($tagDISPPARAMS) $tDISPPARAMS.cNamedArgs = 1 $tDispidNamed = DllStructCreate("uint") DllStructSetData($tDispidNamed, 1, $DISPID_PROPERTYPUT) $tDISPPARAMS.rgdispidNamedArgs = DllStructGetPtr($tDispidNamed) $tDISPPARAMS.cArgs = 1 $tVar = DllStructCreate($tVARIANT) $tDISPPARAMS.rgvarg = DllStructGetPtr($tVar) ; Set desired value $tVar.vt = $VT_I4 $tVar.data = $vData ; And call it $iRet = $oObjMy.Invoke($iDispId, $tIID_NULL, 0x800, $DISPATCH_PROPERTYPUT, $tDISPPARAMS, 0, 0, 0) Return (Hex($iRet, 8)) ; ConsoleWrite(">>> Returned hresult = " & Hex($iRet, 8) & @CRLF) ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< EndFunc ;==>_SetProperty here an example of use: https://www.autoitscript.com/forum/topic/200129-set-object-properties-with-propertyname-and-value-taken-from-an-array/?do=findComment&comment=1436386
    1 point
  13. Since I have this extra post here I'll go into some of the details As you recall (or maybe you have no idea) Begee's original code only updated one point on each graph redraw This lead to some pretty high CPU usage if you wanted to add lots of points My idea was to allow adding multiple points before redrawing the graph.......
    1 point
  14. Use GUICtrlRead to get the state of the checkbox and execute the respective function is they are checked #include <GUIConstants.au3> Global $frmMain = GUICreate("Test", 300, 200) Global $inpInput = GUICtrlCreateInput("", 10, 10, 280, 20) Global $chkMsgBox = GUICtrlCreateCheckbox("MsgBox('', '', 'Inputbox')", 10, 35, 280) Global $chkShellExecute = GUICtrlCreateCheckbox("ShellExecute('Inputbox')", 10, 55, 280) Global $btnRun = GUICtrlCreateButton("Run Test", 10, 80, 280, 20) Global $bExecuteMsgBox = False Global $bExecuteShell = False GUISetState(@SW_SHOW, $frmMain) ; Option 1 While (1) Switch (GUIGetMsg()) Case $GUI_EVENT_CLOSE Exit Case $btnRun Local $sData = GUICtrlRead($inpInput) If ($bExecuteShell) Then ShellExecute($sData) If ($bExecuteMsgBox) Then MsgBox("", "", $sData) Case $chkMsgBox $bExecuteMsgBox = Not $bExecuteMsgBox Case $bExecuteShell $bExecuteShell = Not $bExecuteShell EndSwitch WEnd ; Option 2 While (1) Switch (GUIGetMsg()) Case $GUI_EVENT_CLOSE Exit Case $btnRun Local $sData = GUICtrlRead($inpInput) If (GUICtrlRead($chkShellExecute) = $GUI_CHECKED) Then ShellExecute($sData) If (GUICtrlRead($chkMsgBox) = $GUI_CHECKED) Then MsgBox("", "", $sData) EndSwitch WEnd
    1 point
  15. If $variableA <> $variableB Then ...The relevant docu can be found here.
    1 point
  16. grasshopper3, You could do it like this: #include <GUIConstantsEx.au3> Global $aControlID[4] ; Set this to match the number of controls Global $sIniFile = @ScriptDir & "\Test.ini" $hGUI = GUICreate("Test", 500, 500) ; Create the control $hInput_A = GUICtrlCreateInput("", 10, 10, 200, 20) ; And save the ControlID in the Array $aControlID[0] = $hInput_A $hInput_B = GUICtrlCreateInput("", 10, 50, 200, 20) $aControlID[1] = $hInput_B $hInput_C = GUICtrlCreateInput("", 10, 90, 200, 20) $aControlID[2] = $hInput_C $hInput_D = GUICtrlCreateInput("", 10, 130, 200, 20) $aControlID[3] = $hInput_D ; Loop through the array to set the saved values For $i = 0 To 3 GUICtrlSetData($aControlID[$i], IniRead($sIniFile, "Data", $i, "Not found")) Next GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ; Loop through the array to save the current values For $i = 0 To 3 IniWrite($sIniFile, "Data", $i, GUICtrlRead($aControlID[$i])) Next Exit EndSwitch WEnd You coudl also put the ControlIDs directly into the array as the controls are created, but then you would have to remember which array element was which control. I think the code above is the best compromise - you get nice easy to use variables in your script and an array to loop through when needed. All clear? M23
    1 point
×
×
  • Create New...