Jump to content
Sign in to follow this  
javip

is there a better way than CASE select for Combo selection?

Recommended Posts

javip

so my script was made to load drivers based on a selection from a combo box. i've created a VERY robust system to load drivers when imaging with wds or ghost using a winPE wim. WDS does not work correctly with injected drivers. so comes into play my script/program that loads from a winPE wim after wds loads. anyone knows WDS is pretty powerful but it does not always have proper drivers once the winPE loads. so my program loads drivers into winPE based on the model / device. so if we get a new model of laptop or desktop and we want to save up that image to wds we find 32bit drivers and we load them into my program.

wds then in turn loads my winPE with my program set to autolaunch and presenting all these options. if winPE contained a generic driver then all is good. if not then we go through my list and usually one of the drivers does work but in case it doesn't we add to my list.

that's just the pre-amble incase anyone asks what i'm doing.

reminder that this has worked flawlessly for the better part of a year. but now with more devices it's getting cumbersome to manually edit my code, then compile, then mount edit and recompile the winPE wim and inject my autoit program into it.

takes a maximum of 5 minutes but when you're constantly testing it gets VERY bad.

 

here's a snippet of the array for the combobox.

Local $aList[300][2] = [["___________", "___________"], _
        ["ASUS", "ASUS"], _
        ["HP Probook 4430s", "HP Probook 4430s"], _
        ["Lenovo S10-3", "Lenovo S10-3"], _
        ["Lenovo x200/x230", "Lenovo x200/x230"], _

so this populates a combo box that lists these entries.

i use a case select to determine which box was selected. very manual editing when i need to add another device.

Func selection()

    $sSel = GUICtrlRead($cb_platform)
    $iIndex = _ArraySearch($aList, $sSel)
    Select
        Case $iIndex = 1 ;~ ASUS
            $driver = (@scriptdir & "\drivers\hp32\Netrtl32.inf")
            $nothing = $option

        Case $iIndex = 2 ;~ HP Probook 4430s
            $driver = (@scriptdir & "\drivers\hp4430\hp86win7.inf")
            $nothing = $option

        Case $iIndex = 3 ;~ Lenovo S10-3
            $driver = (@scriptdir & "\drivers\lenovos103\Netrtl32.inf")
            $nothing = $option

EndFunc

this is the part of the script which i'm trying to revamp. right now my script works very awesome for what we're doing. however i want it more streamlined.

as you can see once a combobox selection is selected, then it goes to that CASE and populates those variables then it kicks down to a function that i have that continues either ghost or wds depending on a selected radio box.

this is what i have now for the array for the combobox.

$drivers_folder=_FileListToArray(@scriptdir & "\drivers\","*",2)
$cb_platform = GUICtrlCreateCombo("",10,40,600,120,-1,-1)

For $i=1 To Ubound($drivers_folder)-1
    GUICtrlSetData($cb_platform,$drivers_folder[$i])
Next

this populates the combox based on the folder i have with each individual device. instead of creating a long winded array.

the problem i have now is i don't know how to make it load the driver within that folder without a case select.

i was thinking maybe something that got the name of the folder selected, then appended a "*.inf" at the end to load. but i'm totally in the dark of how to do this.

if you'd like me to post all my code to help, please let me know.

 

Share this post


Link to post
Share on other sites
FireFox

Hi,

What about this kind of array?

Local $aList[300][3] = _
        ["ASUS", "ASUS", "hp32\Netrtl32.inf"], _
        ["HP Probook 4430s", "HP Probook 4430s", "hp4430\hp86win7.inf"], _
        ["Lenovo S10-3", "Lenovo S10-3", "lenovos103\Netrtl32.inf"]]

...
$driver = @ScriptDir & "\drivers\" & $aList[$iIndex][2]
Edit: Added indents.

Br, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
javip

well the thing is i don't want to use that kind of array. manual editing. the way i want to do it is the new way where it pulls the directory listing. so to add a new driver to my program all i need to do is drop the new device folder into the drivers folder. then when the program is launched the new folder is there in the combobox.

each driver folder is independent and containts only one .inf for that device. so using a *.inf wildcard to load it wouldn't hurt anything.

Edited by pixeldotz

Share this post


Link to post
Share on other sites
FireFox

If you don't want to have an array, these informations have to be stored somewhere. Maybe in an ini in each driver's folder or in the inf files.

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
jdelaney

How about:

#include <GUIConstantsEx.au3>
#include <array.au3>
$sDir = @scriptdir & "\driver"

$aFolders = _FileListToArray($sDir,"*",2)
_ArrayDelete($aFolders,0)
$string = _ArrayToString($aFolders)
Local $msg
GUICreate("My GUI combo") ; will create a dialog box that when displayed is centered

$combo = GUICtrlCreateCombo("", 10, 10) ; create first item
GUICtrlSetData(-1,  $string) ; add other item snd set a new default

GUISetState()

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()

    If $msg = $combo Then
        $Folder = GUICtrlRead($combo)
        $sINFFolder = $sDir & "\" & $Folder
        $aTemp = _FileListToArray( $sINFFolder, "*.inf",1)
        If UBound($aTemp)=2 Then
            ; Get the driver
            ConsoleWrite("your driver=[" & $sINFFolder & "\" & $aTemp[1] & "]" & @CRLF)
        Else
            ConsoleWrite("no driver, or multiple drivers, in=[" & $sINFFolder & "\" & "]" & @CRLF)
        EndIf
        $aTemp = ""
    EndIf

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
javip

that would be fine too since it would require editing only one external file instead of adding everything and recompiling. this would also keep everything nice and in alphabetical order.

how would i go about doing that? i've never done a split or loaded from an inf file.

Share this post


Link to post
Share on other sites
FireFox

Take a look at the Ini* functions, it's really simple :)


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
javip

i got it to read using this little code.

$cbox = IniReadSection("device.ini","Config")

For $i = 1 To $cbox[0][0]
        GUICtrlSetData($cb_platform,$cbox[$i][1])
    Next
EndIf

this populates the combobox beautifully. now i'm stuck on the case part. i can do another IniReadSection into another array but how would that work to call my functions? or rather how would that work at all. i'm stumped.

Share this post


Link to post
Share on other sites
FireFox

You can populate an array according to your ini file :

[drivers]
name1=ASUS
displayname1=ASUS
path1=hp32\Netrtl32.inf

name2=HP Probook 4430s
displayname2=HP Probook 4430s
path2=hp4430\hp86win7.inf
There is for sure a better structure way for the ini, but the idea is here.

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
jdelaney

If you had a section ([section]) for each driver folder, then you could key off the combobox selection to drive the INI reading as well.


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
javip

that displays the name and the path in the 'path' thing.

what i was thinking of was something like this.

[device]

name1=ASUS
name2=HP Probook 4430s

[drivers]

path1=(@scriptdir & "AsusNetrtl32.inf")

path2=(@scriptdir & "hp4430hp86win7.inf)

so when i select ASUS i want it to also select path1 and if i select HP i want it to select path2 etc.

then put that as a variable in

            $driver = WHATEVER WAS SELECTED
            $nothing = $option

im totally stumped on this second part.

Share this post


Link to post
Share on other sites
jdelaney

less logic if it looked like this...loop through IniReadSectionNames:

[Case1]

name=ASUS
path=(@scriptdir & "AsusNetrtl32.inf")

 

[Case2]

name=HP Probook 4430s

path=(@scriptdir & "hp4430hp86win7.inf)

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
jdelaney

try this...not doing any action, just populating data, for now:

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <array.au3>
$sDir = @scriptdir & "\driver"

$aFolders = _FileListToArray($sDir,"*",2)
_ArrayDelete($aFolders,0)
$string = _ArrayToString($aFolders)
Local $msg
$gui = GUICreate("My GUI combo") ; will create a dialog box that when displayed is centered

$combo = GUICtrlCreateCombo("", 10, 10) ; create first item
GUICtrlSetData(-1,  $string) ; add other item snd set a new default

$aPos = WinGetPos($gui)

Global $button = GUICtrlCreateButton("Start",10,$aPos[3]-80, 50, 40,$BS_DEFPUSHBUTTON)
GUICtrlSetState($button,$GUI_DISABLE)
GUISetState()
$aDrivers=""
$driver = ""
; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()

    Select
        Case $msg = $combo
            $Folder = GUICtrlRead($combo)
            $sINFFolder = $sDir & "\" & $Folder
            $aTemp = _FileListToArray( $sINFFolder, "*.inf",1)
            If UBound($aTemp)=2 Then
                ; Get the driver
                ConsoleWrite("your driver=[" & $sINFFolder & "\" & $aTemp[1] & "]" & @CRLF)
                $aDrivers = CreateDriverControls($aDrivers, $sINFFolder & "\" & $aTemp[1])
            Else
                ConsoleWrite("no driver, or multiple drivers, in=[" & $sINFFolder & "\" & "]" & @CRLF)
            EndIf
        Case $msg = $button
            ConsoleWrite("Do something with driver=[" & $driver & "]." & @CRLF)

        Case _ArraySearch($aDrivers,$msg,0,0,0,0,1,0)>0
            $driver=$aDrivers[_ArraySearch($aDrivers,$msg,0,0,0,0,1,0)][1]
            ConsoleWrite("changed radio selection to=[" & $driver & "]." & @CRLF)
            If Not BitAND(GUICtrlGetState($button),$GUI_ENABLE) Then GUICtrlSetState($button,$GUI_ENABLE)
    EndSelect

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Func CreateDriverControls ($aDrivers, $sINIFile)
    If BitAND(GUICtrlGetState($button),$GUI_ENABLE) Then GUICtrlSetState($button,$GUI_DISABLE)
    For $i = 0 To UBound($aDrivers) - 1
        For $j = 0 To UBound($aDrivers,2) - 1
            GUICtrlDelete($aDrivers[$i][$j])
        Next
    Next
    $aTemp              = IniReadSection($sINIFile, "device")
    $aTemp2             = IniReadSection($sINIFile, "drivers")
    $iStart             = 40
    $iControlHeight     = 20
    $iControlSpacing    = 10
    For $i = 1 To UBound($aTemp)-1
        $aTemp[$i][0] = GUICtrlCreateRadio($aTemp[$i][1], $iControlSpacing,$iStart+($iControlSpacing*$i)+($iControlHeight*$i), 100 )
        $aTemp2[$i][1] = GUICtrlCreateEdit($aTemp2[$i][1], 100+$iControlSpacing,$iStart+($iControlSpacing*$i)+($iControlHeight*$i), 250 )
    Next
    Return $aTemp
EndFunc
Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
javip

 

try this...not doing any action, just populating data, for now:

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <array.au3>
$sDir = @scriptdir & "\driver"

$aFolders = _FileListToArray($sDir,"*",2)
_ArrayDelete($aFolders,0)
$string = _ArrayToString($aFolders)
Local $msg
$gui = GUICreate("My GUI combo") ; will create a dialog box that when displayed is centered

$combo = GUICtrlCreateCombo("", 10, 10) ; create first item
GUICtrlSetData(-1,  $string) ; add other item snd set a new default

$aPos = WinGetPos($gui)

Global $button = GUICtrlCreateButton("Start",10,$aPos[3]-80, 50, 40,$BS_DEFPUSHBUTTON)
GUICtrlSetState($button,$GUI_DISABLE)
GUISetState()
$aDrivers=""
$driver = ""
; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()

    Select
        Case $msg = $combo
            $Folder = GUICtrlRead($combo)
            $sINFFolder = $sDir & "\" & $Folder
            $aTemp = _FileListToArray( $sINFFolder, "*.inf",1)
            If UBound($aTemp)=2 Then
                ; Get the driver
                ConsoleWrite("your driver=[" & $sINFFolder & "\" & $aTemp[1] & "]" & @CRLF)
                $aDrivers = CreateDriverControls($aDrivers, $sINFFolder & "\" & $aTemp[1])
            Else
                ConsoleWrite("no driver, or multiple drivers, in=[" & $sINFFolder & "\" & "]" & @CRLF)
            EndIf
        Case $msg = $button
            ConsoleWrite("Do something with driver=[" & $driver & "]." & @CRLF)

        Case _ArraySearch($aDrivers,$msg,0,0,0,0,1,0)>0
            $driver=$aDrivers[_ArraySearch($aDrivers,$msg,0,0,0,0,1,0)][1]
            ConsoleWrite("changed radio selection to=[" & $driver & "]." & @CRLF)
            If Not BitAND(GUICtrlGetState($button),$GUI_ENABLE) Then GUICtrlSetState($button,$GUI_ENABLE)
    EndSelect

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Func CreateDriverControls ($aDrivers, $sINIFile)
    If BitAND(GUICtrlGetState($button),$GUI_ENABLE) Then GUICtrlSetState($button,$GUI_DISABLE)
    For $i = 0 To UBound($aDrivers) - 1
        For $j = 0 To UBound($aDrivers,2) - 1
            GUICtrlDelete($aDrivers[$i][$j])
        Next
    Next
    $aTemp              = IniReadSection($sINIFile, "device")
    $aTemp2             = IniReadSection($sINIFile, "drivers")
    $iStart             = 40
    $iControlHeight     = 20
    $iControlSpacing    = 10
    For $i = 1 To UBound($aTemp)-1
        $aTemp[$i][0] = GUICtrlCreateRadio($aTemp[$i][1], $iControlSpacing,$iStart+($iControlSpacing*$i)+($iControlHeight*$i), 100 )
        $aTemp2[$i][1] = GUICtrlCreateEdit($aTemp2[$i][1], 100+$iControlSpacing,$iStart+($iControlSpacing*$i)+($iControlHeight*$i), 250 )
    Next
    Return $aTemp
EndFunc

that's way above my head : . i am making progress though. i'm using an ini formatted as

[devices]
ASUS=\\asus.inf
HP=\\hp.inf

0 is the name and 1 is the path, after a selection is made i want "1" to be set into a variable. that is the last problem i'm having. i think i've been looking at the code too long.

 

here's the code that population of combo box.

$cbox = IniReadSection("device.ini","devices")

If @error Then
    MsgBox(4096, "", "Error occurred, probably no INI file.")
Else
For $i = 1 To $cbox[0][0]
        GUICtrlSetData($cb_platform,$cbox[$i][0])
    Next
End

and here's the function.

Func selection()

    $sSel = GUICtrlRead($cb_platform)
    $iIndex = _ArraySearch($cbox, $ssel)
    

            $driver = (@scriptdir & $iIndex)
            MsgBox(1, "",$driver)
        ;    $nothing = $option

EndFunc

using  this function all i get it does is display the "case" of the select item so for install it shows c:asuscase when the first option is selected and c:hpcase1 when the second is selected.

i know i'm close i'm just looking at it to hard i think.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Similar Content

    • Bllee
      By Bllee
      every time i press "delete button" delete a line, but i can't add new line with info. the id line write normally but i can't change or add new info
      obs: looking at the "includes" one realizes that already tried of everything that knew
      my code
      #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> #include <WinAPI.au3> #include <StringConstants.au3> #include <Array.au3> #include <GuiListBox.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 612, 480, 192, 154) $MenuItem1 = GUICtrlCreateMenu("&Arquivo") $MenuItem2 = GUICtrlCreateMenuItem("Salvar Ctrl+S", $MenuItem1, $SS_CENTER) $MenuItem4 = GUICtrlCreateMenuItem("Carregar Ctrl+O", $MenuItem1, $SS_CENTER) $MenuItem3 = GUICtrlCreateMenuItem("Salvar Como Shitft+Ctrl+S", $MenuItem1, $SS_CENTER) $Group1 = GUICtrlCreateGroup("", 21, 8, 569, 97, $SS_CENTER) $Input1 = GUICtrlCreateInput("ID COR", 122, 32, 97, 21, $SS_CENTER) $Input2 = GUICtrlCreateInput("REGIÃO", 138, 64, 249, 21, $SS_CENTER) $Input3 = GUICtrlCreateInput("Label", 264, 30, 121, 21, $SS_CENTER) $Label1 = GUICtrlCreateLabel("Label", 232, 32, 30, 17, $SS_CENTER) $Button1 = GUICtrlCreateButton("Capturar Cor", 42, 30, 75, 25, $SS_CENTER) $Button2 = GUICtrlCreateButton("Capturar Região", 42, 62, 91, 25, $SS_CENTER) $Button3 = GUICtrlCreateButton("ADD", 442, 24, 113, 33) $Button5 = GUICtrlCreateButton("Delet", 442, 64, 113, 33) $Group2 = GUICtrlCreateGroup("Editar ID selecionado", 8, 384, 601, 57, $SS_CENTER) $Input7 = GUICtrlCreateInput("ID", 10, 402, 40,21, $SS_CENTER) $Input4 = GUICtrlCreateInput("COR", 51, 402, 121, 21, $SS_CENTER) $Input5 = GUICtrlCreateInput("REGIÃO", 173, 402, 249, 21, $SS_CENTER) $Input6 = GUICtrlCreateInput("LABEL", 423, 402, 121, 21, $SS_CENTER) $Button4 = GUICtrlCreateButton("\/", 544, 400, 30, 25, $SS_CENTER) $Button6 = GUICtrlCreateButton("/\", 574, 400, 30, 25, $SS_CENTER) ; Add column Global $id = Int(0) $List1 = GUICtrlCreateListView("",5, 120, 601, 253, $SS_CENTER) _GUICtrlListView_AddColumn($List1, "ID",40) _GUICtrlListView_AddColumn($List1, "COR",100) _GUICtrlListView_AddColumn($List1, "COORDENADA",305) _GUICtrlListView_AddColumn($List1, "LABEL",150) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $MenuItem2 MsgBox($MB_SYSTEMMODAL, "ctrl + s", "Nothing Here",1) Case $MenuItem3 MsgBox($MB_SYSTEMMODAL, "shift+ctrl s", "Nothing Here",1) Case $MenuItem4 MsgBox($MB_SYSTEMMODAL, "ctrl + o", "Nothing Here",1) Case $Button1 MsgBox($MB_SYSTEMMODAL, "Capturar cor", "Aperte espaço para capturar a cor") GUICtrlSetData($Input1,MouseColor()) Case $Button2 MsgBox($MB_SYSTEMMODAL, "capturar região", "Aperte espaço para capturar a posição inicial") local $mouse = MouseGetPos() $x_init = $mouse[0] $y_init = $mouse[1] MsgBox($MB_SYSTEMMODAL, "capturar região", "Aperte espaço para capturar a posição final") local $mouse = MouseGetPos() $x_end = $mouse[0] $y_end = $mouse[1] GUICtrlSetData($Input2,$x_init&','&$y_init&' ; '&$x_end&','&$y_end) Case $Button3 _GUICtrlListView_AddItem($List1, $id, 1) ; id _GUICtrlListView_AddSubItem($List1, $id, GUICtrlRead($Input1), 1, 1) ;cor _GUICtrlListView_AddSubItem($List1, $id, GUICtrlRead($Input2), 2, 1) ;coordenada _GUICtrlListView_AddSubItem($List1, $id, GUICtrlRead($Input3), 3, 1) ;label $id= $id + 1 Case $Button4 $Item = _GUICtrlListView_GetSelectedIndices($List1) $Sid = _GUICtrlListView_GetItem($List1, Number($Item),0) $Scor = _GUICtrlListView_GetItem($List1, Number($Item),1) $Scord = _GUICtrlListView_GetItem($List1, Number($Item),2) $Slabel = _GUICtrlListView_GetItem($List1, Number($Item),3) ; get info GUICtrlSetData($Input7,$Sid[3]) GUICtrlSetData($Input4,$Scor[3]) GUICtrlSetData($Input5,$Scord[3]) GUICtrlSetData($Input6,$Slabel[3]) Case $Button5 _GUICtrlListView_DeleteItemsSelected($List1) Case $Button6 ; give back inf if GUICtrlRead($Input7) <> "ID" Then _GUICtrlListView_SetItem($List1, GUICtrlRead($Input4), GUICtrlRead($Input7),1) ;cor _GUICtrlListView_SetItem($List1, GUICtrlRead($Input5), GUICtrlRead($Input7),2) ;coordenada _GUICtrlListView_SetItem($List1, GUICtrlRead($Input6), GUICtrlRead($Input7),3) ;coordenada EndIf EndSwitch WEnd Func MouseColor() local $mouse = MouseGetPos() Return Hex(PixelGetColor($mouse[0],$mouse[1]), 6) EndFunc  
    • kelso
      By kelso
      Hello Guru's,
       
      I'm trying to write an autoit script to select from the dropdown list as you see in the attached picture. 
      I read the help page for _IEFormElementOptionSelect, but I cannot grasp how to correlate that with the source code that I'm seeing. any suggestions?

    • FrancescoDiMuro
      By FrancescoDiMuro
      Good evening everyone
      First, I want to apologize with you for the title not very clear, but I thought a little bit on which title to set at the thread, and this is the one that came in mind.
      Now, let me explain what I'm trying to understand.

      I am making an application ( with n clients ), with an SQLite Database, which has a Main form, and n sub-forms... 
      Since these sub-forms are called several times, because they are used to add or update records to the Database, I put the code that generates the GUI of these sub-forms in Functions.
      There are two sub-forms which are "treated" as two main forms, since even them have n sub-forms, which perform various tasks.
      Where am I stucked?

      For the Main form I created a Status Bar, in order to display messages ( add/delete/update/search results ), and it works perfectly with all the forms which don't have other sub-forms.
      For the two forms, which indeed have n sub-forms, I created two separated Status Bars, which are (re)created everytime I call the function that then displays the form.
      Practically, I can't set icons to these two Status Bars, and I don't know why.
      I'm really sorry that I don't feel clear enough, so, here you are an example of what I am saying.
      I recreated exactly what my script does:
      #include <GuiButton.au3> #include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) Global $frmSubForm, _ $txtSubFormField, _ $sbSubFormStatusBar, _ $objSB_IconError = _WinAPI_LoadShell32Icon(109), _ $objSB_IconInformation = _WinAPI_LoadShell32Icon(277) #Region ### START Koda GUI section ### Form= $frmMainForm = GUICreate("Main Form", 300, 300, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "ExitApplication") $sbMainStatusBar = _GUICtrlStatusBar_Create($frmMainForm) $btnCreateSubForm = GUICtrlCreateButton("Create Sub Form", 105, 110, 75, 41, BitOR($BS_CENTER,$BS_VCENTER,$BS_MULTILINE)) GUICtrlSetOnEvent(-1, "GenerateSubForm") GUICtrlSetFont(-1, 10, 400, 0, "Arial") _GUICtrlStatusBar_SetSimple($sbMainStatusBar) _GUICtrlStatusBar_SetText($sbMainStatusBar, "") GUISetState(@SW_SHOW, $frmMainForm) #EndRegion ### END Koda GUI section ### While 1 Sleep(100) WEnd Func ExitApplication() Exit EndFunc Func GenerateSubForm() #Region ### START Koda GUI section ### Form= $frmSubForm = GUICreate("Sub-Form", 300, 300, -1, -1, -1, -1, $frmMainForm) GUISetOnEvent($GUI_EVENT_CLOSE, "DeleteSubForm") $txtSubFormField = GUICtrlCreateInput("", 0, 0, 100, 20) $btnCheckSubFormField = GUICtrlCreateButton("Check Field", 105, 110, 75, 41, BitOR($BS_CENTER,$BS_VCENTER,$BS_MULTILINE)) GUICtrlSetOnEvent(-1, "CheckSubFormField") GUICtrlSetFont(-1, 10, 400, 0, "Arial") $sbSubFormStatusBar = _GUICtrlStatusBar_Create($frmSubForm) _GUICtrlStatusBar_SetSimple($sbSubFormStatusBar) _GUICtrlStatusBar_SetText($sbSubFormStatusBar, "") GUISetState(@SW_SHOW, $frmSubForm) GUISetState(@SW_DISABLE, $frmMainForm) #EndRegion ### END Koda GUI section ### EndFunc Func DeleteSubForm() ; Declared Globally => $frmSubForm GUIDelete($frmSubForm) GUISetState(@SW_ENABLE, $frmMainForm) EndFunc Func WriteToStatusBar($sbStatusBar, $objSB_Icon, $strText) _GUICtrlStatusBar_SetIcon($sbStatusBar, 0, $objSB_Icon) _GUICtrlStatusBar_SetText($sbStatusBar, $strText) ConsoleWrite("Icon Handle: " & $objSB_Icon & @CRLF) EndFunc Func CheckSubFormField() ; Declared Globally => $txtSubFormField If GUICtrlRead($txtSubFormField) = "" Then ; Declared Globally => $sbStatusBar WriteToStatusBar($sbSubFormStatusBar, $objSB_IconError, "Field NOK.") Else WriteToStatusBar($sbSubFormStatusBar, $objSB_IconInformation, "Field OK.") EndIf EndFunc The text is set, but icon is not.
      Could someone please tell me why?
      Thanks everyone in advance  

      Best Regards.
    • odaylton
      By odaylton
      Hello everyone ,
      Text translated from Portuguese by google - please apologize for any errors

      Once again I need a light from the gurus of this wonderful website
      I am fanatic by combobox for its usability but I am not able to uncertain images within lists ...
      I know uncertain icons, and cursors but I am not able to insert gif or jpg images.
      1) How to solve this ...
      2) will the path is to convert gif into bmp and then uncertain ... how to do that?
      #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> ;dados de mouse #include <WinAPIRes.au3> ;COMBO #include <GuiComboBoxEx.au3> ;Fonts #include <FontConstants.au3> ;obter imagem de arquivo #include <GDIPlus.au3> #include <WinAPIGdi.au3> Example() Func Example() Local $hGUI, $hImage, $hCombo, $hFont Local $idListview, $hImage Local $sWow64 = "" Local $Pasta = "C:\WINDOWS\Cursors\3dgarro.cur" Local $PastaROMs = @MyDocumentsDir & "\Stella\ROMs\" ;com barra no final $hGUI = GUICreate("ImageList", 500, 310) GUISetFont(14, 400, 0, "Arial") ;<<<<<<<<<<this does not work for _GUICtrlComboBoxEx_Create $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 494, 200) ;GUICtrlSetFont($hCombo, 14, 400, 0, "Arial");<<<<<<<<<<It does not work ; ;Create a handle to a font object $hFont = _WinAPI_CreateFont(30, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial') ;Pass the handle to _WinAPI_SetFont _WinAPI_SetFont($hCombo, $hFont) $idListview = GUICtrlCreateListView("", 2, 50, 494, 250, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)) GUISetState(@SW_SHOW) ; Initialize GDI+ library _GDIPlus_Startup() ; Load images $hImage = _GUIImageList_Create(120, 70, 6, 2) ;32,32,5,5) ; $DadosCombo = "Escolha|" & _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 120, 70)) ;Local $aCursors[] = [32650, 32512, 32515, 32649, 32651, 32513, 32648, 32646, 32643, 32645, 32642, 32644, 32516, 32514] For $i = 1 To 10 $sFile = FileOpenDialog("Please select an image", $PastaROMs, "Image (*.jpg;*.png;*.bmp;*.gif;*.tif)", BitOR($FD_PATHMUSTEXIST, $FD_FILEMUSTEXIST)) If @error Then Exit MsgBox(BitOR($MB_TOPMOST, $MB_ICONERROR), "Error", "No image file has been selected", 30) $a = _GDIPlus_BitmapCreateFromFile ($sFile);<<<<< ok If @error Or Not $hImage Then MsgBox(BitOR($MB_TOPMOST, $MB_ICONERROR), "Error", "This file isn't supported by GDIPlus!") Else $b=_GUIImageList_Add($hImage, $a);<<<<<< Return -1 $DadosCombo &= "|" & $i & "_img_princ.gif""|" & $b EndIf Next _GUICtrlListView_SetImageList($idListview, $hImage, 1) _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage) ; Add columns _GUICtrlListView_AddColumn($idListview, "Icons - Mouses", 350) ; Add items $a = StringSplit($DadosCombo, "|") For $i = 1 To $a[0] Step 2 _GUICtrlListView_AddItem($idListview, $a[$i], $a[$i + 1]) _GUICtrlComboBoxEx_AddString($hCombo, $a[$i], $a[$i + 1], $a[$i + 1]) Next ;AutoIt_Debugger_Command:Disable_Debug ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() ;AutoIt_Debugger_Command:Enable_Debug EndFunc ;==>Example tks
    • Reziskonh
      By Reziskonh
      Hi, everybody
      I look for GUI whose behavior similar to the message of an email client or antivirus
      In other words:
          Any PC screen able to calculate the size
          To consider the Task bar size
          To find the lower corner on the right/below and to nestle on it

      Notes:
      In GUI the GUICtrlCreateEdit field (as option) - that can be received and displayed through variable information
      Thanks a lot
      PS
      I use the translator, excuse if something is not clear
       

×