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

    • Sven-Seyfert
      By Sven-Seyfert
      Hi Community,

      I use a UDF by @smashly to play a video in a GUI. That works fine for my main monitor.
      But when I change the X and Y positions of the GUI (also for the video) to my second or third monitor, the video plays, I can hear the sound of it, but I don't see the video.

      I debugged the UDF and checked the Microsoft description for MCI Command Strings which are used in the UDF (docs.microsoft...) - everything is fine, so I got no clue why the video isn't displayed.

      PlayVideoTest.au3:
       
      VideoInGui_by_Smashky.au3 (UDF):
       
      The example video:
       
      It would be great when anyone can help .
      Is there maybe a other way to play (display videos in GUI)?

      Thanks for any suggestion - I'm grateful!
      Sven
    • UEZ
      By UEZ
      Following script shows a parent GUI with a child GUI initialized as MDICHILD.
      #include <Constants.au3> #include <GUIConstantsEx.au3> #include <GuiReBar.au3> #include <GuiScrollBars.au3> #include <GuiToolbar.au3> #include <ScreenCapture.au3> #include <ScrollBarConstants.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() Global Enum $idNew = 1000, $idOpen, $idSave, $idHelper Global Const $iImageW = @DesktopWidth, $iImageH = @DesktopHeight Global Const $hBMP_ScreenCapture = _ScreenCapture_Capture("", 0, 0, $iImageW, $iImageH, False) Global Const $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBMP_ScreenCapture) Sleep(50) Global Const $iW = 1500, $iH = 700, $SC_DRAGMOVE = 0xF012 Global Const $hGUI = GUICreate("Move child GUI within GUI", $iW, $iH) Global Const $hToolbar = _GUICtrlToolbar_Create($hGUI) Global Const $hReBar = _GUICtrlRebar_Create($hGUI, BitOR($CCS_TOP, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS)) Global Const $height_delta = 37 Global Const $idPic = GUICtrlCreatePic("", 0, $height_delta + 2, $iW, $iH) Global $hBitmap_tmp, $hHBitmap_tmp $hBitmap_tmp = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Global $hGfx_Context = _GDIPlus_ImageGetGraphicsContext($hBitmap_tmp) _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR) _GUICtrlToolbar_AddButton($hToolbar, $idNew, $STD_FILENEW) _GUICtrlToolbar_AddButton($hToolbar, $idOpen, $STD_FILEOPEN) _GUICtrlToolbar_AddButton($hToolbar, $idSave, $STD_FILESAVE) _GUICtrlToolbar_AddButtonSep($hToolbar) _GUICtrlToolbar_AddButton($hToolbar, $idHelper, $STD_HELP) _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0) Global Const $iVSscroll = _WinAPI_GetSystemMetrics(2) Global Const $iHSscroll = _WinAPI_GetSystemMetrics(3) Global Const $iYCaption = _WinAPI_GetSystemMetrics(4) Global Const $iYFixedFrame = _WinAPI_GetSystemMetrics(8) Global Const $iXFixedFrame = _WinAPI_GetSystemMetrics(7) Global Const $iMetricsSumX = $iVSscroll + $iXFixedFrame * 2 Global Const $iMetricsSumY = $iHSscroll + $iYCaption + $iYFixedFrame _GUIScrollBars_Init($hGUI) _GUIScrollBars_SetScrollInfoMin($hGUI, $SB_HORZ, 0) _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_HORZ, $iImageW - $iW + 61 + $iMetricsSumX) _GUIScrollBars_SetScrollInfoMin($hGUI, $SB_VERT, 0) _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_VERT, $iImageH - $iH + $iMetricsSumY + $height_delta - 1) GUISetState(@SW_SHOW, $hGUI) Global Const $STM_SETIMAGE = 0x0172 _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBMP_ScreenCapture)) Global $IE_offset_x = 0, $IE_offset_y = 0 DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH) GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL_IE") GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL_IE") Global $iPosX_Crop = 0, $iPosY_Crop = 0, $iW_crop = 200, $iH_crop = 200, $bMove_Crop = True Global $hGUI_IE_Crop = GUICreate("", $iW_crop, $iH_crop, $iPosX_Crop, $iPosY_Crop) GUISetStyle(BitOR($WS_BORDER, $WS_POPUP), $WS_EX_MDICHILD) _WinAPI_SetParent($hGUI_IE_Crop, $hGUI) WinSetTrans($hGUI_IE_Crop, "", 0xA0) Global $iLable_CropMove = GUICtrlCreateLabel("", 0, 0, $iW_crop, $iH_crop, -1, $GUI_WS_EX_PARENTDRAG) GUISetState(@SW_SHOW, $hGUI_IE_Crop) GUIRegisterMsg($WM_MOVE, "WM_MOVE_IE_GUI_Crop") ;~ GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN") Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch Until False GUIRegisterMsg($WM_HSCROLL, "") GUIRegisterMsg($WM_VSCROLL, "") GUIRegisterMsg($WM_MOVE, "") GUIRegisterMsg($WM_LBUTTONDOWN, "") _WinAPI_DeleteObject($hBMP_ScreenCapture) _GDIPlus_BitmapDispose($hBitmap_tmp) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGfx_Context) _GDIPlus_Shutdown() Exit Func WM_HSCROLL_IE($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $lParam Local $Min, $Max, $Page, $TrackPos ; Get all the horizontal scroll bar information Local $tSCROLLINFO_X = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ) $Min = DllStructGetData($tSCROLLINFO_X, "nMin") $Max = DllStructGetData($tSCROLLINFO_X, "nMax") $Page = DllStructGetData($tSCROLLINFO_X, "nPage") ; Save the position for comparison later on $IE_offset_x = DllStructGetData($tSCROLLINFO_X, "nPos") $TrackPos = DllStructGetData($tSCROLLINFO_X, "nTrackPos") #forceref $Min, $Max Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Switch $nScrollCode Case $SB_LINELEFT ; user clicked left arrow DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x - 1) Case $SB_LINERIGHT ; user clicked right arrow DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x + 1) Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x - $Page) Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x + $Page) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO_X, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO_X, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO_X) $IE_offset_x = DllStructGetData($tSCROLLINFO_X, "nPos") DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH) $hHBitmap_tmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_tmp) _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap_tmp)) _WinAPI_DeleteObject($hHBitmap_tmp) $bMove_Crop = False ConsoleWrite($iPosX_Crop & ", " & $iPosY_Crop & " / " & $IE_offset_x & ", " & $IE_offset_y & @CRLF) WinMove($hGUI_IE_Crop, "", -$IE_offset_x + $iPosX_Crop, -$IE_offset_y + $iPosY_Crop) ;~ DllCall("user32.dll", "bool", "MoveWindow", "hwnd", $hGUI_IE_Crop, "int", -$IE_offset_x + $iPosX_Crop, "int", -$IE_offset_y + $iPosY_Crop, "int", $iW_crop, "int", $iH_crop, "bool", True) $bMove_Crop = True Return "GUI_RUNDEFMSG" EndFunc ;==>WM_HSCROLL_IE Func WM_VSCROLL_IE($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $lParam Local $Min, $Max, $Page, $TrackPos ;~ ; Get all the horizontal scroll bar information Local $tSCROLLINFO_Y = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $Min = DllStructGetData($tSCROLLINFO_Y, "nMin") $Max = DllStructGetData($tSCROLLINFO_Y, "nMax") $Page = DllStructGetData($tSCROLLINFO_Y, "nPage") ; Save the position for comparison later on $IE_offset_y = DllStructGetData($tSCROLLINFO_Y, "nPos") $TrackPos = DllStructGetData($tSCROLLINFO_Y, "nTrackPos") #forceref $Min, $Max Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Switch $nScrollCode Case $SB_LINELEFT ; user clicked left arrow DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y - 1) Case $SB_LINERIGHT ; user clicked right arrow DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y + 1) Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y - $Page) Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y + $Page) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO_Y, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO_Y, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO_Y) $IE_offset_y = DllStructGetData($tSCROLLINFO_Y, "nPos") DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH) $bMove_Crop = False ConsoleWrite($iPosX_Crop & ", " & $iPosY_Crop & " / " & $IE_offset_x & ", " & $IE_offset_y & @CRLF) WinMove($hGUI_IE_Crop, "", -$IE_offset_x + $iPosX_Crop, -$IE_offset_y + $iPosY_Crop) ;~ DllCall("user32.dll", "bool", "MoveWindow", "hwnd", $hGUI_IE_Crop, "int", -$IE_offset_x + $iPosX_Crop, "int", -$IE_offset_y + $iPosY_Crop, "int", $iW_crop, "int", $iH_crop, "bool", True) $bMove_Crop = True Return "GUI_RUNDEFMSG" EndFunc ;==>WM_VSCROLL_IE Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) _SendMessage($hGUI_IE_Crop, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndFunc ;==>_WM_LBUTTONDOWN Func WM_MOVE_IE_GUI_Crop($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam If $hWnd = $hGUI_IE_Crop And $bMove_Crop Then $iPosX_Crop = _WinAPI_LoWord($lParam) $iPosY_Crop = _WinAPI_HiWord($lParam) EndIf Return "GUI_RUNDEFMSG" EndFunc ;==>WM_MOVE_IE_GUI_Crop Func WM_SIZE_IE_GUI_Crop($hWnd, $iMsg, $wParam, $lParam) Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZE_IE_GUI_Crop Func DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH) _GDIPlus_GraphicsDrawImageRectRect($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH, 0, 0, $iW, $iH) $hHBitmap_tmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_tmp) _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap_tmp)) _WinAPI_DeleteObject($hHBitmap_tmp) EndFunc  
      My problem: if you move the child window at left upper corner to another place and move either H or V scrollbar the child GUI will be moved properly. BUT if you have scrolled the scrollbars to the right bottom of the image and move the child GUI to that corner, too then the child GUI jumps if you click on one of the scrollbars.
      Is there something that I didn't consider?
    • ahha
      By ahha
      I'm using the excellent _Excel UDF to read a whole spreadsheet into an array I want to operate on.  I can read a specified range without a problem.  What I'd like to do is allow the user in Excel to select a range (contiguous is fine) and be able to read that range so that I know what range to operate on without having the user input the range via a keyboard.  I'm stuck and any hints greatly appreciated.  The code below uses the Helpfile .xls to illustrate where I crash.
      ; #AutoIt3Wrapper_run_debug_mode=Y ; use this to debug in console window <--- LOOK #include <Excel.au3> #include <MsgBoxConstants.au3> #include <Debug.au3> ;for _DebugArrayDisplay $sExcelFullFileName = "C:\Program Files (x86)\AutoIt3\Examples\Helpfile\Extras\_Excel1.xls" ;use Autoit test for example $oExcel = _Excel_Open() ;Create application object and open an Excel workbook $oWorkbook = _Excel_BookOpen($oExcel, $sExcelFullFileName) $aExcelArray = _Excel_RangeRead($oWorkbook, Default) _DebugArrayDisplay($aExcelArray, $aExcelArray) ;let's look at it $aI5K6 = _Excel_RangeRead($oWorkbook, Default,"I5:K6") ;read a rangeI5:K6 and return value _DebugArrayDisplay($aI5K6, $aI5K6) ;let's look at range it ;rather than defining the range explicity I'd like to read the selection in Excel and use it ;need a function like _Excel_SelectionRead ;try hacking Excel.au3 _Excel_RangeRead to see if can create _Excel_SelectionRead looks like .Selection .Value .Text and .Address possible MsgBox($MB_SYSTEMMODAL, "Info", "Select cells in Excel then click OK") ;ACTUALLY get range of the selection and this will suffice for us to use on the $aExcelArray $vRange = $oWorkbook.ActiveSheet.Selection.Address($vRange) ;tried all sorts of permutations and clearly I need help _DebugArrayDisplay($vRange, $vRange) ;let's look at range it ;$vResult = $oExcel.Transpose($vRange.Value) ;_DebugArrayDisplay($vResult, $vResult) ;let's look at range it _Excel_Close($oExcel, False, True) Exit  
    • Emmhor1
      By Emmhor1
      Hi All,

      MAIN QUESTION:
      Is it possible to Call specific function within a GUI

      So I have a script with multiple functions although I don't want to use every function every time.
      My Idea is to create a simple GUI which allows me to select what functions I want to use then run the funtions by clicking a button.
      I have already made a GUI which allows me to select specific .exe's I would like to run after selection it runs the .exe one by one.
      This script is on my work laptops and cannot access it right now.
       
      Who can help me with this?
      GUIcreate
      Func1 
      Func2
      Func3
      Then have a boxes which allows me to select the specif Func.(I used GUIChecked and Unchecked in my other script)
      Then a button which executes/calls the selected functions
    • Blois
      By Blois
      Hi Guis,
       
      I need to create keyboard shortcut to navigate the tabs and activate them, but I could not use the code below:
      #include <TabConstants.au3> #include <WindowsConstants.au3> #include <GuiTab.au3> #include <GUIConstantsEx.au3> HotKeySet("^{TAB}", "_TabRight") HotKeySet("^+{TAB}", "_TabLeft") $gui = GUICreate("test",450, 300) $Tab1 = GUICtrlCreateTab(20, 24, 425, 201) $TabSheet1 = GUICtrlCreateTabItem("Tabsheet 1") $lbContagemGrupos2 = GUICtrlCreateLabel("aaaa", 50, 50) GUICtrlSetColor(-1, 0x0000FF) GUICtrlCreateTabItem("") $TabSheet2 = GUICtrlCreateTabItem(" ") $TabSheet3 = GUICtrlCreateTabItem(" ") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func _TabRight() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos + 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Func _TabLeft() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos - 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Exit  
      can you help me?
×