Yashied

Skin UDF

11 posts in this topic

#1 ·  Posted (edited)

LAST VERSION - 0.2

03-Jan-15

Skin UDF allows you to create buttons from the predefined images (files, resources, etc.). I rewrote this library by using GDI+ (first version used GDI). This allowed add the many additional features and get rid of the problems related to the transparency. Nevertheless, the library has a beta status, so there is no detailed description of the functions. But I am sure that the example below gives complete information about the features of this library. I hope that many users will find it useful. If you will have any questions, please ask them in this thread.
 

Skin.png


Available functions

_Skin_AddButton
_Skin_AddButtonEx
_Skin_DeleteButton
_Skin_Destroy
_Skin_DisableButton
_Skin_EnableFocus
_Skin_EnableKBInput
_Skin_Helper
_Skin_SetButton
_Skin_SetButtonEx
_Skin_SetFocusRect

Skin Library v1.0

Skin.zip


Example

#Include <GUIConstantsEx.au3>
#Include <Skin.au3>

Global $Button[3]

$hForm = GUICreate('MyGUI', 278, 106)

GUICtrlCreatePic('background.bmp', 0, 0, 278, 106)
GUICtrlSetState(-1, $GUI_DISABLE)

; Create buttons from PNG images (images should be located in the same folder as the script)
$Button[0] = _Skin_AddButton(20 , 20, 66, 66, 'red_normal.png', 'red_hover.png', 'red_click.png', 'disable.png', 'alpha.png', 1)
$Button[1] = _Skin_AddButton(106, 20, 66, 66, 'yellow_normal.png', 'yellow_hover.png', 'yellow_click.png', 'disable.png', 'alpha.png', 1)
$Button[2] = _Skin_AddButton(192, 20, 66, 66, 'green_normal.png', 'green_hover.png', 'green_click.png', 'disable.png', 'alpha.png', 1)

#cs

; Create buttons from GDI+ HBITMAP handles
$Button[0] = _Skin_AddButtonEx(20 , 20, 64, 64, _GDIPlus_BitmapCreateFromFile('red_normal.png'), ..., 1, 1)
$Button[1] = _Skin_AddButtonEx(104, 20, 64, 64, _GDIPlus_BitmapCreateFromFile('yellow_normal.png'), ..., 1, 1)
$Button[2] = _Skin_AddButtonEx(188, 20, 64, 64, _GDIPlus_BitmapCreateFromFile('green_normal.png'), ..., 1, 1)

#ce

; Disable "Yellow" button (Optional)
_Skin_DisableButton($Button[1], 1)

; Enable keyboard input (Optional)
_Skin_EnableKBInput(1)

; Set margins for dotted focus rectangle (Optional)
For $i = 0 To 2
    _Skin_SetFocusRect($Button[$i], 5, 5, 56, 56)
Next

; Enable dotted focus rectangle (Optional)
_Skin_EnableFocus(1)

GUISetState()

; _Skin_Helper() must be called continuously in the main loop
While 1
    _Skin_Helper($hForm)
    $ID = GUIGetMsg()
    Switch $ID
        Case 0
            ContinueLoop
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $Button[0]
            ConsoleWrite('Red' & @CR)
        Case $Button[1]
            ConsoleWrite('Yellow' & @CR)
        Case $Button[2]
            ConsoleWrite('Green' & @CR)
        Case Else

    EndSwitch
WEnd

; You must delete all created buttons before destroying the appropriate window
;~For $i = 0 To 2
;~  _Skin_DeleteButton($Button[$i])
;~Next
Edited by Yashied
2 people like this

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Thank you!
This is exactly what I was looking for.

Excellent project
You came just at the right time in perfect accuracy :)

Edit:

I need it to work with embedded images with Resources UDF

I would love if you add such support

Edit2:

My request is valid if you did not added such support ..
I'll check the UDF in more detail later..

Edited by gil900

Share this post


Link to post
Share on other sites

I need it to work with embedded images with Resources UDF

All you need is a _Skin_AddButtonEx() function. Here's an example:

