KevinO Posted September 1, 2014 Share Posted September 1, 2014 (edited) Hello there, i want some help with my code , im new to AutoIT the problem is that the crosshair isn't center for some reason. #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <Constants.au3> #include <WinAPI.au3> Local $iSize = 35 #region GUI $hGUIMain = GUICreate("") $hGUIChild = GUICreate("", $iSize, $iSize, -1, -1, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_LAYERED, $WS_EX_TRANSPARENT), $hGUIMain) GUISetBkColor($COLOR_BLACK) GUICtrlCreateLabel("", 0, Int($iSize / 2), $iSize, 1) GUICtrlSetBkColor(-1, $COLOR_BLUE) GUICtrlCreateLabel("", Int($iSize / 2), 0, 1, $iSize) GUICtrlSetBkColor(-1, $COLOR_BLUE) _WinAPI_SetLayeredWindowAttributes($hGUIChild, $COLOR_BLACK) GUISetState(@SW_SHOWNOACTIVATE, $hGUIChild) #endregion While 1 Sleep(10) _WinAPI_SetWindowPos($hGUIChild, $HWND_TOPMOST, 0, 0, 0, 0, BitOR($SWP_NOACTIVATE, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOSENDCHANGING)) WEnd Could you guys please tell me how to make it center so i can learn from it next time The Red one is from the internet, and the blue one is me.... the red one is center Edited September 1, 2014 by KevinO Link to comment Share on other sites More sharing options...
Danyfirex Posted September 1, 2014 Share Posted September 1, 2014 Welcome. Look. Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
KevinO Posted September 1, 2014 Author Share Posted September 1, 2014 Welcome. Look. Saludos yea i've read it ... all i want to know is how to make it center thats all Link to comment Share on other sites More sharing options...
Maelstrom Posted September 1, 2014 Share Posted September 1, 2014 (edited) Welcome. Look. Saludos Does it interfere with the forum rules? I see where you are going with this, but it doesn't seem like he is making a bot or anything. -------------------------------------------------------------------------------------------------------------------------------------------------------- Anyways, back on topic, the reason that the cross hairs are not pointing in the dead center is because of window's menu bar. For instance if my menu bar is 16 pixels (it isn't, but examples) autoit wouldn't read these 16 pixels as part of the screen. To center it fully you have to know the size of the task-bar that the user has. Does that help? Edited September 1, 2014 by Maelstrom Link to comment Share on other sites More sharing options...
KevinO Posted September 2, 2014 Author Share Posted September 2, 2014 Does it interfere with the forum rules? I see where you are going with this, but it doesn't seem like he is making a bot or anything. -------------------------------------------------------------------------------------------------------------------------------------------------------- Anyways, back on topic, the reason that the cross hairs are not pointing in the dead center is because of window's menu bar. For instance if my menu bar is 16 pixels (it isn't, but examples) autoit wouldn't read these 16 pixels as part of the screen. To center it fully you have to know the size of the task-bar that the user has. Does that help? you are right, when i move my menu bar up the cross will get another position.... now my question is how do i fix that?. so the cross will always stay in middle of the screen Link to comment Share on other sites More sharing options...
Maelstrom Posted September 2, 2014 Share Posted September 2, 2014 you are right, when i move my menu bar up the cross will get another position.... now my question is how do i fix that?. so the cross will always stay in middle of the screen You would have to add in the amount of pixels that your menu bar takes up. Link to comment Share on other sites More sharing options...
KevinO Posted September 2, 2014 Author Share Posted September 2, 2014 this is the source from the red one.... but what am i doing wrong in the blue one? #include <GDIPlus.au3> #include <WindowsConstants.au3> Local $hGUI, $hGraphics, $hBitmap, $hBackBuffer, $hPen, $wedith = @DesktopWidth/2, $height = @DesktopHeight/2 _GDIPlus_Startup() HotKeySet("{ESC}","_Exit") $hDummy = GUICreate("") $hGUI = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST,$WS_EX_TRANSPARENT),$hDummy) GUISetBkColor(0xABCDEF, $hGUI) _WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF, 255) $hPen = _GDIPlus_PenCreate(0xFFFF0000,1) $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) $hBitmap = _GDIPlus_BitmapCreateFromGraphics(@DesktopWidth, @DesktopHeight, $hGraphics) $hBackBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap) GUISetState() While Sleep(10) _GDIPlus_GraphicsDrawLine($hGraphics, $wedith-40, $height, $wedith+40, $height, $hPen) _GDIPlus_GraphicsDrawLine($hGraphics, $wedith+1, $height-40, $wedith+1, $height+40, $hPen) _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, $wedith, $height) WEnd Func _Exit() _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_PenDispose($hPen) GUIDelete($hGUI) Exit EndFunc i don't see it Link to comment Share on other sites More sharing options...
Maelstrom Posted September 2, 2014 Share Posted September 2, 2014 This is what I mean: Screen: Menu Toolbar length: So if our toolbar length was 16, and the toolbar was on the left side (like mine is), then your function would be as follows: #include <GDIPlus.au3> #include <WindowsConstants.au3> ;//---------------------------------------------------------------------------------VV----------------------------\\; Local $hGUI, $hGraphics, $hBitmap, $hBackBuffer, $hPen, $wedith = @DesktopWidth/2 + 16, $height = @DesktopHeight/2 _GDIPlus_Startup() HotKeySet("{ESC}","_Exit") $hDummy = GUICreate("") $hGUI = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST,$WS_EX_TRANSPARENT),$hDummy) GUISetBkColor(0xABCDEF, $hGUI) _WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF, 255) $hPen = _GDIPlus_PenCreate(0xFFFF0000,1) $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) $hBitmap = _GDIPlus_BitmapCreateFromGraphics(@DesktopWidth, @DesktopHeight, $hGraphics) $hBackBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap) GUISetState() This variant of the script moves the pointer 16 to the right. If I wanted to move it to the left, I would subtract 16 instead of add it. Get the idea? Link to comment Share on other sites More sharing options...
KevinO Posted September 2, 2014 Author Share Posted September 2, 2014 i got it, thx for your helps 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