Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

(SOLVED) A little read Dot


  • Please log in to reply
19 replies to this topic
SpiderGames
  • Members
  • 936 posts
  • Last active: Aug 13 2019 02:50 AM
  • Joined: 09 Jun 2008
Hey,

I was wondering if it is possible to make a litte red dot apear always on top. In the exact middle of the screen. I was thinking maybe something like a splash image. Any Ideas?

EDIT::

So far i have this and it works OKish. I would like to know how to remove the title and everything else.

EDIT2:: Heres the working script


Start:
SplashImage, C:\Users\cbkrunch17\Desktop\Untitled.gif, B,,,haha
WinSet, TransColor, White, haha
Return,
 
!h::
 WinKill, haha
Return,

!s::
 Goto, Start
Return,


^!x::
ExitApp

Posted Image
I know i have 6 legs. It's cuz I'm special.

ahklerner
  • Members
  • 1386 posts
  • Last active: Oct 08 2014 10:29 AM
  • Joined: 26 Jun 2006
search for SetPixel on forum or in the docs. dllcall page
Posted Image
ʞɔпɟ əɥʇ ʇɐɥʍ

Wickedness
  • Guests
  • Last active:
  • Joined: --
Download this picture and put it in C:\Corsshair.PNG
http://i60.photobuck... ... sshair.png
Posted Image

This will work better if you have a transparent PNG picture...




sFile   := "C:\Crosshair.PNG" 

mDC_Scr   := Gdi_CreateCompatibleDC(0) 
pToken   := Gdip_Startup() 
pBitmap   := !hIcon ? Gdip_CreateBitmapFromFile(sFile) : Gdip_CreateBitmapFromHICON(hIcon) 
nWidth   := Gdip_GetImageWidth( pBitmap) 
nHeight   := Gdip_GetImageHeight(pBitmap) 
hBitmap   := !hIcon ? Gdip_CreateHBITMAPFromBitmap(pBitmap) : Gdi_CreateDIBSection(mDC_Scr, nWidth, nHeight) 
Gdip_DisposeImage(pBitmap) 
Gdip_Shutdown(pToken) 
oBitmap   := Gdi_SelectObject(mDC_Scr, hBitmap) 

If   hIcon 
   DllCall("DrawIconEx", "Uint", mDC_Scr, "int", 0, "int", 0, "Uint", hIcon, "int", nWidth, "int", nHeight, "Uint", 0, "Uint", 0, "Uint", 1|2) 

Gui, +LastFound -Caption +E0x80000 +ToolWindow +AlwaysOnTop
DllCall("UpdateLayeredWindow", "Uint", WinExist(), "Uint", 0, "Uint", 0, "int64P", nWidth|nHeight<<32, "Uint", mDC_Scr, "int64P", 0, "Uint", 0, "UintP", 255<<16|1<<24, "Uint", 2) 
Gui, Show,W%nWidth% H%nHeight%, Crosshair

Gdi_SelectObject(mDC_Scr, oBitmap) 
Gdi_DeleteObject(hBitmap) 
Gdi_DeleteDC(mDC_Scr) 

Gdi_CreateDIBSection(hDC, nW, nH, bpp = 32, ByRef pBits = "") 
{ 
   NumPut(VarSetCapacity(bi, 40, 0), bi) 
   NumPut(nW, bi, 4) 
   NumPut(nH, bi, 8) 
   NumPut(bpp, NumPut(1, bi, 12, "UShort"), 0, "Ushort") 
  
   Return   DllCall("gdi32\CreateDIBSection", "Uint", hDC, "Uint", &bi, "Uint", 0, "UintP", pBits, "Uint", 0, "Uint", 0) 
} 

Gdi_CreateCompatibleDC(hDC = 0) 
{ 
   Return   DllCall("gdi32\CreateCompatibleDC", "Uint", hDC) 
} 

Gdi_SelectObject(hDC, hGdiObj) 
{ 
   Return   DllCall("gdi32\SelectObject", "Uint", hDC, "Uint", hGdiObj) 
} 

