AutoHotkey Community

It is currently May 26th, 2012, 3:09 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 73 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next
Author Message
 Post subject:
PostPosted: March 4th, 2009, 8:37 pm 
Offline

Joined: March 4th, 2009, 4:15 pm
Posts: 7
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 5th, 2009, 12:58 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Borderless
PostPosted: April 7th, 2009, 1:45 pm 
Offline

Joined: March 21st, 2009, 8:12 pm
Posts: 28
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 7th, 2009, 1:51 pm 
Quote:
How do i do this?
Search for 'border' in the AHK help. Check the first hit. Gotcha. :roll:


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 7th, 2009, 1:52 pm 
Offline

Joined: March 21st, 2009, 8:12 pm
Posts: 28
thanks for the quick reply, i just added
Code:
-Caption
on the end of line 14


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 30th, 2009, 9:22 pm 
I hit ^+Z and zoom window appears, but +Esc and +RButton doesn't works for me at all. Please help :?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 12th, 2009, 8:58 am 
Offline

Joined: June 3rd, 2008, 6:44 pm
Posts: 27
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
}



Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 12th, 2009, 10:26 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 16th, 2009, 7:05 am 
Offline

Joined: June 3rd, 2008, 6:44 pm
Posts: 27
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%
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 16th, 2009, 10:09 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 17th, 2009, 6:04 pm 
Offline
User avatar

Joined: September 8th, 2008, 12:26 am
Posts: 1048
Location: Ploieşti, RO
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. 8)

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! :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 18th, 2009, 12:00 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 18th, 2009, 3:04 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 18th, 2009, 1:21 pm 
Offline
User avatar

Joined: September 8th, 2008, 12:26 am
Posts: 1048
Location: Ploieşti, RO
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 18th, 2009, 4:05 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 73 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Uberi and 11 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group