Jump to content
Sign in to follow this  
quaizywabbit

"highlighting" controls

Recommended Posts

quaizywabbit

I'm pretty sure this has been asked, but didn't find it when searching the forums...

How can I highlight a control in the same manner that AutoIt's window info tool does??

I'm making a step by step interactive setup totorial for a program and being able to Highlight various controls would be very useful. I want the highlight to blink on and off to get the user's attention.


[u]Do more with pre-existing apps![/u]ANYGUIv2.8

Share this post


Link to post
Share on other sites
steveR

I think this might be it. One of Larry's scripts.

Opt("WinWaitDelay",1)
Opt("WinTitleMatchMode",4)

Send("#r")
WinWait("Run")
$hwnd = WinGetHandle("Run","")

OutlineControl("Run","","Static1")
Sleep(1000)
DLLCall("user32.dll","int","InvalidateRect","hwnd",$hwnd,"int",0,"int",1)
OutlineControl("Run","","Button1")
Sleep(1000)
DLLCall("user32.dll","int","InvalidateRect","hwnd",$hwnd,"int",0,"int",1)
OutlineControl("Run","","Button2")
Sleep(1000)
DLLCall("user32.dll","int","InvalidateRect","hwnd",$hwnd,"int",0,"int",1)
OutlineControl("Run","","Button3")

Func OutlineControl($l_szTitle,$l_szText,$l_szControl)
  $l_hWnd = ControlGetHandle($l_szTitle,$l_szText,$l_szControl)
  $l_hWndDad = WinGetHandle($l_szTitle,$l_szText)
  $l_rect = ControlGetPos($l_szTitle,$l_szText,$l_szControl)
  $l_hdc = DLLCall("user32.dll","int","GetDC","hwnd",$l_hWndDad)
  DLLCall("gdi32.dll","int","MoveToEx","int",$l_hdc[0],"int",$l_rect[0],"int",$l_rect[1],"int",0)
  DLLCall("gdi32.dll","int","LineTo","int",$l_hdc[0],"int",$l_rect[0] + $l_rect[2],"int",$l_rect[1])
  DLLCall("gdi32.dll","int","LineTo","int",$l_hdc[0],"int",$l_rect[0] + $l_rect[2],"int",$l_rect[1]+$l_rect[3])
  DLLCall("gdi32.dll","int","LineTo","int",$l_hdc[0],"int",$l_rect[0],"int",$l_rect[1]+$l_rect[3])
  DLLCall("gdi32.dll","int","LineTo","int",$l_hdc[0],"int",$l_rect[0],"int",$l_rect[1])
  $l_hdc = DLLCall("user32.dll","int","ReleaseDC","hwnd",$l_hWndDad,"int",$l_hdc[0])
EndFunc

AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.

Share this post


Link to post
Share on other sites
quaizywabbit

Thanks!!

EDIT: works just fine...except no color.

with all those dll calls, I have no clue how to add color to it.

Edited by quaizywabbit

[u]Do more with pre-existing apps![/u]ANYGUIv2.8

Share this post


Link to post
Share on other sites
quaizywabbit

Found this in one of Larry's old posts....now its just a matter of figuring out how to combine the two...

$a = DrawRectangle(600, 300, 750, 400, 0xFFFF00)
While 1
    Sleep(100)
    WEnd

Func DrawRectangle($xstart, $ystart, $xend, $yend, $color)
 $rectdraw = DLLCall("user32.dll","int","GetDC","hwnd",0)
 If @error Then Return 0
 $pen = DLLCall("gdi32.dll","int","CreatePen","int",0,"int",20,"int",$color)
 $err = @error
 If Not $err Then
    DLLCall("gdi32.dll","int","SelectObject","int",$rectdraw[0],"int",$pen[0])
    If Not @error Then
      DLLCall("gdi32.dll","int","MoveToEx","int",$rectdraw[0],"int",_
                   $xstart,"int",$ystart,"int",0)
      DLLCall("gdi32.dll","int","LineTo","int",$rectdraw[0], _
                   "int",$xend,"int",$ystart)
      DLLCall("gdi32.dll","int","LineTo","int",$rectdraw[0], _
                   "int",$xend,"int",$yend)
      DLLCall("gdi32.dll","int","LineTo","int",$rectdraw[0], _
                   "int",$xstart,"int",$yend)
      DLLCall("gdi32.dll","int","LineTo","int",$rectdraw[0], _
                   "int",$xstart,"int",$ystart)
      DLLCall("gdi32.dll","int","DeleteObject","int",$pen[0])
    EndIf
 EndIf
 DLLCall("user32.dll","int","ReleaseDC","hwnd",0,"int",$rectdraw[0])
 If $err Then Return 0
 Return 1
EndFunc
Edited by quaizywabbit

[u]Do more with pre-existing apps![/u]ANYGUIv2.8

Share this post


Link to post
Share on other sites
quaizywabbit

Thanks again Larry!!!

This is sooo cool :)

Very, VERY much appreciated!!!


[u]Do more with pre-existing apps![/u]ANYGUIv2.8

Share this post


Link to post
Share on other sites
steveR

I tried using the CreatePen and SelectObject API calls but it's not working.

Ack! I didn't have the subscripts for the Pen() and GetDC() calls.

How come they return an array? Couldn't be low-byte - high-byte, is it?

Edited by steveR

AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.