Gianni Posted January 8, 2023 Share Posted January 8, 2023 This simple code snippet simulates a writing hand as you type into any input field (hand follows caret) P.S. I don't know what it's for, but I'll post it anyway. .... One possible use would be to draw attention to a message. (such as what I posted here: https://www.autoitscript.com/forum/topic/209396-3202-sraey-wen-yppah/?do=findComment&comment=1510993) Have fun expandcollapse popup#include <GUIConstants.au3> #include <GDIPlus.au3> Global $iWidth = 100, $iHeight = 70, $iPosX = -1, $iPosY = -1, $aCaretPos, $msg Global $iHandMoves = 2, $iAmplitude = 5, $iHideHidleDelay = 1000, $iFlag = True, $iTimer Global Const $hGUI = GUICreate('', $iWidth, $iHeight, $iPosX, $iPosY, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_NOACTIVATE)) Global Const $idLogo = GUICtrlCreatePic("", 0, 0, $iWidth, $iHeight) _GDIPlus_Startup() Global $Bmp_Logo = _GDIPlus_BitmapCreateFromMemory(_WritingHand(), True) _WinAPI_DeleteObject(GUICtrlSendMsg($idLogo, $STM_SETIMAGE, $IMAGE_BITMAP, $Bmp_Logo)) $Bmp_Logo = '' _GDIPlus_Shutdown() While True $aCaretPos = _WinGetCaretPos() If @extended Then $iTimer = TimerInit() $iFlag = True If Not @error Then GUISetState(@SW_SHOWNOACTIVATE, $hGUI) _MoveHand($aCaretPos) EndIf EndIf If $iFlag And (TimerDiff($iTimer) > $iHideHidleDelay) Then GUISetState(@SW_HIDE, $hGUI) $iFlag = False EndIf Sleep(250) WEnd Func _MoveHand($aCaretPos) For $i = 1 To $iHandMoves WinMove($hGUI, '', $aCaretPos[0] + Random(-$iAmplitude, $iAmplitude, 1), $aCaretPos[1] + Random(-$iAmplitude, $iAmplitude, 1), Default, Default, 1) Next WinMove($hGUI, '', $aCaretPos[0], $aCaretPos[1]) EndFunc ;==>_MoveHand ; A more reliable method to retrieve the caret coordinates in MDI Func _WinGetCaretPos() Local Static $iXAdjust = -5, $iYAdjust = -5, $aPrevPos[2] = [0, 0] Local $iOpt = Opt("CaretCoordMode", 0) ; Set "CaretCoordMode" to relative mode and store the previous option. Local $aGetCaretPos = WinGetCaretPos() ; Retrieve the relative caret coordinates. Local $aGetPos = WinGetPos("[ACTIVE]") ; Retrieve the position as well as height and width of the active window. Local $sControl = ControlGetFocus("[ACTIVE]") ; Retrieve the control name that has keyboard focus. Local $aControlPos = ControlGetPos("[ACTIVE]", "", $sControl) ; Retrieve the position as well as the size of the control. $iOpt = Opt("CaretCoordMode", $iOpt) ; Reset "CaretCoordMode" to the previous option. Local $aReturn[2] = [0, 0] ; Create an array to store the x, y position. If IsArray($aGetCaretPos) And IsArray($aGetPos) And IsArray($aControlPos) Then $aReturn[0] = $aGetCaretPos[0] + $aGetPos[0] + $aControlPos[0] + $iXAdjust $aReturn[1] = $aGetCaretPos[1] + $aGetPos[1] + $aControlPos[1] + $iYAdjust ; Check if caret has moved If ($aReturn[0] <> $aPrevPos[0]) Or ($aReturn[1] <> $aPrevPos[1]) Then $aPrevPos[0] = $aReturn[0] $aPrevPos[1] = $aReturn[1] SetError(0, 1) ; if caret has moved set @Extended EndIf Return $aReturn ; Return the array Else Return SetError(1, 0, $aReturn) ; Return the array and set @error to 1. EndIf EndFunc ;==>_WinGetCaretPos ;Code below was generated by: 'File to Base64 String' Code Generator v1.20 Build 2020-06-05 Func _WritingHand($bSaveBinary = False, $sSavePath = @ScriptDir) Local $WritingHand $WritingHand &= 'R0lGODlhZABGAHAAACH5BAEAAP8ALAAAAABkAEYAhwAAAAAAMwAAZgAAmQAAzAAA/wArAAArMwArZgArmQArzAAr/wBVAABVMwBVZgBVmQBVzABV/wCAAACAMwCAZgCAmQCAzACA/wCqAACqMwCqZgCqmQCqzACq/wDVAADVMwDVZgDVmQDVzADV/wD/AAD/MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMrADMrMzMrZjMrmTMrzDMr/zNVADNVMzNVZjNVmTNVzDNV/zOAADOAMzOAZjOAmTOAzDOA/zOqADOqMzOqZjOqmTOqzDOq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cP51eqDimsW/OC1okV0iBG7KE0Vj0Y4vmGRixWU2+bMNCAXltCBMGFfnpzUrHlpbBFQAtwYO5Y1GbYEi5OQWAhZyMZaSMmNDdwa91oisSUN8IZSzI2kDMa8/6EPjvbzISPhxsU8Rik0JMTeMrRnFMp9UJMrU6EUwRglSfZpLs3LWs7k4pie8aIXF8NYHdHES/TocI+AggZnFKktltjSlhibIhg71CdTLRN4WSMl02qlpEYCEV4yIpiMPOnMWBJDe+mTi/3M+C4m1bGIm0uPqSyZPneUklh0sWYQiVi1RZRQGUtrxxLngoQoVPKiSGXq3w1feMksaUuDx2QSS87ZP6sk8ZusgiNMPmLLcgZUfPQi6DySlEF9Hcl+WHTixJbnrHvOMhmsoqYmbZkJq+ASaMpKouRQypm7geRIyUIlI/d3PZkqMWffVGkc4/jDivbCpwPRxzALFU6E1oWfxhQiFpEqOY5mSqjGPKU1AwIAOw==' Local $bString = _WinAPI_Base64Decode($WritingHand) If @error Then Return SetError(1, 0, 0) Return Binary($bString) EndFunc ;==>_WritingHand Func _WinAPI_Base64Decode($sB64String) Local $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "ptr", 0, "dword*", 0, "ptr", 0, "ptr", 0) If @error Or Not $aCrypt[0] Then Return SetError(1, 0, "") Local $bBuffer = DllStructCreate("byte[" & $aCrypt[5] & "]") $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "struct*", $bBuffer, "dword*", $aCrypt[5], "ptr", 0, "ptr", 0) If @error Or Not $aCrypt[0] Then Return SetError(2, 0, "") Return DllStructGetData($bBuffer, 1) EndFunc ;==>_WinAPI_Base64Decode AutoBert, kurtykurtyboy, noellarkin and 1 other 4 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
taurus905 Posted January 11, 2023 Share Posted January 11, 2023 @Gianni You write some interesting stuff. And that's why I follow you. taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
Gianni Posted January 15, 2023 Author Share Posted January 15, 2023 On 1/11/2023 at 2:56 AM, taurus905 said: @Gianni You write some interesting stuff. And that's why I follow you. taurus905 thanks mate Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
kurtykurtyboy Posted March 17, 2023 Share Posted March 17, 2023 On 1/8/2023 at 1:23 PM, Gianni said: I don't know what it's for, but I'll post it anyway. I don't know either, but I think it's great! Gianni 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now