AutoHotkey Community

It is currently May 27th, 2012, 1:29 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Visual Overlay
PostPosted: March 30th, 2009, 7:18 pm 
Offline

Joined: March 30th, 2009, 7:17 pm
Posts: 9
I have a script that I run in conjunction with a Direct X Game, Its a plain click saver and I have way of knowing when its running due to the time between the clicks, I added a noise but that is rubbish and I would like to add some kind of visual indicator.

Can anyone suggest a way that I can programme some kind of visual indicator like a little coloured circle at the bottom left of the screen whilst the loop is active ?

~Ore


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 30th, 2009, 8:29 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
Try that ToolTip()

Code:
hwnd:=ToolTip(1,"Loop running...","Info","I1 O1 T80 X" . A_ScreenWidth . " Y" . A_ScreenHeight)
Loop 10
{
   Sleep, 500
   ShowToolTip(hwnd,A_ScreenWidth,A_ScreenHeight,"Loop #" A_Index,"",1,80)
}
ExitApp
ToolTip(_tool_tip_id_="", text=" ", title="", options=""){ ;i x y b f d t o c m
   static _tt_hwnd_list_,txt:=" "
   global #_ti_
   If !#_ti_
      VarSetCapacity(#_ti_, 40, 0),#_ti_:=Chr(40),NumPut(0x20,#_ti_,4)
   If !_tool_tip_id_
   {
      Loop,Parse,_tt_hwnd_list_,|
         If WinExist("ahk_id " RegExReplace(A_LoopField,"\d+\."))
            DllCall("DestroyWindow","Uint",hwnd1)
      _tt_hwnd_list_=
      Return
   }
   If options
      Loop,Parse,options,%A_Space%
      {
         option:= SubStr(A_LoopField,1,1)
         ;MsgBox % option "=" SubStr(A_LoopField,2)
         If option
            %option%:= SubStr(A_LoopField,2)
      }
   If RegExMatch(_tt_hwnd_list_,"\|" . _tool_tip_id_ . "\.([^\|]+)",hwnd)
         hwnd := hwnd1
   If (!WinExist("ahk_id " hwnd1) and text!="")
   {
      _tt_hwnd_list_:=RegExReplace(_tt_hwnd_list_,"\|" . _tool_tip_id_ . "\.[^\|]+\|")
      ;MsgBox % O "`n" C "`n" (C ? 80 : 0)+(O ? 115 : 50)
      hWnd := DllCall("CreateWindowEx", "Uint", 0x8, "str", "tooltips_class32", "str", "", "Uint", (C ? 80 : 0)+(O ? 115 : 50), "int", 0, "int", 0, "int", 0, "int", 0, "Uint", 0, "Uint", 0, "Uint", 0, "Uint", 0) ;param4 0xc3 0x80
      _tt_hwnd_list_.= "|" . _tool_tip_id_ . "." . hWnd . "|"
      NumPut(&txt,#_ti_,36)
      DllCall("SendMessage", "Uint", hWnd, "Uint", 1028, "Uint", 0, "Uint", &#_ti_)   ; TTM_ADDTOOL
      DllCall("SendMessage", "Uint", hWnd, "Uint", 1041, "Uint", 1, "Uint", &#_ti_)   ; TTM_TRACKACTIVATE
      WinHide, ahk_id %hWnd%
      If !C
      WinSet, Disable,,ahk_id %hwnd%
      If M
       WinSet,ExStyle,^0x20,ahk_id %hwnd%
   }
   ;MsgBox % options "`n" i x y b f d t
   If ((B!="" ? SetToolTipColor(hwnd,B) :) or (F !="" ? SetToolTipTextColor(hwnd,F) :) and text="")
      DllCall("DestroyWindow","Uint",hwnd), _tt_hwnd_list_:=RegExReplace(_tt_hwnd_list_,"\|" . _tool_tip_id_ . "\.[^\|]+\|")
   else if !D
      ShowToolTip(hwnd,x,y,text,title,I,T)
   else
   {
      A_Timer := A_TickCount, D *= 1000
      Loop
         If (A_TickCount - A_Timer > D or ShowToolTip(hwnd,x,y,text,title,I,T))
            Break
      DllCall("DestroyWindow","Uint",hwnd), _tt_hwnd_list_:=RegExReplace(_tt_hwnd_list_,"\|" . _tool_tip_id_ . "\.[^\|]+\|")
   }
   Return hwnd
}
SetToolTipTitle(hwnd,title,I="0"){
   title := (StrLen(title) < 96) ? title : ("…" . SubStr(title, -97))
   ; TTM_SETTITLE   ; 0: None, 1:Info, 2: Warning, 3: Error. n > 3: assumed to be an hIcon.
   DllCall("SendMessage", "Uint", hWnd, "Uint", 1056, "Uint", I, "Uint", &Title)
}
SetToolTipColor(hwnd,B){
   B := (StrLen(B) < 8 ? "0x" : "") . B
   B := ((B&255)<<16)+(((B>>8)&255)<<8)+(B>>16) ; rgb -> bgr
   DllCall("SendMessage", "Uint", hWnd, "Uint", 1043, "Uint", B, "Uint", 0)   ; TTM_SETTIPBKCOLOR   
}
SetToolTipTextColor(hwnd,F){
   F := (StrLen(F) < 8 ? "0x" : "") . F
   F := ((F&255)<<16)+(((F>>8)&255)<<8)+(F>>16) ; rgb -> bgr
   DllCall("SendMessage", "Uint", hWnd, "Uint", 1044, "Uint",F & 0xFFFFFF, "Uint", 0)   ; TTM_SETTIPTEXTCOLOR
}
ShowToolTip(hwnd,x,y,text,title="",I="0",T=""){
   local xc,yc,xw,ywd
   MouseGetPos, xc,yc
   WinGetPos,xw,yw,,,A
   If (x="caret")
      xc:=xw+A_CaretX+1
   If (y="caret")
      yc:=yw+A_CaretY+15
   DllCall("SendMessage", "Uint", hWnd, "Uint", 1042, "Uint", 0, "Uint", ((x="" ? xc : (x="caret" ? xc : x)) & 0xFFFF)|((y="" ? yc : (y="caret" ? yc : y)) & 0xFFFF)<<16)   ; TTM_TRACKPOSITION
   If (title!="")
      SetToolTipTitle(hwnd,title,I)
   NumPut(&text,#_ti_,36)
   DllCall("SendMessage", "Uint", hWnd, "Uint", 1048, "Uint", 0, "Uint", A_ScreenWidth) ;TTM_SETMAXTIPWIDTH
   DllCall("SendMessage", "Uint", hWnd, "Uint", 0x40c, "Uint", 0, "Uint", &#_ti_)   ; TTM_UPDATETIPTEXT
   WinSet, Disable,,ahk_id %hwnd%
   If T
      WinSet,Transparent,%t%,ahk_id %hwnd%
}

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, chaosad, oldbrother and 18 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