#include #include #include #include HotKeySet("^1", "searching") $search = "" ; if its going to be a string, its good practice to declare it as a string Global $sIni = @ScriptDir & "\answers.ini" While 1 Sleep(1) WEnd Func _test() Local $sAnswer = "" $sAnswer = IniRead($sIni, "answers", $search, "Sorry No answer available") If StringInStr($sAnswer,"") Then $aAnswer = StringSplit($sAnswer,"",1) $sAnswer = "" For $i = 1 To $aAnswer[0] $sAnswer &= $aAnswer[$i] & @CR Next EndIf _Sendex ($sAnswer) $search = "" ;Reset string EndFunc ;==>_test Func searching() $search &= InputGui("Test input", "Please enter a search term:" & @CRLF & "Available terms:" & @CRLF & @CRLF, 180, 130 ) _test() EndFunc ;==>search Func _SendEx($ss) Local $iT = TimerInit() While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12") If TimerDiff($iT) > 2000 Then MsgBox(262144, "Warning", "Shift, Ctrl and Alt keys need to be released to proceed!") $iT = TimerInit() ; reset the timer EndIf WEnd Send($ss) $search = "" ;Reset string EndFunc ;==>_SendEx Func InputGui($titletxt = "", $TextMSG = "", $w = 300, $h = 120) If $w < 85 Then $w = 85 If $h < 85 Then $h = 85 Local $MyGui = GUICreate($titletxt, $w, $h, -1, -1, $WS_POPUP + $WS_CAPTION) Local $Edit = GUICtrlCreateEdit($TextMSG, 4, 4, $w - 8, $h - 55, BitOR($ES_AUTOVSCROLL, $ES_READONLY, $WS_VSCROLL)) Local $input = GUICtrlCreateInput("", 4, $h - 50, $w - 8, 20, $ES_WANTRETURN) Local $buttonOK = GUICtrlCreateButton("OK", 4, $h - 25, 35, 20) Local $buttonCA = GUICtrlCreateButton("Cancel", $w - 45, $h - 25, 40, 20) GUISetState(@SW_SHOW) Local $final, $tmp, $itxt, $itxtold, $Err = 0 Local $WinPos While 1 $WinPos = WinGetPos($MyGui) $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $buttonCA $Err = 1 ExitLoop Case $msg = $buttonOK Or _IsPressed("0D") ExitLoop EndSelect $itxt = GUICtrlRead($input) If $itxt <> $itxtold Then $itxtold = $itxt $tmp = ReadIniAnswers($itxt) _GUICtrlEdit_BeginUpdate($Edit) GUICtrlSetData($Edit, "", 1) GUICtrlSetData($Edit, $TextMSG & $tmp) _GUICtrlEdit_EndUpdate($Edit) EndIf Sleep(10) WEnd If $Err = 0 Then $final = GUICtrlRead($input) GUIDelete($MyGui) Return $final Else GUIDelete($MyGui) SetError(1) Return "" EndIf EndFunc ;==>InputGui Func ReadIniAnswers($text) Local $array = IniReadSection($sIni, "answers") Local $list = "" Local $x, $y For $x = 1 To $array[0][0] For $y = StringLen($text) To 1 Step -1 If StringLeft($array[$x][0], $y) = $text Then $list = $list & $array[$x][0] & @CRLF ExitLoop EndIf Next Next Return $list EndFunc ;==>ReadIniAnswers