Jump to content

Recommended Posts

Two things.

1) I want to make a transparent, ontop, window that I can draw on and click through so that I din't have to redraw constantly such as when I use the hwnd/hDC of another window.

2) How can I set an autoit gui as a child of a non-autoit window?

I saw mention of how to do #1 somewhere but I can't find it again.

Link to comment
Share on other sites

_WinAPI_SetLayeredWindowAttributes() & _WinAPI_SetParent() & look at this >>

Also please don't bump your threads less than 24 hours.

Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

maybe something in here will help? I was working on this to add a gun scope option to a game I was making. it works fine in xp but seems to be having some issue with my win 7 64 bit now. (I haven't touched this code in a long time)

#include <Misc.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <WinAPIEx.au3>
$dll = DllOpen("user32.dll")
Global $hParent, $hForm, $Pos, $hBitmap = 0, $Go = 1, $XPrev = MouseGetPos(0), $YPrev = MouseGetPos(1)
Global $hDC, $hMemDC, $hSv, $pBlend, $tBlend, $pSize, $tSize, $pSource, $tSource, $hWnd,$iX,$iY,$iHeight
Global $scope = 0
;$Cursor="E:\Shawns_Stuff\Terisi_PF\data\cross_l.cur"
;$CursorBack = 'E:\Shawns_Stuff\Terisi_PF\data\arrow_m.cur'
$hParent = GUICreate('', -1, -1, -1, -1, -1, BitOR($WS_EX_LAYERED,$WS_EX_TOOLWINDOW,$WS_EX_TRANSPARENT ))
$hForm = GUICreate('', 150, 150, $XPrev + 25, $YPrev + 25, BitOR($WS_DISABLED, $WS_POPUPWINDOW), BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST,$WS_EX_TRANSPARENT ), $hParent)
GUISetState(@SW_HIDE, $hForm)
While 1
 If _IsPressed("1B", $dll) Then
  ;$cDll = DllCall($dll, "hwnd", "LoadCursorFromFile", "str", $CursorBack)
  ;DllCall($dll, "int", "SetSystemCursor", "int", $cDll[0], "int", 32512)
  DllClose($dll)
  Exit (1)
 EndIf
 If _IsPressed("5A", $dll) And $scope = 0 Then
  ;$cDll = DllCall($dll, "hwnd", "LoadCursorFromFile", "str", $Cursor)
  ;DllCall($dll, "int", "SetSystemCursor", "int", $cDll[0], "int", 32512)
  $scope = 1
  Sleep(500)
 EndIf
 If _IsPressed("5A", $dll) And $scope = 1 Then
  ;$cDll = DllCall($dll, "hwnd", "LoadCursorFromFile", "str", $CursorBack)
  ;DllCall($dll, "int", "SetSystemCursor", "int", $cDll[0], "int", 32512)
  $scope = 0
  GUISetState(@SW_HIDE, $hForm)
  Sleep(500)
 EndIf
 If $scope = 1 Then
  GUISetState(@SW_SHOWNOACTIVATE, $hForm)
  $Pos = MouseGetPos()
  If ($Go) Or ($Pos[0] <> $XPrev) Or ($Pos[1] <> $YPrev) Then
   WinMove($hForm, '', $Pos[0] - 75, $Pos[1] - 75)
   _Capture($Pos[0] - 25, $Pos[1] - 25, 50, 50)
   $XPrev = $Pos[0]
   $YPrev = $Pos[1]
   $Go = 0
  EndIf
  _Capture($Pos[0] - 25, $Pos[1] - 25, 50, 50)
 EndIf