#Region Resources
#AutoIt3Wrapper_Res_File_Add=background.bmp, 2, 200
#AutoIt3Wrapper_Res_File_Add=red_normal.png, PNG, RED_NORMAL
#AutoIt3Wrapper_Res_File_Add=red_hover.png, PNG, RED_HOVER
#AutoIt3Wrapper_Res_File_Add=red_click.png, PNG, RED_CLICK
#AutoIt3Wrapper_Res_File_Add=yellow_normal.png, PNG, YELLOW_NORMAL
#AutoIt3Wrapper_Res_File_Add=yellow_hover.png, PNG, YELLOW_HOVER
#AutoIt3Wrapper_Res_File_Add=yellow_click.png, PNG, YELLOW_CLICK
#AutoIt3Wrapper_Res_File_Add=green_normal.png, PNG, GREEN_NORMAL
#AutoIt3Wrapper_Res_File_Add=green_hover.png, PNG, GREEN_HOVER
#AutoIt3Wrapper_Res_File_Add=green_click.png, PNG, GREEN_CLICK
#AutoIt3Wrapper_Res_File_Add=alpha.png, PNG, ALPHA
#EndRegion Resources

#Include <GDIPlus.au3>
#Include <GUIConstantsEx.au3>
#Include <Memory.au3>
#Include <Skin.au3>
#Include <WinAPIEx.au3>

Global $hInstance = _WinAPI_GetModuleHandle('')
Global $hBitmap[10] = ['RED_NORMAL', 'RED_HOVER', 'RED_CLICK', 'YELLOW_NORMAL', 'YELLOW_HOVER', 'YELLOW_CLICK', 'GREEN_NORMAL', 'GREEN_HOVER', 'GREEN_CLICK', 'ALPHA']
Global $Button[3]

_GDIPlus_Startup()
For $i = 0 To 9
    $hBitmap[$i] = _LoadResourceImage($hInstance, 'PNG', $hBitmap[$i])
Next
_GDIPlus_Shutdown()

$hForm = GUICreate('MyGUI', 278, 106)
GUICtrlCreatePic('', 0, 0, 278, 106)
GUICtrlSendMsg(-1, 0x0172, 0, _WinAPI_LoadBitmap($hInstance, 200))
GUICtrlSetState(-1, $GUI_DISABLE)
$Button[0] = _Skin_AddButtonEx(20 , 20, 66, 66, $hBitmap[0], $hBitmap[1], $hBitmap[2], 0, $hBitmap[9], 1)
$Button[1] = _Skin_AddButtonEx(106, 20, 66, 66, $hBitmap[3], $hBitmap[4], $hBitmap[5], 0, $hBitmap[9], 1)
$Button[2] = _Skin_AddButtonEx(192, 20, 66, 66, $hBitmap[6], $hBitmap[7], $hBitmap[8], 0, $hBitmap[9], 1)
_Skin_EnableKBInput(1)
For $i = 0 To 2
    _Skin_SetFocusRect($Button[$i], 5, 5, 56, 56)
Next
_Skin_EnableFocus(1)
GUISetState()

While 1
    _Skin_Helper($hForm)
    $ID = GUIGetMsg()
    Switch $ID
        Case 0
            ContinueLoop
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $Button[0]
            ConsoleWrite('Red' & @CR)
        Case $Button[1]
            ConsoleWrite('Yellow' & @CR)
        Case $Button[2]
            ConsoleWrite('Green' & @CR)
        Case Else

    EndSwitch
WEnd

