 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Scape
Joined: 04 Mar 2009 Posts: 7
|
Posted: Wed Mar 04, 2009 8:37 pm Post subject: |
|
|
Useful script. One issue I found is that grey colors created a balloon window that was grey on grey. While in theory making the baloon the selected color & the inverse seems good there are cases near grey where it makes it near unreadable. I modified the foloowing two lines to use plain white on black so that no matter the color it's easy to read:
Original code:
| Code: |
SendMessage, 1043, nColor, 0,, ahk_id %hWnd%
SendMessage, 1044,~nColor & 0xFFFFFF, 0,, ahk_id %hWnd%
|
Modified code:
| Code: |
SendMessage, 1043, 0x000000, 0,, ahk_id %hWnd%
SendMessage, 1044, 0xFFFFFF, 0,, ahk_id %hWnd%
|
That was the only issue / suggestion I had. Solid work! |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2208
|
Posted: Thu Mar 05, 2009 12:58 am Post subject: |
|
|
| Scape wrote: | | One issue I found is that grey colors created a balloon window that was grey on grey. | Use Shift+Esc or Shift+RightClick which will copy the color into the clipboard.
| Code: | SendMessage, 1043, 0x000000, 0,, ahk_id %hWnd%
SendMessage, 1044, 0xFFFFFF, 0,, ahk_id %hWnd% | They aren't necessary, just remove the two lines, then the system default colors will be used. |
|
| Back to top |
|
 |
Psycho.Mario
Joined: 21 Mar 2009 Posts: 28
|
Posted: Tue Apr 07, 2009 1:45 pm Post subject: Borderless |
|
|
How did you make the window so it had no border? I am trying to make a GUI which shows a webpage, sort of like an rss feed, so far i have this:
| Code: | Gui +AlwaysOnTop +Resize +ToolWindow
GoSub, GuiOpen
pweb := COM_AtlAxCreateControl(WinExist(), "Shell.Explorer")
psink:= COM_ConnectObject(pweb, "Web_")
COM_Invoke(pweb, "Silent", True)
COM_Invoke(pweb, "Navigate2", "http://news.google.co.uk/nwshp?hl=en&tab=wn")
Return
Navigate:
COM_Invoke(pweb, "Navigate2", _URL_)
Return
GuiOpen:
Gui, +Resize +LastFound
Gui, Show, w975 h750 Center, Blades
COM_AtlAxWinInit()
Return
GuiClose:
COM_Release(psink)
COM_Release(pweb)
Gui, Destroy
COM_AtlAxWinTerm()
ExitApp
Web_NewWindow3(prms)
{
Global _URL_:= COM_DispGetParam(prms,4)
COM_DispSetParam(-1,prms,1,11)
SetTimer, Navigate, -10
} |
I adapted this from another script. I want to have the edges borderless, like the magnifier. How do i do this?
Thanks |
|
| Back to top |
|
 |
Guest
|
Posted: Tue Apr 07, 2009 1:51 pm Post subject: |
|
|
Search for 'border' in the AHK help. Check the first hit. Gotcha.  |
|
| Back to top |
|
 |
Psycho.Mario
Joined: 21 Mar 2009 Posts: 28
|
Posted: Tue Apr 07, 2009 1:52 pm Post subject: |
|
|
| thanks for the quick reply, i just added on the end of line 14 |
|
| Back to top |
|
 |
Guest
|
Posted: Sat May 30, 2009 9:22 pm Post subject: |
|
|
I hit ^+Z and zoom window appears, but +Esc and +RButton doesn't works for me at all. Please help  |
|
| Back to top |
|
 |