Gdi_DeleteObject(hGdiObj) 
{ 
   Return   DllCall("gdi32\DeleteObject", "Uint", hGdiObj) 
} 

Gdi_DeleteDC(hDC) 
{ 
   Return   DllCall("gdi32\DeleteDC", "Uint", hDC) 
} 

Gdip_CreateBitmapFromFile(sFile) 
{ 
   VarSetCapacity(wFile, 1023) 
   DllCall("kernel32\MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sFile, "int", -1, "Uint", &wFile, "int", 512) 
   DllCall("gdiplus\GdipCreateBitmapFromFile", "Uint", &wFile, "UintP", pBitmap) 
   Return   pBitmap 
} 

Gdip_CreateBitmapFromHICON(hIcon) 
{ 
   DllCall("gdiplus\GdipCreateBitmapFromHICON", "Uint", hIcon, "UintP", pBitmap) 
   Return   pBitmap 
} 

Gdip_CreateHBITMAPFromBitmap(pBitmap, ARGB = 0) 
{ 
   DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", "Uint", pBitmap, "UintP", hBitmap, "Uint", ARGB) 
   Return   hBitmap 
} 

Gdip_DisposeImage(pImage) 
{ 
   Return   DllCall("gdiplus\GdipDisposeImage", "Uint", pImage) 
} 

Gdip_GetImageWidth(pImage) 
{ 
   DllCall("gdiplus\GdipGetImageWidth", "Uint", pImage, "UintP", nW) 
   Return   nW 
} 

Gdip_GetImageHeight(pImage) 
{ 
   DllCall("gdiplus\GdipGetImageHeight", "Uint", pImage, "UintP", nH) 
   Return   nH 
} 

Gdip_Startup() 
{ 
   If Not   DllCall("GetModuleHandle", "str", "gdiplus") 
   DllCall("LoadLibrary"    , "str", "gdiplus") 
   VarSetCapacity(si, 16, 0), si := Chr(1) 
   DllCall("gdiplus\GdiplusStartup", "UintP", pToken, "Uint", &si, "Uint", 0) 
   Return   pToken 
} 

Gdip_Shutdown(pToken) 
{ 
   DllCall("gdiplus\GdiplusShutdown", "Uint", pToken) 
   If   hModule :=   DllCall("GetModuleHandle", "str", "gdiplus") 
         DllCall("FreeLibrary"    , "Uint", hModule) 
   Return   0 
}


Krogdor
  • Members
  • 1391 posts
  • Last active: Jun 08 2011 05:31 AM
  • Joined: 18 Apr 2008
Here is a way to do it without requiring external files:

SetTimer, SetPixel, 15
SetPixel:
 hDrwArea := DllCall("GetDC", "uint", Null)
 DllCall("SetPixel", "uint", hDrwArea, "int", 500, "int", 500, "uint", 255, "uint", 00, "uint", 00)
 DllCall("ReleaseDC", UInt, 0, UInt, hDrwArea)
 DllCall("FreeLibrary", "UInt", hDrwArea)


Wickedness
  • Guests
  • Last active:
  • Joined: --
Steal the light, Krog... Steal the spot-light :p

SpiderGames
  • Members
  • 936 posts
  • Last active: Aug 13 2019 02:50 AM
  • Joined: 09 Jun 2008
Krogdor's dosn;t work.

I like the one I have. Thanks anyways.
Posted Image
I know i have 6 legs. It's cuz I'm special.

Chavez
  • Members
  • 256 posts
  • Last active: Oct 13 2009 01:27 PM
  • Joined: 20 Aug 2008

Krogdor's dosn;t work.

I like the one I have. Thanks anyways.


What's your ingame name if i may ask?
-Chavez.

Serenity
  • Members
  • 1271 posts
  • Last active:
  • Joined: 07 Nov 2004
SetPixel works, but it is only a pixel so it is very hard to see. Try moving the window beneath it.

SetTimer, SetPixel, 15
SetPixel:
 hDrwArea := DllCall("GetDC", "uint", Null)
 DllCall("SetPixel", "uint", hDrwArea, "int", A_ScreenWidth/2, "int", A_ScreenHeight/2, "uint", 255, "uint", 0, "uint", 0)
 DllCall("ReleaseDC", UInt, 0, UInt, hDrwArea)
 DllCall("FreeLibrary", "UInt", hDrwArea)

In one line:

Splashimage, 1:, % "B W2 H2 CWFF0000 X" . A_ScreenWidth/2 . " Y" . A_ScreenHeight/2,,, Dot

"Anything worth doing is worth doing slowly." - Mae West
Posted Image

Krogdor
  • Members
  • 1391 posts
  • Last active: Jun 08 2011 05:31 AM
  • Joined: 18 Apr 2008
Oops, my code should be:

OnExit, ExitRoutine
SetTimer, SetPixel, 15
hDrwArea := DllCall("GetDC", "uint", Null)
SetPixel:
DllCall("SetPixel", "uint", hDrwArea, "int", A_ScreenWidth/2, "int", A_ScreenHeight/2, "uint", 255, "uint", 0, "uint", 0)
Return

ExitRoutine:
DllCall("ReleaseDC", UInt, 0, UInt, hDrwArea)
DllCall("FreeLibrary", "UInt", hDrwArea)
ExitApp

If you want it to be more visible (instead of one pixel), use this:
OnExit, ExitRoutine
X := 10 ;change for how wide you want it
Y := 10 ;change for how tall you want it
XX1 := ((A_ScreenWidth/2)-(X/2))
YY1 := ((A_ScreenHeight/2)-(Y/2))
SetTimer, SetPixel, 15
hDrwArea := DllCall("GetDC", "uint", Null)
SetPixel:
Loop, %X% {
  B_Index := A_Index
  Loop, %Y%
    DllCall("SetPixel", "uint", hDrwArea, "int",  XX1 + B_Index, "int",  YY1 + A_Index, "uint", 255, "uint", 0, "uint", 0)
}
Return

ExitRoutine:
DllCall("ReleaseDC", UInt, 0, UInt, hDrwArea)
DllCall("FreeLibrary", "UInt", hDrwArea)
ExitApp


Serenity
  • Members
  • 1271 posts
  • Last active:
  • Joined: 07 Nov 2004
Krogdor, if you move the window beneath do you get "pixel bleed"?
"Anything worth doing is worth doing slowly." - Mae West
Posted Image

Krogdor
  • Members
  • 1391 posts
  • Last active: Jun 08 2011 05:31 AM
  • Joined: 18 Apr 2008
o_O Nothing like that has happened on my computer. Although if you move the window underneath, it will flicker. But nothing like that where the square moves all over the place... I don't know what could be causing that.

ahklerner
  • Members
  • 1386 posts
  • Last active: Oct 08 2014 10:29 AM
  • Joined: 26 Jun 2006
it is because of how ahk handles the redrawing of the window.
Posted Image
ʞɔпɟ əɥʇ ʇɐɥʍ

bcn_246
  • Guests
  • Last active:
  • Joined: --
The original script by Wickedness works great, except it isnt quite in the centre... any way to manually offset it up/down/left/right?

Thanks

Ben

tomoe_uehara
  • Members
  • 2166 posts
  • Last active: Jun 11 2015 05:33 PM
  • Joined: 05 Sep 2009
It seems the GUI doesn't have any X or Y coordinates, so it will be auto centered by default, but you can try to change the value of X or Y.
Gui, Show, W%nWidth% H%nHeight% X100 Y100, Crosshair


  • Guests
  • Last active:
  • Joined: --
a version without gifs or DllCalls

diam = 8	; diameter of dot

Gui -Caption +AlwaysOnTop
Gui margin,0,0
Gui add, ListView,	w%diam% h%diam%	-Hdr -E0x200 BackgroundRed
SysGet, mon, MonitorWorkArea		; get screen size (to include taskbar height delete text 'WorkArea')
Gui show, % "x" monRight//2-(diam//2) " y" monBottom//2-(diam//2)
WinSet, Region, 0-0 W%diam% H%diam% E, A		; make it circular
return


Esc::
ExitApp