Func _LoadResourceImage($hInstance, $sType, $sName, $iLanguage = 0)

    Local $hInfo, $hData, $pData, $iSize, $hMem, $pMem, $pStream, $hBitmap

    If Not $hInstance Then
        $hInstance = _WinAPI_GetModuleHandle('')
    EndIf
    If $iLanguage Then
        $hInfo = _WinAPI_FindResourceEx($hInstance, $sType, $sName, $iLanguage)
    Else
        $hInfo = _WinAPI_FindResource($hInstance, $sType, $sName)
    EndIf
    $hData = _WinAPI_LoadResource($hInstance, $hInfo)
    $iSize = _WinAPI_SizeOfResource($hInstance, $hInfo)
    $pData = _WinAPI_LockResource($hData)
    If @Error Then
        Return SetError(1, 0, 0)
    EndIf
    $hMem = _MemGlobalAlloc($iSize, $GMEM_MOVEABLE)
    $pMem = _MemGlobalLock($hMem)
    _WinAPI_MoveMemory($pMem, $pData, $iSize)
    _MemGlobalUnlock($hMem)
    $pStream = _WinAPI_CreateStreamOnHGlobal($hMem)
    _GDIPlus_Startup()
    $hBitmap = _GDIPlus_BitmapCreateFromStream($pStream)
    _GDIPlus_Shutdown()
    _WinAPI_ReleaseStream($pStream)
    If Not $hBitmap Then
        Return SetError(2, 0, 0)
    EndIf
    Return $hBitmap
EndFunc   ;==>_LoadResourceImage

#cs

Func _GDIPlus_BitmapCreateFromStream($pStream)

    Local $Ret = DllCall($ghGDIPDll, 'uint', 'GdipCreateBitmapFromStream', 'ptr', $pStream, 'handle*', 0)

    If (@Error) Or ($Ret[0]) Then
        Return SetError(1, 0, 0)
    EndIf
    Return $Ret[2]
EndFunc   ;==>_GDIPlus_BitmapCreateFromStream

#ce
1 person likes this

Share this post


Link to post
Share on other sites

I will dare to answer my own question :)

There is an UDF developed for this

Just add to includes

#include "NoFocusLines.au3"
#include <ButtonConstants.au3>

; And declare in Globals

$fGlobal = True ; this will switch off all spots and lines for all controls

Already tested in WIN 8

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Awesome work, thanks man :D that is just what I needed.

Edited by Kira16651

Share this post


Link to post
Share on other sites

Thank you for this great UDF

There is a tiny select-like area around the image with button. Is it possible to remove it?

 

All you need to do is comment-out line 37 of Skin_Ex.au3.

Line 36 explains it.

Share this post


Link to post
Share on other sites

Unless I'm missing something... does this no longer work with the current AutoIt? It skins everything correctly but it doesn't seem to allow the buttons to be clicked. It flashes as if you clicked it but the Switch never works. Nothing is written to the Console.

 

Thanks!


MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Share this post


Link to post
Share on other sites

