Jump to content

"highlighting" controls


Recommended Posts

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
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...