顯示具有 Autohotkey 標籤的文章。 顯示所有文章
顯示具有 Autohotkey 標籤的文章。 顯示所有文章

2013年8月20日 星期二

禁用滑鼠中鍵點擊

#IfWinActive ahk_class Chrome_WidgetWin_1
MBUTTON::
Click Middle
Sleep 10
Sendinput {ESC}
Return

2013年8月19日 星期一

多個控制項水平排列

Gui, Add, Text, Section, Your first name: 
Gui, Add, Edit, vName w250 ys, %vName% 
Gui, Show
Return

參考
http://www.autohotkey.com/board/topic/70051-horizontal-layout-for-multiple-gui-controls/

放置控制項到群組方塊

;我用來放置控制項的兩個方法(忽略是否將控制項放在一個群組方塊裡面)
;1. 在你的控制項中的其中一個使用關鍵字 SECTION。後來的控制項,就使用xs+NN ys+NN來放置它。
;2. 使用相對位置 - x+NN y+NN 和 xp+NN yp+NN。
#SingleInstance Force

Gui Margin, 5,5
Gui Add, GroupBox, w300 h200, Tada

; Example 1: Without the use of section
Gui Add, Edit, xp+10 yp+20 w100, Edit
Gui Add, Edit, xp y+4 wp, Edit
Gui Add, Edit, xp y+4 wp, Edit
Gui Add, Edit, xp y+4 wp, Edit
Gui Add, Edit, xp y+4 wp, Edit

; Example 2: With SECTION
Gui Add, Edit, x+30 y25 w80 section, Nice Edit
Gui Add, Edit, xs y+4 wp, Nice Edit
Gui Add, Edit, xs y+4 wp, Nice Edit
Gui Add, Edit, xs y+4 wp, Nice Edit

Gui Show

ESC::ExitApp

參考
http://www.autohotkey.com/board/topic/39510-position-of-controls-in-a-groupbox/

2013年1月28日 星期一

compare two string

reference
MatchList = one,two,three,four,five ; list of possible matches (may be made case sensitive)

var = two      ; string to search for
if var in %MatchList%
  msgbox, found "%var%"
else
 msgbox, "%var%" not found

timer stopwatch

reference
StartTime := A_TickCount
Sleep, 1000
ElapsedTime := A_TickCount - StartTime
MsgBox,  %ElapsedTime% milliseconds have elapsed.

2013年1月21日 星期一

ControlGetText example

reference
#singleinstance force
CoordMode, ToolTip, screen
CoordMode, Mouse, screen
return

;======== show the information from a single tooltip =========
F1::
ControlGetText, tooltip2,,ahk_class tooltips_class32
;tooltip, ******************`n%tooltip2%`n******************, 1300, 300
;sleep, 1000
;tooltip
msgbox, %tooltip2%
return


;======== show the information from a multiple tooltips =========
F2::
WinGet, ID, LIST,ahk_class tooltips_class32
tt_text=
Loop, %id%
{
  this_id := id%A_Index%
  ControlGetText, tooltip2,,ahk_id %this_id%
  tt_text.= "******************`n" tooltip2 "`n******************`n"
}

;tooltip, %tt_text%, 300, 300
msgbox, %tt_text%
;sleep, 3000
;tooltip

return

ocr library

reference

Save print screen as jpg

reference
irfanview has many commands, example
(note: screenshot1 and screenshots are path-variables)
~printscreen::
ifexist,%screenshot1%\irfanview.exe
    {
    run, "%screenshot1%\irfanview.exe" "/capture=0 /convert=%screenshots%\%A_now%_screenshot.jpg"
   sleep,500
   run,%screenshots%  ;open folder
   return
    }
return


~!printscreen::       ;copy only active window
ifexist,%screenshot1%\irfanview.exe
    {
    run, "%screenshot1%\irfanview.exe" "/capture=2 /convert=%screenshots%\%A_now%_screenshot.jpg"
   sleep,500
   run,%screenshots%
   return
    }
return

Bring window to foreground

reference
+#w::
SetTitleMatchMode, 2 ; approximate match
IfWinExist, - Microsoft Word
{
WinActivate, - Micrsoft Word
}
IfWinNotExist, - Microsoft Word
{
Run FullFilePathToMicrosoftWord
}
return