TrashBoat Posted November 5, 2018 Posted November 5, 2018 After i create my GUI i cant set the color anymore. help? $hBarGUI1 = GUICreate("", 50, 1, 91, 188, 0x80000000, 0x08000080) $g = GUICtrlCreateLabel("", 1, 1, 1, 1) GUICtrlSetBkColor(-1, $color) GUISetBkColor($color, $hBarGUI1) WinSetTrans($hBarGUI1, '', 0) WinSetState($hBarGUI1, '', @SW_SHOWNOACTIVATE) WinMove($hBarGUI1, '', -1, -1) WinSetTrans($hBarGUI1, '', 254) WinSetOnTop($hBarGUI1, "", 1) I see that my problem has to do something with WinSetState but have no clue how to fix it already tried to set it to @SW_UNLOCK and @SW_SHOWNORMAL. @swa
BrewManNH Posted November 5, 2018 Posted November 5, 2018 Post something we can run, this doesn't help anyone in figuring out what is the issue. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
TrashBoat Posted November 5, 2018 Author Posted November 5, 2018 Here u go, the entire script cause im lazy. Spoiler expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <SliderConstants.au3> #include <StaticConstants.au3> #include <Misc.au3> #include <WinAPI.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Crosshair overlay", 346, 474, -1, -1) $Group1 = GUICtrlCreateGroup("Window list", 4, 4, 337, 57) $Combo1 = GUICtrlCreateCombo("", 12, 24, 257, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) $Button1 = GUICtrlCreateButton("Update", 272, 24, 63, 21) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("Crosshairs", 4, 64, 89, 85) $Checkbox1 = GUICtrlCreateCheckbox("Dot", 12, 84, 41, 17) $Checkbox2 = GUICtrlCreateCheckbox("Cross", 12, 104, 49, 17) $Checkbox3 = GUICtrlCreateCheckbox("Big dot", 12, 124, 65, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group3 = GUICtrlCreateGroup("Color", 96, 64, 245, 85) $Label1 = GUICtrlCreateLabel("", 104, 84, 56, 56, $WS_BORDER) GUICtrlSetBkColor(-1, 0xFFFFFF) $Button2 = GUICtrlCreateButton("Change color", 256, 84, 75, 57) $Input1 = GUICtrlCreateInput("0xFFFFFF", 168, 100, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY)) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group4 = GUICtrlCreateGroup("Crosshair settings", 4, 152, 337, 317) $Group5 = GUICtrlCreateGroup("Offsets", 12, 292, 321, 165) $Group7 = GUICtrlCreateGroup("X", 20, 308, 305, 69) $Input3 = GUICtrlCreateInput("0", 32, 336, 37, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY)) $Slider2 = GUICtrlCreateSlider(76, 328, 242, 37) GUICtrlSetLimit(-1, 50, -50) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group8 = GUICtrlCreateGroup("Y", 20, 380, 305, 69) $Input4 = GUICtrlCreateInput("0", 32, 408, 37, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY)) $Slider3 = GUICtrlCreateSlider(72, 400, 246, 37) GUICtrlSetLimit(-1, 50, -50) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group6 = GUICtrlCreateGroup("Alpha", 12, 212, 321, 77) $Input2 = GUICtrlCreateInput("254", 20, 244, 37, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY)) $Slider1 = GUICtrlCreateSlider(64, 236, 258, 37) GUICtrlSetLimit(-1, 254, 0) GUICtrlCreateGroup("", -99, -99, 1, 1) $Button3 = GUICtrlCreateButton("Update postion", 88, 172, 83, 25) $Checkbox4 = GUICtrlCreateCheckbox("Auto-update", 176, 176, 81, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $color = 0xFFFFFF $alpha = 254 Local $oX, $oY, $X, $Y = 0 Local $winPos $title = "" $autoState = False $c1 = False $c2 = False $c3 = False #Region crosshair1 $hBarGUI = GUICreate("", 1, 1, 91, 188, 0x80000000, 0x08000080) GUICtrlCreateLabel("", 1, 1, 1, 1) GUICtrlSetBkColor(-1, $color) GUISetBkColor($color, $hBarGUI) WinSetTrans($hBarGUI, '', 0) WinSetState($hBarGUI, '', @SW_SHOWNOACTIVATE) WinMove($hBarGUI, '', 0, -19) WinSetTrans($hBarGUI, '', 254) WinSetOnTop($hBarGUI, "", 1) _WinAPI_SetWindowLong($hBarGUI, $GWL_EXSTYLE, BitOR(_WinAPI_GetWindowLong($hBarGUI, $GWL_EXSTYLE), $WS_EX_TRANSPARENT)) #EndRegion crosshair1 #Region crosshair2 $hBarGUI1 = GUICreate("", 50, 1, 91, 188, 0x80000000, 0x08000080) $g = GUICtrlCreateLabel("", 1, 1, 1, 1) GUICtrlSetBkColor(-1, $color) GUISetBkColor($color, $hBarGUI1) WinSetTrans($hBarGUI1, '', 0) WinSetState($hBarGUI1, '', @SW_SHOWNOACTIVATE) WinMove($hBarGUI1, '', -1, -1) WinSetTrans($hBarGUI1, '', 254) WinSetOnTop($hBarGUI1, "", 1) _WinAPI_SetWindowLong($hBarGUI1, $GWL_EXSTYLE, BitOR(_WinAPI_GetWindowLong($hBarGUI1, $GWL_EXSTYLE), $WS_EX_TRANSPARENT)) $hBarGUI2 = GUICreate("", 1, 50, 91, 188, 0x80000000, 0x08000080) GUICtrlCreateLabel("", 1, 1, 1, 1) GUICtrlSetBkColor(-1, $color) GUISetBkColor($color, $hBarGUI2) WinSetTrans($hBarGUI2, '', 0) WinSetState($hBarGUI2, '', @SW_SHOWNOACTIVATE) WinMove($hBarGUI2, '', -1, -1) WinSetTrans($hBarGUI2, '', 254) WinSetOnTop($hBarGUI2, "", 1) _WinAPI_SetWindowLong($hBarGUI2, $GWL_EXSTYLE, BitOR(_WinAPI_GetWindowLong($hBarGUI2, $GWL_EXSTYLE), $WS_EX_TRANSPARENT)) #EndRegion crosshair2 While 1 If $autoState Then If $c1 Then _updateInfo() WinMove($hBarGUI, "", $X + $oX, $Y + $oY) EndIf If $c2 Then _updateInfo() WinMove($hBarGUI1, "", $X + $oX - 25, $Y + $oY) WinMove($hBarGUI2, "", $X + $oX, $Y + $oY - 25) EndIf EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 getComboData() Case $Checkbox4 $autoState = Not $autoState Case $Button2 $color = _ChooseColor(2, 0, 2, $Form1) GUICtrlSetData($Input1, $color) GUICtrlSetBkColor($Label1, $color) WinSetState($hBarGUI, '', @SW_SHOWNORMAL) WinSetState($hBarGUI1, '', @SW_SHOWNORMAL) WinSetState($hBarGUI2, '', @SW_SHOWNORMAL) ;~ GUISetBkColor($g, $color) GUISetBkColor($hBarGUI, $color) GUISetBkColor($hBarGUI1, $color) GUISetBkColor($hBarGUI2, $color) WinSetState($hBarGUI, '', @SW_SHOWNOACTIVATE) WinSetState($hBarGUI1, '', @SW_SHOWNOACTIVATE) WinSetState($hBarGUI2, '', @SW_SHOWNOACTIVATE) Case $Slider1 $alpha = GUICtrlRead($Slider1) GUICtrlSetData($Input2, $alpha) Case $Slider2 $oX = GUICtrlRead($Slider2) GUICtrlSetData($Input3, $oX) Case $Slider3 $oY = GUICtrlRead($Slider3) GUICtrlSetData($Input4, $oY) Case $Checkbox1 $c1 = Not $c1 If Not $c1 Then WinSetTrans($hBarGUI, '', 0) Else WinSetTrans($hBarGUI, '', 254) EndIf Case $Checkbox2 $c2 = Not $c2 If Not $c2 Then WinSetTrans($hBarGUI1, '', 0) WinSetTrans($hBarGUI2, '', 0) Else WinSetTrans($hBarGUI1, '', 254) WinSetTrans($hBarGUI2, '', 254) EndIf Case $Checkbox3 $c3 = Not $c3 EndSwitch WEnd Func getComboData() Local $aList = WinList() For $i = 1 To $aList[0][0] If $aList[$i][0] <> "" And BitAND(WinGetState($aList[$i][1]), 2) Then GUICtrlSetData($Combo1, $aList[$i][0]) EndIf Next EndFunc ;==>getComboData Func _updateInfo() $title = GUICtrlRead($Combo1) If $title = "" Then MsgBox(64, "", "Please select a Window") Else $winPos = WinGetPos($title) If IsArray($winPos) Then $X = $winPos[0] + ($winPos[2] / 2) $Y = $winPos[1] + ($winPos[3] / 2) Else MsgBox(64, "", "Cant find window by that name: " & $title & @CRLF & "This might happen then u drag the window!") EndIf EndIf EndFunc ;==>_updateInfo
TrashBoat Posted November 5, 2018 Author Posted November 5, 2018 Tried moving the gui position out of the screen bounds to force it to update the color still didin't change
TrashBoat Posted November 5, 2018 Author Posted November 5, 2018 Maybe there is a simpler way of drawing just the GUI part like that , if there is post it here. Thanks
careca Posted November 5, 2018 Posted November 5, 2018 (edited) Maybe GDI could make this easier no? I mean, 3 GUI to make a crosshair is kinda overkill it seems. Any particular reason why you need 3 windows to form a crosshair? You could, in theory, with gdi do a circle and 2 lines and only have 1 gui, just draw on top of it. EDIT: nvm, i was messing around with it, as the window behind it messes with the graphics, at least if the graphics are drawn directly on top of it. EDIT: here's something to play with if you find it interesting expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** ;#AutoIt3Wrapper_Icon=.ico #AutoIt3Wrapper_UseX64=n ;#AutoIt3Wrapper_Res_Comment=By: ;#AutoIt3Wrapper_Res_Description= #AutoIt3Wrapper_Res_Fileversion=1.1 #AutoIt3Wrapper_Res_SaveSource=y ;#AutoIt3Wrapper_Res_Icon_Add=.ico #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #AutoIt3Wrapper_Run_Tidy=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;============================================================================= #Region ;Include + Opt #include <IE.au3> #include <File.au3> #include <WinAPI.au3> #include <GDIPlus.au3> #include <WinAPIGdi.au3> #include <GuiTreeView.au3> #include <TrayConstants.au3> #include <ScreenCapture.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <AutoItConstants.au3> #include <WindowsConstants.au3> Opt("TrayMenuMode", 3) Opt("TrayIconHide", 0) Opt("GUIResizeMode", 1) Opt("TrayIconDebug", 1) Opt("TrayAutoPause", 0) Opt("MouseCoordMode", 2) Opt("GUIOnEventMode", 1) Opt("MustDeclareVars", 1) Opt("GUIEventOptions", 1) Opt("TrayOnEventMode", 1) Opt("ExpandEnvStrings", 1) Opt("WinDetectHiddenText", 1) #EndRegion ;Include + Opt ;============================================================================= #Region ;GuiVars + FileInstall Global $GUI, $Button_1, $hGraphic, $hGraphic2, $sString, $hFont, $aInfo, $hFormat, $hBrush, $hImage, $hImageR, $hFamily, $tLayout, $IndexDay, $RefreshItem, $wpos Global $ExitItem, $Label, $Label1, $oIE, $oDoc, $oElement1, $oElement2, $StringMid, $Split1, $Split2, $Trim, $Number, $ID, $Pic, $String, $SetString, $CfgFldr, $hPen Global $Day = 0, $WS, $StartWinCheck Global Const $AC_SRC_ALPHA = 1 Global $i_x1 = 0, $i_y1 = 0, $i_x3 = 25, $i_y3 = 25 Global $aMousePos, $aMousePos2, $iMouseOver = 0 Global $aProcessList = ProcessList(@AutoItExe) If $aProcessList[0][0] >= 2 Then Exit #EndRegion ;GuiVars + FileInstall ;============================================================================= #Region ;GUI $GUI = GUICreate('123', 150, 150, 150, 150, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOOLWINDOW) GUISetBkColor(0xABCDEF) GUISetOnEvent($GUI_EVENT_CLOSE, "Quit") $ExitItem = TrayCreateItem("Close") TrayItemSetOnEvent(-1, "Quit") TraySetState(1) TraySetClick(8) GUISetState() WinSetOnTop($GUI, '', 1) _GDIPlus_Startup() _WinAPI_SetLayeredWindowAttributes($GUI, 0xABCDEF, 250) ;0xABCDEF 0xFFFFFF 0x000000 #EndRegion ;GUI ;============================================================================= Start() ;============================================================================= Func Start() _SetLabel('abc', 1, 1) Sleep(1000) WinMove($GUI, '', 280, 250, 150, 150, 10) Sleep(1000) WinMove($GUI, '', 380, 350, 150, 150, 10) Sleep(1000) Quit() EndFunc ;==>Start ;============================================================================= Func _SetLabel($String, $x, $y) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($GUI) _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) $hFormat = _GDIPlus_StringFormatCreate() $hFamily = _GDIPlus_FontFamilyCreate("Arial") $hFont = _GDIPlus_FontCreate($hFamily, 22, 1) $tLayout = _GDIPlus_RectFCreate($x, $y, 390, 50) $hBrush = _GDIPlus_BrushCreateSolid("0xFFFFFFFF") _GDIPlus_GraphicsDrawStringEx($hGraphic, $String, $hFont, $tLayout, $hFormat, $hBrush) ;============================================================================= $hPen = _GDIPlus_PenCreate('0xFFFF0000', 5, 2) $hBrush = _GDIPlus_GraphicsDrawLine($hGraphic, 0, 35, 60, 35, $hPen) ;============================================================================= _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_FontDispose($hFont) _GDIPlus_BrushDispose($hBrush) EndFunc ;==>_SetLabel ;============================================================================= Do ;Main Sleep(100) Until GUIGetMsg() = $GUI_EVENT_CLOSE ;============================================================================= Func Quit() TrayItemSetState($ExitItem, $TRAY_UNCHECKED) _GDIPlus_Shutdown() Exit EndFunc ;==>Quit ;============================================================================= Not sure if better than your system for the use you want to give, but there you have it. Edited November 5, 2018 by careca Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe
TrashBoat Posted November 5, 2018 Author Posted November 5, 2018 @careca The problem is i dont know GDI so i just wanted to make something simple that works but has some flaws, going to try to draw a image instead if that does not work then ill read about gdi.
TrashBoat Posted November 5, 2018 Author Posted November 5, 2018 For anyone wondering if the picture does work: Well yeah and no at the same time, the transparent background is not working.
TrashBoat Posted November 5, 2018 Author Posted November 5, 2018 Ok so it struck me that i just needed to update the gui so i put that into the function and called it then i changed the color and guess what it worked! _drawc1() Func _drawc1() #Region crosshair1 Global $hBarGUI = GUICreate("", 1, 1, 91, 188, 0x80000000, 0x08000080) GUICtrlCreateLabel("", 1, 1, 1, 1) GUICtrlSetBkColor(-1, $color) GUISetBkColor($color, $hBarGUI) WinSetTrans($hBarGUI, '', 0) WinSetState($hBarGUI, '', @SW_SHOWNOACTIVATE) WinMove($hBarGUI, '', 0, -19) WinSetTrans($hBarGUI, '', 254) WinSetOnTop($hBarGUI, "", 1) _WinAPI_SetWindowLong($hBarGUI, $GWL_EXSTYLE, BitOR(_WinAPI_GetWindowLong($hBarGUI, $GWL_EXSTYLE), $WS_EX_TRANSPARENT)) #EndRegion crosshair1 EndFunc ;call this func then the color has been set to redraw the gui, noice
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