WEnd
Func _Capture($iX, $iY, $iWidth, $iHeight)
 Local $tRect, $hDC, $hMemDC, $hScreenshort = _ScreenCapture($iX, $iY, $iWidth, $iHeight)
 _WinAPI_FreeObject($hBitmap)
 $hBitmap = _WinAPI_FitToBitmap($hScreenshort, 150, 150)
 _WinAPI_FreeObject($hScreenshort)
 $hDC = _WinAPI_GetDC($hForm)
 $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
 _WinAPI_SelectObject($hMemDC, $hBitmap)
 _WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($NULL_BRUSH))
 _WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($DC_PEN))
 _WinAPI_SetDCPenColor($hMemDC, 0xA00000)
 $aMiniSize = WinGetClientSize($hForm)
 $aMyMiniDC = DLLCall($dll,"int","GetDC","hwnd",$hForm)
   DLLCall("gdi32.dll","int","Arc", "hwnd", $aMyMiniDC[0], _
       "int", 0, "int", 0, "int", $aMiniSize[0], "int", $aMiniSize[1], _
       "int", 0, "int", $aMiniSize[1]/2, "int", 0, "int", $aMiniSize[1]/2)
  DLLCall("gdi32.dll","int","MoveToEx", "hwnd", $aMyMiniDC[0], "int", 0, "int", $aMiniSize[1]/2, "ptr", 0)
  DLLCall("gdi32.dll","int","LineTo", "hwnd", $aMyMiniDC[0], "int", $aMiniSize[0], "int", $aMiniSize[1]/2)
  DLLCall("gdi32.dll","int","MoveToEx", "hwnd", $aMyMiniDC[0], "int", $aMiniSize[0]/2, "int", 0, "ptr", 0)
  DLLCall("gdi32.dll","int","LineTo", "hwnd", $aMyMiniDC[0], "int", $aMiniSize[0]/2, "int", $aMiniSize[1])
 _WinAPI_DrawLine($hMemDC, 150, 75, -150, 75)
 _WinAPI_DrawLine($hMemDC, 75, 150, 75, -150)
 _WinAPI_DrawLine($hMemDC, 70, 65, 80, 65)
 _WinAPI_DrawLine($hMemDC, 85, 70, 85, 80)
 _WinAPI_DrawLine($hMemDC, 70, 85, 80, 85)
 _WinAPI_DrawLine($hMemDC, 65, 70, 65, 80)
 _WinAPI_DrawLine($hMemDC, 65, 50, 85, 50)
 _WinAPI_DrawLine($hMemDC, 100, 65, 100, 85)
 _WinAPI_DrawLine($hMemDC, 65, 100, 85, 100)
 _WinAPI_DrawLine($hMemDC, 50, 65, 50, 85)
 _WinAPI_DrawLine($hMemDC, 60, 35, 90, 35)
 _WinAPI_DrawLine($hMemDC, 115, 60, 115, 90)
 _WinAPI_DrawLine($hMemDC, 60, 115, 90, 115)
 _WinAPI_DrawLine($hMemDC, 35, 60, 35, 90)
 _WinAPI_ReleaseDC($hForm, $hDC)
 _WinAPI_DeleteDC($hMemDC)
 _SetBitmap($hForm, $hBitmap, 254)
EndFunc   ;==>_Capture
Func _ScreenCapture($iX, $iY, $iWidth, $iHeight)
 Local $hWnd, $hDC, $hMemDC, $hBitmap
 $hWnd = _WinAPI_GetDesktopWindow()
 $hDC = _WinAPI_GetDC($hWnd)
 $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
 $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight)
 _WinAPI_SelectObject($hMemDC, $hBitmap)
 _WinAPI_BitBlt($hMemDC, 0, 0, $iWidth, $iHeight, $hDC, $iX, $iY, $MERGECOPY)
 _WinAPI_ReleaseDC($hWnd, $hDC)
 _WinAPI_DeleteDC($hMemDC)
 Return $hBitmap
EndFunc   ;==>_ScreenCapture
Func _SetBitmap($hWnd, $hBitmap, $iOpacity)
 $hDC = _WinAPI_GetDC($hWnd)
 $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
 $hSv = _WinAPI_SelectObject($hMemDC, $hBitmap)
 $tSize = _WinAPI_GetBitmapDimension($hBitmap)
 $pSize = DllStructGetPtr($tSize)
 $tSource = DllStructCreate($tagPOINT)
 $pSource = DllStructGetPtr($tSource)
 $tBlend = DllStructCreate($tagBLENDFUNCTION)
 $pBlend = DllStructGetPtr($tBlend)
 DllStructSetData($tBlend, 'Alpha', $iOpacity)
 DllStructSetData($tBlend, 'Format', 0)
 _WinAPI_UpdateLayeredWindow($hWnd, $hDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
 _WinAPI_ReleaseDC($hWnd, $hDC)
 _WinAPI_SelectObject($hMemDC, $hSv)
 _WinAPI_DeleteDC($hMemDC)
EndFunc   ;==>_SetBitmap

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...