ArchCarrier
Joined: 03 Jun 2008 Posts: 20
|
Posted: Fri Jun 12, 2009 8:58 am Post subject: |
|
|
I tried to modify the original script so that clicking would send the color code to the clipboard and close the zoomer window, but only six zeros are copied to the clipboard whenever I click. Any suggestions?
| Code: | #NoEnv
#SingleInstance, Force
SetWinDelay, 10
nZ := 3 ; Zoom Factor
nR := 100 ; Rectangle of the Zoomer
CoordMode, Mouse
CoordMode, Pixel
ToolTip, %A_Space%
WinGet, hWnd, ID, ahk_class tooltips_class32
WinSet, ExStyle, +0x00000020, ahk_id %hWnd%
hDC_SC := DllCall("GetDC", "Uint", 0)
hDC_TT := DllCall("GetDC", "Uint", hWnd)
Loop
{
MouseGetPos, xmouse, ymouse
DllCall("StretchBlt", "Uint", hDC_TT, "int", 0, "int", 0, "int", nR*2, "int", nR*2, "Uint", hDC_SC, "int", xmouse-nR//nZ, "int", ymouse-nR//nZ, "int", nR//nZ*2, "int", nR//nZ*2, "Uint", 0x00CC0020)
WinMove, ahk_id %hWnd%,, xmouse-nR, ymouse-nR, nR*2, nR*2
WinSet, AlwaysOnTop, On, ahk_id %hWnd%
}
LButton::
Clipboard := GetColor()
Goto Exit
Esc::
Goto Exit
Exit:
DllCall("ReleaseDC", "Uint", 0, "Uint", hDC_SC)
DllCall("ReleaseDC", "Uint", hWnd, "Uint", hDC_TT)
ExitApp
GetColor()
{
VarSetCapacity(nColor, 6)
SendMessage, 1046, 0, 0,, A
DllCall("wsprintf", "str", nColor, "str", "%06X", "Uint", ErrorLevel, "Cdecl")
Return nColor
}
|
|
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2208
|
Posted: Fri Jun 12, 2009 10:26 am Post subject: |
|
|
| ArchCarrier wrote: | | but only six zeros are copied to the clipboard whenever I click. | To see what you did wrong, run the code inside GetColor().
| Code: | WinGetClass, sClass, A
MsgBox, % sClass | Use hWnd instead. Next, even with hWnd you'll only get the default background color of tooltip. So, you should rewrite the code. |
|
| Back to top |
|
 |
ArchCarrier
Joined: 03 Jun 2008 Posts: 20
|
Posted: Tue Jun 16, 2009 7:05 am Post subject: |
|
|
Sean, thanks for the reply (although I'm afraid I didn't understand it). I got it working now, using a script from Skrommel's collection:
| Code: | #NoEnv
#SingleInstance, Force
SetWinDelay, 10
nZ := 3 ; Zoom Factor
nR := 100 ; Rectangle of the Zoomer
CoordMode, Mouse
CoordMode, Pixel
ToolTip, %A_Space%
WinGet, hWnd, ID, ahk_class tooltips_class32
WinSet, ExStyle, +0x00000020, ahk_id %hWnd%
hDC_SC := DllCall("GetDC", "Uint", 0)
hDC_TT := DllCall("GetDC", "Uint", hWnd)
Loop
{
MouseGetPos, xmouse, ymouse
DllCall("StretchBlt", "Uint", hDC_TT, "int", 0, "int", 0, "int", nR*2, "int", nR*2, "Uint", hDC_SC, "int", xmouse-nR//nZ, "int", ymouse-nR//nZ, "int", nR//nZ*2, "int", nR//nZ*2, "Uint", 0x00CC0020)
WinMove, ahk_id %hWnd%,, xmouse-nR, ymouse-nR, nR*2, nR*2
WinSet, AlwaysOnTop, On, ahk_id %hWnd%
}
LButton::
Clipboard := GetColor()
Goto Exit
Esc::
Goto Exit
Exit:
DllCall("ReleaseDC", "Uint", 0, "Uint", hDC_SC)
DllCall("ReleaseDC", "Uint", hWnd, "Uint", hDC_TT)
ExitApp
GetColor()
{
MouseGetPos,x,y
PixelGetColor,rgb,x,y,RGB
StringTrimLeft,rgb,rgb,2
Return %rgb%
} |
|
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2208
|
Posted: Tue Jun 16, 2009 10:09 am Post subject: |
|
|
Yes, it'll work, although it's redundant here.
| Code: | LButton::
VarSetCapacity(nColor, 6)
DllCall("wsprintf", "str", nColor, "str", "%06X", "int", DllCall("GetPixel", "Uint", hDC_SC, "int", xmouse, "int", ymouse), "Cdecl")
Clipboard := nColor
Esc::
DllCall("ReleaseDC", "Uint", 0, "Uint", hDC_SC)
DllCall("ReleaseDC", "Uint", hWnd, "Uint", hDC_TT)
ExitApp
|
|
|
| Back to top |
|
 |
Drugwash
Joined: 08 Sep 2008 Posts: 608 Location: Ploiesti, RO
|
Posted: Wed Jun 17, 2009 6:04 pm Post subject: |
|
|
Hey, Sean! In your first post you say your script will never work in Win9x. Oh well... not in its official form, but with a few minor changes, it does.
Personally I run Win98SE with some WinME, Win2000, WinXP and even Win2003 system files upgraded. As such, balloon tips display fine when called (see the topics on balloon tips posted around, where I've performed tests). The only drawback is that the close button won't show up so can't be used to close the balloons and also links won't show up (but that doesn't pertain to your script; sorry for the digression).
The color zoomer rectangle appears fine with the cross cursor in the middle of it, but it won't show anything inside, because the layered style used is not supported by the 9x USER32.DLL library and all it captures is the zoom rectangle itself. As such, I'd be grateful if you could offer an alternate option of showing the zoom rectangle as a tooltip to the side of the cross cursor, similar to the magnifier; when so, the script would also work correctly at least in a stock WinME, along with any updated Win98SE such as mine.
The other necessary changes would be:
- replace RtlFillMemoryULong calls with NumPut
- replace CreateWindowEx with CreateWindowExA
- replace SetClassLong with SetClassLongA
| Code: | DllCall("ntdll\RtlFillMemoryUlong", "Uint", &ti + 4, "Uint", 4, "Uint", 0x20)
DllCall("ntdll\RtlFillMemoryUlong", "Uint", &ti +36, "Uint", 4, "Uint", &nColor)
hWnd := DllCall("CreateWindowEx", "Uint", 0x08000008, "str", "tooltips_class32", "str", "", "Uint", 0x3, "int", 0, "int", 0, "int", 0, "int", 0, "Uint", 0, "Uint", 0, "Uint", 0, "Uint", 0, "UInt")
DllCall("SetClassLong", "Uint", hWnd, "int", -12, "int", DllCall("LoadCursor", "Uint", 0, "Uint", 32515))
|
would become:
| Code: | NumPut(0x20, ti, 4, "UInt")
NumPut(&nColor, ti, 36, "UInt")
hWnd := DllCall("CreateWindowExA", "Uint", 0x08000008, "str", "tooltips_class32", "str", "", "Uint", 0x3, "int", 0, "int", 0, "int", 0, "int", 0, "Uint", 0, "Uint", 0, "Uint", 0, "Uint", 0)
DllCall("SetClassLongA", "Uint", hWnd, "int", -12, "int", DllCall("LoadCursor", "Uint", 0, "Uint", 32515))
|
The magnifier works fine with the exception of a flickering rectangle to the top-left side of the magnified window, containing the original clipped region unzoomed. Probably a recreation/initialization of the tooltip. I haven't yet checked that particular code to see for a fix.
[EDIT] OK, I've checked the magnifier code and the fix (actually workaround) is pretty simple: check for mouse coordinates and if not changed between loop iterations, just continue the loop. This way it will only flicker while the mouse is moved.
Here's the relevant part fo the code:
| Code: | Loop
{
MouseGetPos, xCursor, yCursor
if (oldX = xCursor && oldY = yCursor)
continue
DllCall("BitBlt", "Uint", hDC_LW, "int", 0, "int", 0, "int", 2*nW, "int", 2*nH, "Uint", hDC_SC, "int", xCursor-nW, "int", yCursor-nH, "Uint", 0x40CC0020)
If bInvert
DllCall("BitBlt", "Uint", hDC_LW, "int", 0, "int", 0, "int", 2*nW, "int", 2*nH, "Uint", 0, "int", 0, "int", 0, "Uint", 0x00550009)
Cursor(hDC_LW, nW, nH) ; Capture magnified mouse cursor.
DllCall("StretchBlt", "Uint", hDC_TT, "int", 0, "int", 0, "int", 2*nW*nZ, "int", 2*nH*nZ, "Uint", hDC_LW, "int", 0, "int", 0, "int", 2*nW, "int", 2*nH, "Uint", 0x00CC0020)
; Cursor(hDC_TT, nW*nZ, nH*nZ) ; Capture un-magnified mouse cursor.
WinMove, ahk_id %hWnd%,, xCursor-(nW*nZ+1), yCursor+nH, 2*(nW*nZ+1), 2*(nH*nZ+1)
oldX := xCursor
oldY := yCursor
If GetKeyState("Esc")
Break
}
|
Thank you so much for the script!  |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2208
|
Posted: Thu Jun 18, 2009 12:00 am Post subject: |
|
|
| Drugwash wrote: | | because the layered style used is not supported by the 9x USER32.DLL library and all it captures is the zoom rectangle itself. | It's a little unclear to me. So, you can or cannot use a transparent window? Actually a tooltip window with Layered ExStyle defaultly is a feature of v6.0 of comctl32.dll. If not using it, you have to set the Layered ExStyle manually even in XP, via e.g.
| Code: | | WinSet, Transparent, 255, ahk_id %hWnd% |
| Quote: | - replace CreateWindowEx with CreateWindowExA
- replace SetClassLong with SetClassLongA | Why? It's supposed to be done by AHK itself. There are no exported APIs CreateWindowEx/SetClassLong in XP either. |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2208
|
Posted: Thu Jun 18, 2009 3:04 am Post subject: |
|
|
| Drugwash wrote: | | The magnifier works fine with the exception of a flickering rectangle to the top-left side of the magnified window, containing the original clipped region unzoomed. | OK, I now realized what you meant. I recalled that I was concerned about this when I wrote it, but was unnoticeable in my system. I guess your system is rather slow. In that case, the cure is simple. Use mem DC in place of hDC_LW, i.e., use CreateCompatibleDC. Don't forget then you have to adjust the followings appropriately like creating/selecting bitmap etc. |
|
| Back to top |
|
 |
Drugwash
Joined: 08 Sep 2008 Posts: 608 Location: Ploiesti, RO
|
Posted: Thu Jun 18, 2009 1:21 pm Post subject: |
|
|
| Sean wrote: | | It's a little unclear to me. So, you can or cannot use a transparent window? | No, in Win9x I cannot, unfortunately. WinSet, Transparent cannot work either.
| Quote: | | Why? It's supposed to be done by AHK itself. There are no exported APIs CreateWindowEx/SetClassLong in XP either. | For some reason, it doesn't do it on my 98SE system. I stumbled into this issue many times when I didn't pay enough attention to MSDN and didn't check the actual function names in the dlls. Anyway, if there's no explicit need for the Unicode versions of the functions, the ANSI versions can safely be hardcoded in the script, to ensure it would work under most Windows versions.
| Quote: | | I guess your system is rather slow. In that case, the cure is simple [...]. | It's a 667MHz Pentium III. Since I'm not at all familiar with the GDI API, I'm afraid the aforementioned workaround will have to do for me (forgot to mention the break hotkey check should be placed in the very beginning of the loop so it wouldn't require a mouse move to exit the magnifier). But if you think it's not worth changing the code, I'll just use it locally.
Thanks for taking the time to answer. |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2208
|
Posted: Thu Jun 18, 2009 4:05 pm Post subject: |
|
|
| Drugwash wrote: | | Since I'm not at all familiar with the GDI API | You better learn about it. It could pay you back unexpected reward/solution for one of your problems. Anyway it's easy to adopt the code from another script of mine
http://www.autohotkey.com/forum/topic18146.html
Before the loop:
| Code: | hDC_TT := DllCall("GetDC", "Uint", hWnd)
hDC_SC := DllCall("GetDC", "Uint", 0)
hDC_LW := DllCall("CreateCompatibleDC", "Uint", hDC_SC)
hBM := DllCall("CreateCompatibleBitmap", "Uint", hDC_SC, "int", 2*nW, "int", 2*nH)
oBM := DllCall("SelectObject", "Uint", hDC_LW, "Uint", hBM)
DllCall("SetStretchBltMode", "Uint", hDC_TT, "int", 4)
|
After the loop:
| Code: | DllCall("SelectObject", "Uint", hDC_LW, "Uint", oBM)
DllCall("DeleteObject", "Uint", hBM)
DllCall("DeleteDC", "Uint", hDC_LW)
DllCall("ReleaseDC", "Uint", 0, "Uint", hDC_SC)
DllCall("ReleaseDC", "Uint", hWnd, "Uint", hDC_TT)
|
| Quote: | | But if you think it's not worth changing the code, I'll just use it locally. | It's not a matter of whether I think it's worth or not. I just don't want to be trapped into keeping constantly updating the old codes I posted. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|