Hey guys,
I cant figure out how to make my cross hairs work after initial initiation of the application i am developing.
At start its loads fine, but when i click to pause the area of zoom and then start it again the cross hairs don't appear. Also the issue is flicker cross hairs, but i am not sure if that can be avoidable.
My script should operate like this:
When you launch it ask for source window, works on game windows best(calculator seams to not work with my app), then once you give the proper window name it opens 3 guis. One a copy of the whole window, 2nd is the panel for my app. Inside the panel there is a frame to hold the maximized refreshing image of where the mouse is/should be of the chosen window. It uses the same bitmap that's a copy of the real chosen window just used differently in a different gui. And is meant to have cross hairs while the frame is active. There is a button OK to initiate that frame if it is stopped. When you click left mouse button on the full window copy gui the zoom frame freezes till you click OK button.
How it actually works:
gets name of the window(no validation yet), when name is correct if fills the full copy gui and initiates the zoom frame with cross hair like it should. reacts to left click appropriately. But when its initiated again it fails to draw the cross hairs in the zoom frame.
Code: Select all
#SingleInstance, Force
#NoEnv
SetBatchLines, -1
#Include Gdip_All.ahk
CoordMode Mouse, Screen
pToken := Gdip_Startup()
global magWinSide := 256, winName, winX, winY, winW, winH
global srcPrintFrame, destPrintFrame, destFullFrame
InputBox, winName,, Please Enter The Window Title
winSetup()
activate()
winSetup()
{
WinGet, prnSrcID, ID, % winName
WinGetPos, winX, winY, winW, winH, % winName
Gui, PnCfgMain: +AlwaysOnTop
Gui, PnCfgMain: Show, % "x" 0 " y" 0 " w" magWinSide " h" magWinSide + 400, PaneConfigMain
Gui, PnCfgMain: Add, Button, % "y+" magWinSide " gactivate Default ", OK
WinGet, pnCfgMainID, ID, PaneConfigMain
WinGet pnCfgMainID, ID, PaneConfigMain
Gui, PnCfgSrc: -Border -Caption
Gui, PnCfgSrc: Show , % "w" winW " h" winH " x" 0 " y" 0, PaneConfigSource
WinGet pnCfgSrcID, ID, PaneConfigSource
srcPrintFrame := GetDC(prnSrcID)
destPrintFrame := GetDC(pnCfgMainID)
destFullFrame := GetDC(pnCfgSrcID)
StretchBlt(destFullFrame, 0, 0, winW, winH, srcPrintFrame, 0, 0, winW, winH, 0xCC0020)
}
activate()
{
zoom := 16
zSide := magWinSide / zoom
Loop
{
MouseGetPos, x, y
x -= zSide/2
y -= zSide/2
If (x=x_old) && (y=y_old)
Continue
x_old:=x, y_old:=y
StretchBlt(destPrintFrame, 0, 0, magWinSide, magWinSide, srcPrintFrame, x, y, zSide, zSide, 0xCC0020)
crshDIBS := CreateDIBSection(magWinSide, magWinSide)
crshRegObj := SelectObject(destPrintFrame, crshDIBS)
destGpxDCP := Gdip_GraphicsFromHDC(destPrintFrame)
pen1 := Gdip_CreatePen(0x660000ff, 10)
Gdip_DrawLine(destGpxDCP, pen1, 0, magWinSide/2, magWinSide, magWinSide/2)
Gdip_DrawLine(destGpxDCP, pen1, magWinSide/2, 0, magWinSide/2, magWinSide)
GetKeyState, state, LButton
if state = D
{
;zoomAct--
break
}
}
}
PnCfgMainGuiClose()
{
ExitApp
}
Gdip_Shutdown(pToken)