Kleines Sript das ich unter Zuhilfename von "Intellibox" für meine Firma entwickelt habe.
Könnte an vielen Stellen noch gekürzt werden und es sind unnötige Fehlerroutinen drin, aber vll kann ja irgentwas damit anfangen.
Spoiler anzeigen
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListBoxConstants.au3>
#include <WindowsConstants.au3>
#include <GUIListBox.au3>
#Include <WinAPI.au3>
#include <Misc.au3>
#include <GUIConstants.au3>
Opt("GUICloseOnESC", 0)
[/autoit] [autoit][/autoit] [autoit]#Region ### START Koda GUI section ### Form=
[/autoit] [autoit][/autoit] [autoit]Global $show = False
Global $indexB = -1
Global $SenseGui, $SenseCtrl, $guiBox, $box
Global $POSSenseGui[2]
$text = IniRead(@WorkingDir&"\list.ini","land","land","0") ;Danke an Chip
Global $aData = StringSplit($text,",",2) ;"
$guiBox = GUICreate('', 180, 100, 300, 600, BitOR($WS_SIZEBOX, $WS_POPUP), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
$box = _GUICtrlListBox_Create($guiBox, '', 0, 0, 180, 101, BitOR($LBS_SORT, 0x00B00002))
; ListBox muß 1 Pixel höher als GUI sein - sonst fehlerhafte Darstellung <<<<<<<<<<<<<<<< BEACHTEN !!!!!! >>>>>>>>>>>>>>>>>>>>>>>>>>
For $i = 0 To UBound($aData) -1 ; falls Daten mit _FileReadToArray gelesen werden: StartIndex=1
_GUICtrlListBox_AddString($box, $aData[$i])
Next
#EndRegion Box
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
GUIRegisterMsg($WM_MOVE, "_WM_MOVE")
GUIRegisterMsg(0x231, "_WM_ENTERSIZEMOVE")
#EndRegion - Deklarationen Sense
#Region Main
[/autoit] [autoit][/autoit] [autoit]$Form1 = GUICreate("Tarifsuchmaschine", 554, 150, 360, 400)
$SenseGui = $Form1 ; <== Für Allgemeingültigkeit Zuweisung an $SenseGui
$name = GUICtrlCreateInput("Bitte Land eingeben...", 8, 55, 201, 21)
$button1 = GUICtrlCreateButton("Such!", 8, 80, 201, 33)
$label1 = GUICtrlCreateLabel("Bitte Land eingeben", 8, 16, 204, 17)
$label2 = GUICtrlCreateLabel("", 232, 32, 300, 100)
$Pic1 = GUICtrlCreatePic("", 460, 30, 73, 80)
$us = GUICtrlCreateLabel("Deine Suche: ", 232, 8, 164, 17)
$SenseCtrl = $name ; <== Für Allgemeingültigkeit Zuweisung an $SenseCtrl
$hInput = GUICtrlGetHandle($name)
GUISetState()
#EndRegion Main
$aufbau="0"
$an="0"
$ab="0"
$inet="0"
$sms = "0"
$zahl = "0"
$land= "0"
$font = "Times New Roman Bold"
GuiCtrlSetFont($label1,11,400,0,$font)
GuiCtrlSetFont($us,10,400,4,$font)
GuiCtrlSetFont($button1,9,400,0,$font)
GuiCtrlSetFont($label2,9,400,0,$font)
While 1
_ChooseBox()
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $button1
_lauf()
EndSwitch
WEnd
Func _lauf()
$zahl = IniRead("list.ini", "liste", GUICtrlRead($name),"false")
$land = GuiCtrlRead($name) ;für die spätere angabe vom Land
_suchen()
_ausgabe()
EndFunc
Func _suchen()
$aufbau = IniRead("list.ini","tarif"&$zahl,"aufbau","fehlt")
$an = IniRead("list.ini","tarif"&$zahl,"an","fehlt")
$ab = IniRead("list.ini","tarif"&$zahl,"ab","fehlt")
$sms = IniRead("list.ini","tarif"&$zahl,"sms","fehlt")
$zahl = IniRead("list.ini", "internet", GUICtrlRead($name),"false")
$inet = IniRead("list.ini","inettar"&$zahl,"kosten","fehlt")
EndFunc
func _bilder()
GUICtrlSetImage($pic1,"") ;sonst Bildüberlagerung bei mehrmaliger Suche
GUICtrlSetImage($pic1,@WorkingDir&"\"&$land&".gif")
EndFunc
Func _ausgabe()
If $land = "Deutschland" Then
GuiCtrlSetData($label2,"Abgehend:" &@TAB& $ab& "€ / Minute" & @CRLF& "SMS:" & @TAB &@TAB& $sms & "€"& @CRLF & "Daten:"&@TAB&@TAB& $inet & "€ /50kb")
GuiCtrlSetData($us,"Deine Suche: "&$land)
_bilder()
Elseif $inet = "0,00" Then
GuiCtrlSetData($label2,"Verbingsaufbau:" &@TAB &$aufbau & "€ / Verbindung" & @CRLF & "An ab 61 Minute:"&@TAB & $an & "€ / Minute" & @CRLF & "Abgehend:" &@TAB&@TAB& $ab& "€ / Minute" & @CRLF& "SMS:" & @TAB&@TAB &@TAB& $sms & "€"& @CRLF & "Daten:"&@TAB&@TAB&@TAB& "Kostenlos")
GuiCtrlSetData($us,"Deine Suche: "&$land)
_bilder()
Else
GuiCtrlSetData($label2,"Verbingsaufbau:" & @TAB &$aufbau & "€ / Verbindung" & @CRLF & "An ab 61 Minute:"&@TAB & $an & "€ / Minute" & @CRLF & "Abgehend:" &@TAB&@TAB& $ab& "€ / Minute" & @CRLF& "SMS:" & @TAB&@TAB &@TAB& $sms & "€"& @CRLF & "Daten:"&@TAB&@TAB&@TAB& $inet & "€ /50kb")
GuiCtrlSetData($us,"Deine Suche: "&$land)
_bilder()
Endif
endfunc
#region - SenseFuncs
Func _ChooseBox()
;If Not $show Then Return
If Not $show Or ControlGetText($SenseGui, '', $SenseCtrl) = "" Then
GUISetState(@SW_HIDE, $guiBox)
$show = False
Return
EndIf
If _IsPressed('0D') Then ; ENTER
ControlSetText($SenseGui, '', $SenseCtrl, _GUICtrlListBox_GetText($box, $indexB))
GUISetState(@SW_HIDE, $guiBox)
_lauf()
$show = False
ElseIf _IsPressed('1B') Then ; ESC
GUISetState(@SW_HIDE, $guiBox)
$show = False
ElseIf _IsPressed('26') Then ; UP
If $indexB > 0 Then
$indexB -= 1
_GUICtrlListBox_SetCurSel($box, $indexB)
Sleep(90)
EndIf
ElseIf _IsPressed('28') Then ; DOWN
If $indexB < _GUICtrlListBox_GetCount($box)-1 Then
$indexB += 1
_GUICtrlListBox_SetCurSel($box, $indexB)
Sleep(90)
EndIf
EndIf
EndFunc
Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
Local $nNotifyCode = BitShift($wParam, 16)
Local $hCtrl = $lParam
Local $hSenseCtrl = $SenseCtrl
If Not IsHWnd($hSenseCtrl) Then $hSenseCtrl = GUICtrlGetHandle($hSenseCtrl)
If ($nNotifyCode = 1024 Or $nNotifyCode = 6) And $hCtrl = $hSenseCtrl Then
Local $str = ControlGetText($SenseGui, '', $SenseCtrl)
$indexB = _GUICtrlListBox_FindString($box, $str)
_GUICtrlListBox_SetCurSel($box, $indexB)
$caret = _CaretPos()
If Not @error And Not $show Then
If $caret[3] + $caret[4] - 95 < 0 Then ; Platz für Liste über dem Ctrl ausreichend?
WinMove($guiBox, '', $caret[0], $caret[1] + 30) ; Versatz 25 (Ctrlhöhe+5) unter y vom Ctrl
Else
WinMove($guiBox, '', $caret[0] - 5, $caret[1] + 15) ; Versatz 95 (Boxhöhe+10) über y vom Ctrl
EndIf
GUISetState(@SW_SHOWNOACTIVATE, $guiBox)
$show = True
EndIf
ElseIf $hCtrl = $box And $nNotifyCode = 1 Then
$indexB = _GUICtrlListBox_GetCurSel($box)
ControlSetText($SenseGui, '', $SenseCtrl, _GUICtrlListBox_GetText($box, $indexB))
GUISetState(@SW_HIDE, $guiBox)
$show = False
ElseIf $show And $nNotifyCode = 512 And $hCtrl = $lParam And Not $hCtrl = $box Then
GUISetState(@SW_HIDE, $guiBox)
$show = False
EndIf
Return $GUI_RUNDEFMSG
EndFunc ;==>MY_WM_COMMAND
Func _WM_ENTERSIZEMOVE($hWnd)
If $hWnd = $SenseGui Then $POSSenseGui = WinGetPos($SenseGui)
EndFunc ;==>_WM_ENTERSIZEMOVE
Func _WM_MOVE($hWnd)
If $hWnd = $SenseGui Then
Local $pos = WinGetPos($guiBox)
Local $postemp = WinGetPos($SenseGui)
WinMove($guiBox, "", $pos[0] - ($POSSenseGui[0] - $postemp[0]), $pos[1] - ($POSSenseGui[1] - $postemp[1]))
$POSSenseGui = WinGetPos($SenseGui)
EndIf
EndFunc ;==>_WM_MOVE
Func _CaretPos()
Local $old = Opt("CaretCoordMode", 0) ;relative mode
Local $c = WinGetCaretPos() ;relative caret coords
Local $w = WinGetPos("") ;window's coords
Local $f = ControlGetFocus("", "") ;text region "handle"
Local $e = ControlGetPos("", "", $f) ;text region coords
Local $h = ControlGetHandle("", "", $f) ;Ctrl-Handle
Local $t[5]
If IsArray($c) And IsArray($w) And IsArray($e) Then
If _WinAPI_IsClassName($SenseCtrl, 'Edit') Then ; Input wird als Edit-Class erkannt
$t[0] = $c[0] + $w[0] + $e[0]
ElseIf _WinAPI_IsClassName($SenseCtrl, 'ComboBox') Then
$t[0] = $w[0] + $e[0]
EndIf
$t[1] = $c[1] + $w[1] + $e[1]
$t[2] = $h
$t[3] = $w[1]
$t[4] = $e[1]
Opt("CaretCoordMode", $old)
Return $t ;absolute screen coords of caret cursor
Else
Opt("CaretCoordMode", $old)
SetError(1)
EndIf
EndFunc ;==>_CaretPos
#endregion - SenseFuncs
die dafür nötige list.ini
Spoiler anzeigen
[land]
land = USA, Kanada, Bayern
[liste]
USA = USA
Kanada = Kanada
Bayern = Bayern
[tarifUSA]
aufbau = 0,63
an = 0,21
ab = 0,21
sms = 0,25
[tarifKanada]
aufbau = 0,10
an = 0,10
ab = 0,10
sms = 0,10
[tarifBayern]
aufbau = 0,20
an = 0,20
ab = 0,20
sms = 0,20
[internet]
USA = 0
Kanada = 1
Bayern = 2
[inettar0]
kosten= 0,00
[inettar1]
kosten = 0,10
[inettar2]
kosten = 0,20