Code: Select all
; a little gui with some text from the manual
Gui 1:Add, Button, gFindString, Search
Gui 1:Add, Edit, w100 vfind
Gui 1:Add, Edit, w330 r3 vContent HSCROLL
Gui 1:Add, StatusBar,, Ctrl+F to search
SB_SetParts(300)
GuiControl, Hide, Button1
GuiControl, Hide, Edit1
Gui 1:Show,, FindSample
WinGet ControlID, ID, FindSample
someText=
(
Creating a script
Each script is a plain text file containing commands
to be executed by the program (AutoHotkey.exe).
A script may also contain hotkeys and hotstrings, or
even consist entirely of them. However, in the absence
of hotkeys and hotstrings, a script will perform its
commands sequentially from top to bottom the moment
it is launched.
To create a new script:
Open Windows Explorer and navigate to a folder of
your choice.
Pull down the File menu and choose New >> AutoHotkey
Script (or Text Document).
Type a name for the file, ensuring that it ends in .ahk.
For example: Test.ahk
Right-click the file and choose Edit Script.
On a new blank line, type the following:
#space::Run www.google.com
The symbol # stands for the Windows key, so #space means
holding down the Windows key then pressing the spacebar
to activate a hotkey. The :: means that the subsequent
command should be executed whenever this hotkey is
pressed, in this case to go to the Google web site.
To try out this script, continue as follows:
Save and close the file.
In Windows Explorer, double-click the script to launch
it. A new tray icon appears. Hold down the Windows key
and press the spacebar. A web page opens in the default
browser.
To exit or edit the script, right click its tray icon.
Note: Multiple scripts can be running simultaneously,
each with its own tray icon. Furthermore, each script
can have multiple hotkeys and hotstrings.
)
Guicontrol,,Edit2, %someText%
return
FindString:
Gui, Submit, Nohide
if (find != lastFind) {
offset = 0
hits = 0
}
GuiControl 1:Focus, Content ; focus on main help window to show selection
SendMessage 0xB6, 0, -999, Edit2, ahk_id %ControlID% ; Scroll to top
StringGetPos pos, Content, %find% ,,offset ; find the position of the search string
if (pos = -1) {
if (offset = 0) {
SB_SetText("'" . find . "' not found", 1)
SB_SetText("", 2)
}
else {
SB_SetText("No more occurrences of '" . find . "'")
SB_SetText("", 2)
offset = 0
hits = 0
}
return
}
StringLeft __s, Content, %pos% ; cut off end to count lines
StringReplace __s,__s,`n,`n,UseErrorLevel ; Errorlevel <- line number
addToPos=%Errorlevel%
SendMessage 0xB6, 0, ErrorLevel, Edit2, ahk_id %ControlID% ; Scroll to visible
SendMessage 0xB1, pos + addToPos, pos + addToPos + Strlen(find), Edit2, ahk_id %ControlID% ; Select search text
; http://msdn.microsoft.com/en-us/library/bb761637(VS.85).aspx
; Scroll the caret into view in an edit control:
SendMessage, EM_SCROLLCARET := 0xB7, 0, 0, Edit2, ahk_id %ControlID%
offset := pos + addToPos + Strlen(find)
lastFind = %find%
hits++
SB_SetText("'" . find . "' found in line " . addToPos + 1, 1)
SB_SetText(hits . (hits = 1 ? " hit" : " hits"), 2)
Return
^f::
GuiControl, Show, Button1
GuiControl, Show, Edit1
Sleep 100
ControlFocus, Edit1, A
Return
Code: Select all
vDir1 = c:
Gui,2:default
Gui 2:Add, Button,gSearch, Search
Gui 2:Add, Edit, w100 vfind
Gui,2: Add , ListView, r25 w323 backgroundGray cYellow grid vLV1 gLV1a altsubmit Multi, #|%vDir1%|Fullpath|Date
LV_ModifyCol(1,0)
LV_ModifyCol(2,200)
LV_ModifyCol(3,0)
LV_ModifyCol(4,100)
LV_ModifyCol(1,"integer")
LV_ModifyCol(2,"left")
LV_ModifyCol(4,"digit")
LV_ModifyCol(4, "left")
Gui,2: Show
gosub,fill
return
exitapp
Fill:
Gui,2: Submit, Nohide
Loop, 2
Gui,2:ListView, LV%A_Index%
ib=0
LV_Delete()
Loop, Files, % vDir1 "\*", D ;- folders
{
if A_LoopFileName in %foldersBlacklist%
{
excludedFolders .= """" . A_LoopFileFullPath . """ "
continue
}
ib++
SplitPath,A_LoopFileFullPath, name, dir, ext, name_no_ext, drive
LV_Add("",ib,name,A_LoopFileFullPath,a_loopfiletimemodified)
}
LV_ModifyCol(4, "Logical SortDesc")
return
;----------------
LV1a:
Gui,2: Submit, Nohide
Loop, 2
Gui,2:ListView, LV%A_Index%
RC:=LV_GetNext("C")
RF:=LV_GetNext("F")
GC:=LV_GetCount()
If A_GuiEvent=Doubleclick
{
LV_GetText(C1,A_EventInfo,1)
LV_GetText(C2,A_EventInfo,2)
LV_GetText(C3,A_EventInfo,3)
LV_GetText(C4,A_EventInfo,4)
path := c3
;~ msgbox, %path%
goto, goit!
return
}
return
goit!:
msgbox, %path%
return
Search:
MsgBox, help me to mark the finded row on the listview