.. but using an entirely different approach.


[color=#225588]/* _ __ _ ____ __
_ __(_) /__ (_) __/__ ___ _________/ / by SKAN - Suresh Kumar A N
| |/|/ / / '_// /\ \/ -_) _ `/ __/ __/ _ \ ( arian.suresh@gmail.com )
|__,__/_/_/\_\/_/___/\__/\_,_/_/ \__/_//_/ Created: 22-Sep-2010
A U T O - C O M P L E T E C O M B O B O X Last Modifed: 23-Sep-2010
www.autohotkey.com/forum/viewtopic.php?t=62794
*/[/color]
wiki := "http://[color=red]en.[/color]wikipedia.org" [color=black]; alter country code like[/color] [color=red]de. fr. it.[/color]
#SingleInstance, Force
Gui, +AlwaysOnTop +ToolWindow +LastFound
Gui, Margin,0,0
Gui, Font, S9
Gui, Add, ComboBox, w275 R10 Simple vQuery gCheckQuery hwndhCombo1
ControlGet, hEdit1, hWnd,, Edit1, ahk_id %hCombo1%
Gui, Font
Gui, Add, Text, y+1 wp 0x201 vStatus, Enter Query
Gui, Add, Text, y+1 wp h1
Gui, Show,, %wiki%
Gui, Add, Button, Default gOpenWiki, OpenWiki
OnMessage( 0x102, "WM_CHAR" )
Return ; // End of Auto-Execute Section //
WM_CHAR( wParam ) {
Global A_LastKey := wParam
}
Deref_Umlauts( w, n=1 ) {
while n := instr( w, "\u",1,n )
stringreplace, w, w, % ww := substr( w,n,6 ), % chr( "0x" substr( ww,3 ) ), all
return w
}
CheckQuery:
IfEqual,A_LastKey,8, Return ; 8 is BackSpace
GuiControlGet, Query
If ( QueryLen := StrLen( Query ) ) && InStr( chkList, "|" Query ) {
GuiControl, ChooseString, Query, %Query%
GuiControlGet, Query
SendMessage, 0xB1, QueryLen, StrLen(Query),, ahk_id %hEdit1% ; EM_SETTEXT
Return
} IfGreater,QueryLen,2, SetTimer, CheckWiki, -500
Return
CheckWiki:
GuiControl,, Status, Please wait....
URLDownloadToFile, %wiki%/w/api.php?action=opensearch&search=%query%,%A_Temp%\wiki.query
If ( ErrorLevel ) {
GuiControl,, Status, Internet connection error!
Return
} FileRead, Result, %A_Temp%\wiki.query
Result := Deref_Umlauts( RegExReplace( Result, "\[|\]" ) )
Loop, Parse, Result, CSV
WL .= ( A_Index > 1 ) ? "|" A_LoopField :
Sort, WL, D|
If ( FirstMatch := SubStr( WL, 2, ( F := InStr( WL,"|",0,2) ) ? F-2 : StrLen( WL ) ) ) {
GuiControl,, Query, % chkList := WL
ControlSetText,, % FirstMatch, ahk_id %hEdit1%
SendMessage, 0xB1, StrLen(query), StrLen(FirstMatch),, ahk_id %hEdit1% ; EM_SETTEXT
} GuiControl,, Status, % ( FirstMatch ? "" : "No entries found!" ) . ( WL := "" )
Return
OpenWiki:
ControlGetText, Query,, ahk_id %hEdit1%
IfNotEqual, Query,, Run, %wiki%/wiki/%query%
GuiEscape:
GuiClose:
ExitApp