In new version of autoit..is not working this script.

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

  • Similar Content

    • thoms
      By thoms
      Hello Forum,
      As said in the title, I'm searching a way to disable all tabstops in a GUI. My GUI includes 15 buttons and 3 edit controls.
      My questions:
      - is there a way to disable all tabstops at a time
      - is there a way to list all controls of a GUI and then disable tabstops one by one
      - or should I use the following line after each button creation:
      _WinAPI_SetWindowLong(GUICtrlGetHandle(-1), $GWL_STYLE, BitAND(_WinAPI_GetWindowLong(GUICtrlGetHandle(-1), $GWL_STYLE), BitNOT($WS_TABSTOP))) Thanks in advance for your valuable help!
      Thoms
      Edit: or maybe disable TAB key? I don't remember how to do!
    • AppSoftwareVld
      By AppSoftwareVld
      Hello,
       
      I need this for a project and I don't find a method for the next problem.
      I want when I click a button to create a variable ("$variable1") so if I press one more time to create one more ("$variable2") and create more and more how many times you press the button.
       
      Do you have an idea ? 
      Thank you for your attention !
    • rte7
      By rte7
      Hello. We work with the BMC Remedy site to manage incidents and would like to automate the processes of clicking through this button code:
      <a href="javascript:" class="btn btn3d menu" style="top:21; left:184; width:21; height:21;"> <img class="btnimg" src="../../../../resources/images/mt_sprites.gif" alt="menu category issue" title=""> </a> I use firefox with mozrepl and autoit with include FF.au3
      I need your help
      I read the topic https://www.autoitscript.com/forum/topic/95595-ffau3-v0601b-10/ but I could not run the code from the listed commands
      ...
      It is necessary to press the button and from the list of the menu of cahorsations to select the item = "zone of trust abonent"
      Screen # 1 http://joxi.ru/52aJK7bh4a7ypA or below.
      1) Press button
      <a href="javascript:" class="btn btn3d menu" style="top:21; left:184; width:21; height:21;"> <img class="btnimg" src="../../../../resources/images/mt_sprites.gif" alt="menu category issue" title=""> </a>
      2) After pressing the button, I need to choose in this menu of 4 items to select an item called "zone of trust abonent", Screen # 2 - http://joxi.ru/p27gwQKHo71VQ2
      html code table items
      <table class="MenuTable" cellpadding="0" cellspacing="0" style="width: 179px;"> <tbody class="MenuTableBody"> <tr class="MenuTableRow"> <td class="MenuEntryName" nowrap="">zone of trust abonent</td> <td class="MenuEntryNoSub" arvalue="zone of trust abonent"></td> </tr> <tr class="MenuTableRow"><td class="MenuEntryName" nowrap="">zone of trust operator</td> <td class="MenuEntryNoSub" arvalue="zone of trust operator"></td> </tr> <tr class="MenuTableRow"><td class="MenuEntryName" nowrap="">zone of trust third operator</td> <td class="MenuEntryNoSub" arvalue="zone of trust third operator"></td></tr> <tr class="MenuTableRow"><td class="MenuEntryNameHover" nowrap="">No settings</td> <td class="MenuEntryNoSubHover" arvalue="No settings"></td> </tr> </tbody> </table>
       
       
      More in detail, I choose from the menu item "zone of trust abonent" Screen # 3 - http://joxi.ru/GrqVq4ZIQEPW4m

       
      3) The choice is made, Screen # 4 http://joxi.ru/v297w6aC3PovLr
      <textarea class="text sr " wrap="off" id="arid_WIN_0_1000002488" cols="20" maxlen="60" style="top:21; left:0; width:179; height:21;" armenu="CFG:PRC:CategoryHPD-Res-T1-Q" mstyle="2" arautoc="1" arautocmb="1" arautocak="0" arautoctt="400" rows="1"> </textarea>
       
      It's all. I would be very grateful to you =) !!!!!!!!!!
      Here are more detailed codes in the attachment. 
      button1.txt
      menu - table.txt
      all.txt
    • Nareshm
      By Nareshm
      I create message box but i dont know how to add button action when i click it.

      Help for : Add script for Button : Left, Right, Right Finger
      example when i press Left finger button do Case $idNotepad
                      $iPID = WinActivate ( " :PS :: Version - 2.8.0.0  - [eFS Bill]")
                              ControlSend(" :DS  - eF :: Version - 2.8.0.0  - [eF Bill]", "", "[NAME:btnReset]", "{esc}")
                              ControlClick ( " :DS  - eF :: Version - 2.8.0.0  - [eF Bill]", "", "[NAME:txtrdNo]")
                              ControlSend(" :DS  - eF:: Version - 2.8.0.0  - [eF Bill]", "", "[NAME:txtrdNo]", "^v")
                              ControlSend(" :DS  - eF :: Version - 2.8.0.0  - [eF Bill]", "", "[NAME:txtrdNo]", "{enter}")
      How to add like above ?
                    
                                                                sorry for my bad english
       
    • Rimoun
      By Rimoun
      Hello everyone
      I would like to have some help regarding my issue.
      I am trying to extract some information from excel sheet, I use _Excel_RangeFind then I get the array for the value then I check the array. In case the array is true the next will be to get some information based on the extracted array if no array because the value is not found it gives a messages box that the value is not found.
      My problem that the button works for one time only if i tried any value which exist in the sheet it gives me that value not found.
      I suspect that there is a problem regarding While loop.
      here is my code
      #include <GUIConstantsEx.au3> #include <WinAPI.au3> #Include <GuiListBox.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <Excel.au3> #include <MsgBoxConstants.au3> #include <ExcelConstants.au3> if FileExists ("result.txt") Then Sleep (100) Else readxl() EndIf Global $oExcel = _Excel_Open(False,False) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeFind Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Global $oWorkbook = _Excel_BookOpen($oExcel, "D:\info.xlsx",False,False) If @error Then MsgBox($MB_SYSTEMMODAL, "Excel Error", "Error opening workbook '" & $oWorkbook & @CRLF & "@error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) Exit EndIf Local $lab1 = _Excel_RangeRead($oWorkbook, Default,"B1") Local $lab2 = _Excel_RangeRead($oWorkbook, Default,"C1") Local $lab3 = _Excel_RangeRead($oWorkbook, Default,"D1") Local $lab4 = _Excel_RangeRead($oWorkbook, Default,"E1") Global $sResult1,$sResult2,$sResult3,$sResult4,$sResult5,$sResult6 Global $asKeyWords = stringsplit (FileRead (@ScriptDir & "\result.txt"),@CRLF) Global Const $xlUp = -4162 ;~ _Main() Local $hGUI, $hList, $hInput, $aSelected, $sChosen, $hUP, $hDOWN, $hENTER, $hESC Local $sCurrInput = "", $aCurrSelected[2] = [-1, -1], $iCurrIndex = -1, $hListGUI = -1 $hGUI = GUICreate("Rimo System", 253, 270, 192, 124) Global $hInput = GUICtrlCreateInput("", 24, 48, 169, 21) Global $Label1 = GUICtrlCreateLabel("Rimo System", 80, 16, 150, 25) GUICtrlSetFont(-1, 14, 800, 0, "MS Serif") Global $Input2 = GUICtrlCreateInput("", 72, 144, 161, 21) Global $Input3 = GUICtrlCreateInput("", 72, 176, 161, 21) Global $Input4 = GUICtrlCreateInput("", 72, 208, 161, 21) Global $Input5 = GUICtrlCreateInput("", 72, 240, 161, 21) $Input6 = GUICtrlCreateInput("", 72, 272, 161, 21) $Input7 = GUICtrlCreateInput("", 72, 304, 161, 21) $Button1 = GUICtrlCreateButton("Get Info", 72, 88, 89, 33) $Label2 = GUICtrlCreateLabel("Label2", 16, 144, 36, 17) GUICtrlSetData( -1,$lab1) $Label3 = GUICtrlCreateLabel("Label3", 16, 176, 36, 17) GUICtrlSetData( -1,$lab2) $Label4 = GUICtrlCreateLabel("Label4", 16, 208, 36, 17) GUICtrlSetData( -1,$lab3) $Label5 = GUICtrlCreateLabel("Label5", 16, 240, 36, 17) GUICtrlSetData( -1,$lab4) $Label6 = GUICtrlCreateLabel("", 16, 272, 36, 17) $Label7 = GUICtrlCreateLabel("", 16, 304, 36, 17) $Button2 = GUICtrlCreateButton("Cancel", 112, 416, 121, 25) GUISetState(@SW_SHOW, $hGUI) Global $sSearch = guictrlread ($hInput) $hUP = GUICtrlCreateDummy() $hDOWN = GUICtrlCreateDummy() $hENTER = GUICtrlCreateDummy() $hESC = GUICtrlCreateDummy() Dim $AccelKeys[4][2] = [["{UP}", $hUP], ["{DOWN}", $hDOWN], ["{ENTER}", $hENTER], ["{ESC}", $hESC]] GUISetAccelerators($AccelKeys) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $Button2 Exit Case $Button1 Global $aResult = _Excel_RangeFind($oWorkbook, guictrlread($hInput) ,"A2:A2000") Global $aExtract = _ArrayExtract($aResult, 0, 0, 2, 2) if _elementExists($aExtract,0) Then getdata() Else MsgBox(0,"","Value Does Not Exist") EndIf Case $hESC If $hListGUI <> -1 Then ; List is visible. GUIDelete($hListGUI) $hListGUI = -1 Else ExitLoop EndIf Case $hUP If $hListGUI <> -1 Then ; List is visible. $iCurrIndex -= 1 If $iCurrIndex < 0 Then $iCurrIndex = 0 EndIf _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndIf Case $hDOWN If $hListGUI <> -1 Then ; List is visible. $iCurrIndex += 1 If $iCurrIndex > _GUICtrlListBox_GetCount($hList) - 1 Then $iCurrIndex = _GUICtrlListBox_GetCount($hList) - 1 EndIf _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndIf Case $hENTER If $hListGUI <> -1 And $iCurrIndex <> -1 Then ; List is visible and a item is selected. $sChosen = _GUICtrlListBox_GetText($hList, $iCurrIndex) EndIf Case $hList $sChosen = GUICtrlRead($hList) EndSwitch Sleep(10) $aSelected = _GetSelectionPointers($hInput) If GUICtrlRead($hInput) <> $sCurrInput Or $aSelected[1] <> $aCurrSelected[1] Then ; Input content or pointer are changed. $sCurrInput = GUICtrlRead($hInput) $aCurrSelected = $aSelected ; Get pointers of the string to replace. $iCurrIndex = -1 If $hListGUI <> -1 Then ; List is visible. GUIDelete($hListGUI) $hListGUI = -1 EndIf $hList = _PopupSelector($hGUI, $hListGUI, _CheckInputText($sCurrInput, $aCurrSelected)) ; ByRef $hListGUI, $aCurrSelected. EndIf If $sChosen <> "" Then GUICtrlSendMsg($hInput, 0x00B1, $aCurrSelected[0], $aCurrSelected[1]) ; $EM_SETSEL. _InsertText($hInput, $sChosen) $sCurrInput = GUICtrlRead($hInput) GUIDelete($hListGUI) $hListGUI = -1 $sChosen = "" EndIf WEnd GUIDelete($hGUI) Func _CheckInputText($sCurrInput, ByRef $aSelected) Local $sPartialData = "" If (IsArray($aSelected)) And ($aSelected[0] <= $aSelected[1]) Then Local $aSplit = StringSplit(StringLeft($sCurrInput, $aSelected[0]), " ") $aSelected[0] -= StringLen($aSplit[$aSplit[0]]) If $aSplit[$aSplit[0]] <> "" Then For $A = 1 To $asKeyWords[0] If StringLeft($asKeyWords[$A], StringLen($aSplit[$aSplit[0]])) = $aSplit[$aSplit[0]] And $asKeyWords[$A] <> $aSplit[$aSplit[0]] Then $sPartialData &= $asKeyWords[$A] & "|" EndIf Next EndIf EndIf Return $sPartialData EndFunc ;==>_CheckInputText Func _PopupSelector($hMainGUI, ByRef $hListGUI, $sCurr_List) Local $hList = -1 If $sCurr_List = "" Then Return $hList EndIf $hListGUI = GUICreate("", 280, 160, 23, 62, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_MDICHILD), $hMainGUI) $hList = GUICtrlCreateList("", 0, 0, 170, 150, BitOR(0x00100000, 0x00200000)) GUICtrlSetData($hList, $sCurr_List) GUISetControlsVisible($hListGUI) ; To Make Control Visible And Window Invisible. GUISetState(@SW_SHOWNOACTIVATE, $hListGUI) Return $hList EndFunc ;==>_PopupSelector Func _InsertText(ByRef $hEdit, $sString) #cs Description: Insert A Text In A Control. Returns: Nothing #ce Local $aSelected = _GetSelectionPointers($hEdit) GUICtrlSetData($hEdit, StringLeft(GUICtrlRead($hEdit), $aSelected[0]) & $sString & StringTrimLeft(GUICtrlRead($hEdit), $aSelected[1])) Local $iCursorPlace = StringLen(StringLeft(GUICtrlRead($hEdit), $aSelected[0]) & $sString) GUICtrlSendMsg($hEdit, 0x00B1, $iCursorPlace, $iCursorPlace) ; $EM_SETSEL. EndFunc ;==>_InsertText Func _GetSelectionPointers($hEdit) Local $aReturn[2] = [0, 0] Local $aSelected = GUICtrlRecvMsg($hEdit, 0x00B0) ; $EM_GETSEL. If IsArray($aSelected) Then $aReturn[0] = $aSelected[0] $aReturn[1] = $aSelected[1] EndIf Return $aReturn EndFunc ;==>_GetSelectionPointers Func GUISetControlsVisible($hWnd) ; By Melba23. Local $aControlGetPos = 0, $hCreateRect = 0, $hRectRgn = _WinAPI_CreateRectRgn(0, 0, 0, 0) Local $iLastControlID = _WinAPI_GetDlgCtrlID(GUICtrlGetHandle(-1)) For $i = 3 To $iLastControlID $aControlGetPos = ControlGetPos($hWnd, '', $i) If IsArray($aControlGetPos) = 0 Then ContinueLoop $hCreateRect = _WinAPI_CreateRectRgn($aControlGetPos[0], $aControlGetPos[1], $aControlGetPos[0] + $aControlGetPos[2], $aControlGetPos[1] + $aControlGetPos[3]) _WinAPI_CombineRgn($hRectRgn, $hCreateRect, $hRectRgn, 2) _WinAPI_DeleteObject($hCreateRect) Next _WinAPI_SetWindowRgn($hWnd, $hRectRgn, True) _WinAPI_DeleteObject($hRectRgn) EndFunc Func _elementExists($array, $element) If $element > UBound($array)-1 Then Return False ; element is out of the array bounds Return True ; element is in array bounds EndFunc Func getdata() ;~ Local $sResult1 = _Excel_RangeRead($oWorkbook, Default,StringReplace(StringReplace ($aExtract[0],"$",""),"A","B")) ;~ Local $sResult2 = _Excel_RangeRead($oWorkbook, Default,StringReplace(StringReplace ($aExtract[0],"$",""),"A","C")) ;~ Local $sResult3 = _Excel_RangeRead($oWorkbook, Default,StringReplace(StringReplace ($aExtract[0],"$",""),"A","D")) ;~ Local $sResult4 = _Excel_RangeRead($oWorkbook, Default,StringReplace(StringReplace ($aExtract[0],"$",""),"A","E")) ;~ Local $sResult5 = _Excel_RangeRead($oWorkbook, Default,StringReplace(StringReplace ($aExtract[0],"$",""),"A","F")) ;~ Local $sResult6 = _Excel_RangeRead($oWorkbook, Default,StringReplace(StringReplace ($aExtract[0],"$",""),"A","G")) guictrlsetdata($Input2,$sResult1) guictrlsetdata($Input3,$sResult2) guictrlsetdata($Input4,$sResult3) guictrlsetdata($Input5,$sResult4) guictrlsetdata($Input6,$sResult5) guictrlsetdata($Input7,$sResult6) _Excel_Close($oExcel,Default,True) EndFunc Func readxl() Global $oExcel = _Excel_Open(False,False) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeFind Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Global $oWorkbook = _Excel_BookOpen($oExcel, "D:\info.xlsx",False,False) LOcal Const $xlUp = -4162 With $oWorkbook.ActiveSheet ; process active sheet $oRangeLast = .UsedRange.SpecialCells($xlCellTypeLastCell) ; get a Range that contains the last used cells $iRowCount = .Range(.Cells(1, 1), .Cells($oRangeLast.Row, $oRangeLast.Column)).Rows.Count ; get the the row count for the range starting in row/column 1 and ending at the last used row/column $iLastCell = .Cells($iRowCount + 1, "B").End($xlUp).Row ProgressOn("Copying Cells", "Copying Cells progress", "0%") For $i = 2 to $iLastCell Local $total = Int(($i/$iLastCell)*100) Local $sResult3 = _Excel_RangeRead($oWorkbook, Default, "A" & $i) FileWriteLine("result.txt",$sResult3) ProgressSet(($i/$iLastCell)*100, $total & "%") Next ;~ FileWrite("result.txt",$sResult3) ProgressSet(100, "Done", "Complete") Sleep (1500) ProgressOff() _Excel_Close($oExcel,Default,True) EndWith EndFunc