Jump to content

sudeepjd

Active Members
  • Posts

    25
  • Joined

  • Last visited

Everything posted by sudeepjd

  1. Please provide the code that you have created so that the GUI and the issue can be replicated so that anyone trying to answer your question and can help further. Without the code snippet to replicate, it will be difficult for us to understand what issue you are facing.
  2. It may be easier to use a GUICtrlCreatePic and then use GUICtrlSetImage to change the pictures for each of the pages? Then once you reach the end, you can execute the file. If you are looping over a series of images, put the image paths into an Array and loop over the array on each click of the button until you reach then end and then execute the file. Something along the lines of the below code. #include <GUIConstantsEx.au3> AutoItSetOption("GUIOnEventMode", 1) Global $imgArr = ["image_1.jpg", "image_2.jpg", "image_3.jpg", "image_4.jpg"] Global $pos = 0 $g_hBase = GUICreate("Test UI", 500, 520, -1, -1, -1, -1) $pic = GUICtrlCreatePic(@ScriptDir & "\resources\images\" & $imgArr[$pos], 5, 10, 500, 436) $btnBack = GUICtrlCreateButton("<< Move Back", 10, 470, 100, 30) $btnFront = GUICtrlCreateButton("Move Forward >>", 120, 470, 100, 30) GUISetOnEvent($GUI_EVENT_CLOSE , "_Exit") GUICtrlSetOnEvent($btnBack, "changeImg") GUICtrlSetOnEvent($btnFront, "changeImg") GUISetState(@SW_SHOW) While 1 Sleep(100) Wend Func _Exit() Exit EndFunc Func changeImg() If @GUI_CtrlId = $btnBack Then $pos = $pos-1 If $pos=-1 Then $pos = 0 ElseIf @GUI_CtrlId = $btnFront Then $pos = $pos+1 If $pos>Ubound($imgArr)-1 Then $pos = Ubound($imgArr)-1 EndIf GUICtrlSetImage($pic, @ScriptDir & "\resources\images\" & $imgArr[$pos]) If $pos=Ubound($imgArr)-1 Then GUICtrlSetData($btnFront, "Execute File") Else GUICtrlSetData($btnFront, "Move Front >>") EndIf EndFunc
  3. If anyone is still looking for this solution you can use the following to set the IE Zoom level $iZoomLevel = Int(30) ;30% Zoom $oIE.ExecWB (63, 0, $iZoomLevel, Null) 63 is OLECMDID_OPTICAL_ZOOM
  4. If anyone is still looking for this solution you can use the following to set the IE Zoom level $iZoomLevel = Int(30) ;30% Zoom $oIE.ExecWB (63, 0, $iZoomLevel, Null) 63 is OLECMDID_OPTICAL_ZOOM
  5. @FrancescoDiMuro I am executing with the SCite editor. It should give me a COM error on the Console right if there is one.. But this justs returns the $conn as a String instead of an Object.. Whereas on the VBScript it returns the Object. Even if I hardcode the $conn as a Boolean it converts it to a String.. which is weird since I am expecting an Object.
  6. @Werty Thanks for taking a look. Session is a property and not a method per the documentation.. I did try both though.. Thanks for the tip on trying an older version of AutoIT. Will check and see if I can get that to work.
  7. I am looking for a way to interface AutoIT and PTC Creo using the Creo VB API COM object. I am able to do this with VBScript and in theory should also be able to replicate the same into AutoIT as well. However, For some reason, the connection does not seem be made from the Autoit script but is able to be made with VBScript. Below is my working VBScript. Dim asynconn, conn, session Set asynconn = CreateObject("pfcls.pfcAsyncConnection") MsgBox TypeName(asynconn), 0, "COM Type" Set conn = asynconn.Connect("", "", ".", 5) 'Set conn = asynconn.Start("C:\Program Files\PTC\Creo 4.0\M090\Parametric\bin\parametric.exe",".") MsgBox TypeName(conn), 0, "Connection Type" Set sess = conn.session MsgBox TypeName(sess), 0, "Session Type" It opens a connection to the COM object in Creo, and message box outputs the variable types. Below is my NOT working AutoIT Script: Local $asynconn, $conn, $session $asynconn = ObjCreate("pfcls.pfcAsyncConnection") MsgBox(0, "COM Type",ObjName($asynconn)) $conn = $asynconn.Connect("", "", ".", 5) ;$conn = $asynconn.Start("C:\Program Files\PTC\Creo 4.0\M090\Parametric\bin\parametric.exe", ".") MsgBox(0, "Connection Type", ObjName($conn)) $session = $conn.Session Msgbox(0, "Session Type", ObjName($session)) The connection on the $conn object is not being made, even if I start Creo or try connecting to an existing session. I know that there is probably a very few people who would be able to replicate this (those who have access to Creo), but would really appreciate help if someone has any ideas as to why this could be happening. Thanks. Sudeep.
  8. You could also solve this opening with SharePoint issue using the UNC path of SharePoint instead of the HTTP path. For details refer to my answer below.
  9. I know this is an old post and I was having the same problem recently and came across this thread when searching for a solution. The problem is that in the _Excel_BookOpen() function there is a FileExists() check. This check does not work if you are using a http:// filepath, which you are using since the file is on the Sharepoint server. To get around this you need to use the UNC filepath for that folder. To get this open the site in the Windows Explorer browser. Or from Sharepoint in the menu go to Open in File Explorer. Right click and go to Properties. Under location copy the location string. It should be something like \\sharepoint\SiteDirectory\InformationServices\SystemsTeam\Shared%20Documents\Systems%20Administration with this folder as a path, you should be able to open the Excel file since using this UNC path FileExists works and consequently _Excel_BookOpen should also work. I know I am late on this post. But I hope it will help someone else out there looking for the same solution.
  10. @jugador Thanks.. However, my entire program is in EventMode over the MessageLoop mode.. and it is quite large. And I need to hand back the input from the child GUI so this may not work directly for me... But the combination does. Thanks again though.
  11. Yes.. that is what I am looking for.. The data being requested and entered will be different each time, from the same GUI window. Kind of like a custom Inputbox feature. In an Inputbox the script waits for the user to enter the data and then passes the input back into the script. Since I need to have the user enter a lot more information, the Child GUI needs to be a custom one.. and the main script needs to wait until the user has finished entering the data into the child GUI and hit Close. I found what I was looking for on another post.. And your note on GUIGetMsg does not work on OnEventMode and that the _ArrayDisplay via the __ArrayDisplay_Share also works the same way. I need to disable and re-enable GUIOnEventMode to get what I am looking for to work. Here is my working code sample, for anyone else who comes along this type of a problem. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> AutoItSetOption("GUIOnEventMode", 1) Global $hGUI OpenMainGUI() While Sleep(100) ;Main Loop Wend Func OpenMainGUI() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example", 400, 100) $btnMain = GUICtrlCreateButton("Open", 10, 10, 100, 30) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) ; Events GUISetOnEvent($GUI_EVENT_CLOSE, "_ExitMain", $hGUI) GUICtrlSetOnEvent($btnMain, "createChildren") EndFunc ;==>OpenMainGUI Func createChildren() For $i = 1 to 5 $out = createChild($i) ConsoleWrite($i & " - " & $out & @CRLF) Next EndFunc ;==>createChildren() Func createChild($valInp) ;Move On Event Mode to MessageLoop Mode AutoItSetOption('GUIOnEventMode', 0) $hChild = GUICreate("Child GUI", 210, 72, -1, -1, -1, -1, $hGUI) $txtOperation = GUICtrlCreateInput($valInp, 10, 10, 100, 20) $btnCloseChild = GUICtrlCreateButton("Close", 10, 40, 100, 30) ; Display Child GUISetState(@SW_SHOW, $hChild) While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE $retValue = "Skip" ExitLoop Case $btnCloseChild $retValue = GUICtrlRead($txtOperation) ExitLoop EndSwitch WEnd GUIDelete($hChild) ;Restore On Event Mode AutoItSetOption('GUIOnEventMode', 1) Return $retValue EndFunc ;==>CreateChild Func _ExitMain() Exit EndFunc @Nine Thank you for your time. You and the other AutoIt experts here on the forum are a blessing. I have been working with AutoIT for over 10 years now and I get stuck with it sometimes and the community here helps a lot.
  12. I think I figured it out... Your point of you cannot have 2 embedded loops put me in the right direction.. The code below works the way I want it to.. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> AutoItSetOption("GUIOnEventMode", 1) Global $hGUI, $hChild Global $childClose = False Global $rIndex Global $routeData[][3] = [[1, 0, False], [2, 0, False], [3, 0, False]] OpenMainGUI() While Sleep(100) ;ConsoleWrite("Main Loop") WEnd Func OpenMainGUI() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example", 400, 100) $btnMain = GUICtrlCreateButton("Open", 10, 10, 100, 30) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) ; Events GUISetOnEvent($GUI_EVENT_CLOSE, "_ExitMain", $hGUI) GUICtrlSetOnEvent($btnMain, "createChildren") EndFunc ;==>Example Func CreateChildGUI($iVal) $hChild = GUICreate("Child GUI", 210, 72, -1, -1, -1, -1, $hGUI) Global $txtOperation = GUICtrlCreateInput($iVal, 10, 10, 100, 20) Global $btnCloseChild = GUICtrlCreateButton("Close", 10, 40, 100, 30) GUICtrlSetOnEvent($btnCloseChild, "_ExitChild") GUISetState(@SW_SHOW, $hChild) EndFunc Func createChildren() ConsoleWrite("createChildren" & @CRLF) $showChild = False For $i = 0 to UBound($routeData)-1 ConsoleWrite($routeData[$i][2] & @CRLF) If $routeData[$i][2] = False Then $rIndex = $i CreateChildGUI($i) $showChild = True ExitLoop EndIf Next If $showChild = False Then _ArrayDisplay($routeData) EndFunc Func _ExitMain() Exit EndFunc Func _ExitChild() ConsoleWrite("Exit Child Called" & @CRLF) $routeData[$rIndex][1] = GUICtrlRead($txtOperation) $routeData[$rIndex][2] = True GUIDelete($hChild) Call("createChildren") EndFunc However, if there is a better way to do it, instead of handling the flow transfer this way, would be helpful.
  13. @Nine Thanks for looking at it. I do not want 5 child GUI's.. What I need is to have 1 Child GUI that will wait for it to get closed, before the control is passed back to the main window. My explanation, now that I read it again, is not very clear.... sorry. What I need is a method to start a Child GUI in a loop, The Child GUI will get some information passed to it from the main script (I am pulling that information from IE which the user needs, the user then enters the requisite information into the child window and clicks Close and then the control passes back to the main window which then proceeds to get the information for the next part. What I am looking for is a method to have the main loop wait while the user is entering the data on the child window, but I am not able to figure out how to get there. Once Again, thanks for looking at this for me. I have updated the above code to have a single Child Window instance instead of Creating and Deleting the ChildGUI. But the wait is still a problem. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> AutoItSetOption("GUIOnEventMode", 1) Global $hGUI, $hChild Global $childClose = False Global $childValue OpenMainGUI() CreateChildGUI() While Sleep(100) ConsoleWrite("Main Loop") WEnd Func OpenMainGUI() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example", 400, 100) $btnMain = GUICtrlCreateButton("Open", 10, 10, 100, 30) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) ; Events GUISetOnEvent($GUI_EVENT_CLOSE, "_ExitMain", $hGUI) GUICtrlSetOnEvent($btnMain, "createChildren") EndFunc ;==>Example Func CreateChildGUI() $hChild = GUICreate("Child GUI", 210, 72, -1, -1, -1, -1, $hGUI) Global $txtOperation = GUICtrlCreateInput("", 10, 10, 100, 20) Global $btnCloseChild = GUICtrlCreateButton("Close", 10, 40, 100, 30) GUICtrlSetOnEvent($btnCloseChild, "_ExitChild") EndFunc Func createChildren() For $i = 1 to 5 GUICtrlSetData($txtOperation, $i) GUISetState(@SW_SHOW, $hChild) ;THIS IS WHERE THE CONTROL SHOULD WAIT BEFORE CHILD IS CLOSED or $childClose = True ConsoleWrite($i & " - " & $childValue & @CRLF) Next EndFunc Func _ExitMain() Exit EndFunc Func _ExitChild() ConsoleWrite("Exit Child Called") $childValue = GUICtrlRead($txtOperation) $childClose = True GUIDelete($hChild) EndFunc
  14. I am looking for a way to pull up a Child GUI Window that users can enter information into and return that information to the main for loop which is running off an array. However, I have been unable to do so because the For loop continues even though the child window is open. If I put in another while loop inside the child window function, I am not able to poll the windows for the events looking for the close button getting clicked. I have put together a simple test application that shows this. Any help with holding the main loop while the child window is open and returning when the Close button is clicked is appreciated. In the below example, the child window contains a single text box, however, on my main application the Child GUI is much more complex with multiple pieces of information being returned. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> AutoItSetOption("GUIOnEventMode", 1) Global $hGUI, $hChild Global $childClose = False Global $childValue OpenMainGUI() While Sleep(100) ConsoleWrite("Main Loop") WEnd Func OpenMainGUI() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example", 400, 100) $btnMain = GUICtrlCreateButton("Open", 10, 10, 100, 30) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) ; Events GUISetOnEvent($GUI_EVENT_CLOSE, "_ExitMain", $hGUI) GUICtrlSetOnEvent($btnMain, "createChildren") EndFunc ;==>Example Func createChildren() For $i = 1 to 5 createChild($i) ConsoleWrite($i & " - " & $childValue & @CRLF) Next EndFunc Func createChild($valInp) $childClose = False $hChild = GUICreate("Child GUI", 210, 72, -1, -1, -1, -1, $hGUI) $txtOperation = GUICtrlCreateInput($valInp, 10, 10, 100, 20) $btnCloseChild = GUICtrlCreateButton("Close", 10, 40, 100, 30) GUICtrlSetOnEvent($btnCloseChild, "_ExitChild") ; Display Child GUISetState(@SW_SHOW) ;Wait here till Close button is clicked While $childClose = False ConsoleWrite("Stuck in this loop..." & @LF) Sleep(100) $aMsg = GUIGetMsg(1) If $aMsg[0] >0 Then _ArrayDisplay($aMsg) Wend EndFunc Func _ExitMain() Exit EndFunc Func _ExitChild() ConsoleWrite("Exit Child Called") $childValue = GUICtrlRead($txtOperation) $childClose = True GUIDelete($hChild) EndFunc Thanks in advance for any help offered. My other alternative is to create a separate EXE for the child window and use ShellExecuteWait to wait for the child window to close before the loop continues, but I am hoping to avoid doing that.
  15. I have added the example into the first post.
  16. Your "Welcome" And "Name" Labels i.e. lines 62 and 63 $Wilkommen = GUICtrlCreateLabel ( "Wilkommen,", 110, 50, 300, 300 ) $Name = GUICtrlCreateLabel ( $OptionsName, 110, 100, 300, 300, $SS_CENTER ) Have a height of 300 and they are covering the Start and Stop buttons until hovered over and activated. Change the heights of these 2 labels to 100 like so $Wilkommen = GUICtrlCreateLabel ( "Wilkommen,", 110, 50, 300, 100 ) $Name = GUICtrlCreateLabel ( $OptionsName, 110, 100, 300, 100, $SS_CENTER ) And you will see that the buttons appear on the Form without the need of them to be hovered over first.
  17. @Nine Yes.. GUISetAccelerators can be used, and it needs to be linked to a dummy control, but should work. Too many controls to tab through for the _WinAPI_SetWindowLong, was thinking about it, but too much coding work, for a workaround :-) Thanks for the suggestions though. Much appreciated. @pixelsearch Your the man!!! Thank you... You are awesome... I never would have thought that NCHITTEST could be used for this. Thanks a ton.
  18. Looks easy enough. Check out the below help topics to get you started. _Excel_Open to open the Excel - https://www.autoitscript.com/autoit3/docs/libfunctions/_Excel_Open.htm _Excel_BookOpen to open the workbook - https://www.autoitscript.com/autoit3/docs/libfunctions/_Excel_BookOpen.htm _Excel_RangeRead to read the range and put it into an array - https://www.autoitscript.com/autoit3/docs/libfunctions/_Excel_RangeRead.htm For...Next to Loop through the array - https://www.autoitscript.com/autoit3/docs/keywords/For.htm FileCopy to Copy the file - https://www.autoitscript.com/autoit3/docs/functions/FileCopy.htm _Excel_BookClose the Excel book - https://www.autoitscript.com/autoit3/docs/libfunctions/_Excel_BookClose.htm _Excel_Close - Close Excel - https://www.autoitscript.com/autoit3/docs/libfunctions/_Excel_Close.htm Actually I just seem to have written the code for you using the exact steps you need and the help files to read through to get there. If you still have a problem post the code that you have tried and will try and help. All the Best. Sudeep.
  19. Thanks Melba for your reply.. Appreciate it. If it is a known problem, then I cannot solve out of the box. I had to work around it.. What I did was to add in a {TAB} and +{TAB} Hotkey and wrote out a function to manually tab into the controls. This seems to solve my problem of scrolling and tabbing at the same time. Here is my pseudo fix, if anyone comes upon the same problem. #include <GUIConstants.au3> #include <GUIScrollbars.au3> #include <WindowsConstants.au3> #include <WinAPISysWin.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode HotKeySet("{TAB}", "tabFunc") ;<-- Hotkey for tabbing forward HotKeySet("+{TAB}", "tabFunc") ;<--Hotkey for tabbing backwards Global $width=500, $height=500, $titel="Tabtest in Childwindow" ; create the parentwindow $mainwindow = GUICreate($titel, $width, $height, -1, -1) GUISetBkColor(0x00ffff) ; show the parentwindow GUISetState(@SW_SHOW, $mainwindow) ; check on screen Sleep(1000) $input_1 = GUICtrlCreateInput("Outside Input", 10, 10, 100, 20) ; create the childwindow with the scrollbars active ->TABSTOPS Dont work $childwindo1 = GUICreate("child", 220,$height-50, 10 , 50, $WS_CHILD, -1 ,$mainwindow) _GUIScrollBars_Init($childwindo1, 100, 100) GUISetBkColor(0xff0000, $childwindo1) GUISetState(@SW_SHOW, $childwindo1) $input_2 = GUICtrlCreateInput("Scroll Works",10,10) $input_3 = GUICtrlCreateInput("Tab Does Not without tabFunc",10,40) ; create the childwindow with the scrollbars active ->TABSTOPS Work, Scroll does not because window moves $childwindo2 = GUICreate("child", 220, $height, 240 ,0,$WS_CHILD, $WS_EX_CONTROLPARENT ,$mainwindow) _GUIScrollBars_Init($childwindo2, 100, 100) GUISetBkColor(0xff0000, $childwindo2) GUISetState(@SW_SHOW, $childwindo2) $input_4 = GUICtrlCreateInput("Tab Works",10,10) $input_5 = GUICtrlCreateInput("Scroll Does Not",10,40) GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL") ; register close GUISetOnEvent($GUI_EVENT_CLOSE, "close_it",$mainwindow) ;loop While 1 Sleep(100) ; Idle around WEnd Func close_it() ; Exit application GUIDelete($mainwindow) Exit EndFunc $childwindo = GUICreate("child",$width,$height,0,0,$WS_CHILD,-1,$mainwindow) GUISetBkColor(0xff0000) GUISetState(@SW_SHOW,$childwindo) Func tabFunc() ;Get the Control in Focus $itemInFocusHndl = ControlGetHandle($mainwindow, "", ControlGetFocus($mainwindow)) $ctrlID = _WinAPI_GetWindowLong($itemInFocusHndl, $GWL_ID) ;Decide on which side to move Switch @HotKeyPressed Case "{TAB}" $ctrlID = $ctrlID+1 While _WinAPI_GetClassName(GUICtrlGetHandle($ctrlID)) = "Static" $ctrlID = $ctrlID+1 Wend Case "+{TAB}" $ctrlID = $ctrlID-1 While _WinAPI_GetClassName(GUICtrlGetHandle($ctrlID)) = "Static" $ctrlID = $ctrlID-1 Wend EndSwitch ;Shift the focus to the control accordingly. ControlFocus($mainwindow, "", GUICtrlGetHandle($ctrlID)) EndFunc Func WM_VSCROLL($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam, $lParam Local $iScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $iCharY, $iPosY Local $iMin, $iMax, $iPage, $iPos, $iTrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $iCharY = $__g_aSB_WindowInfo[$iIndex][3] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 ; Get all the vertial scroll bar information Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $iMin = DllStructGetData($tSCROLLINFO, "nMin") $iMax = DllStructGetData($tSCROLLINFO, "nMax") $iPage = DllStructGetData($tSCROLLINFO, "nPage") ; Save the position for comparison later on $iPosY = DllStructGetData($tSCROLLINFO, "nPos") $iPos = $iPosY $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $iScrollCode Case $SB_TOP ; user clicked the HOME keyboard key DllStructSetData($tSCROLLINFO, "nPos", $iMin) Case $SB_BOTTOM ; user clicked the END keyboard key DllStructSetData($tSCROLLINFO, "nPos", $iMax) Case $SB_LINEUP ; user clicked the top arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1) Case $SB_LINEDOWN ; user clicked the bottom arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1) Case $SB_PAGEUP ; user clicked the scroll bar shaft above the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage) Case $SB_PAGEDOWN ; user clicked the scroll bar shaft below the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos) EndSwitch ; // Set the position and then retrieve it. Due to adjustments ; // by Windows it may not be the same as the value set. DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) ;// If the position has changed, scroll the window and update it $iPos = DllStructGetData($tSCROLLINFO, "nPos") If ($iPos <> $iPosY) Then _GUIScrollBars_ScrollWindow($hWnd, 0, $iCharY * ($iPosY - $iPos)) $iPosY = $iPos EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_VSCROLL Basically, pass the Tab through a functions that looks for the handle to the item in focus, gets the Control ID and increments or decrements it and then selects the next appropriate one. The only issue with doing this is that Tab and Shift+Tab is being captured by the application and any other windows are not able to use the Tab keys. Is there another way to capture the Tab and Shift+Tab without blocking the inputs to other windows applications? It tried GUIRegisterMsg($WM_KEYDOWN, 'WM_KEYDOWN') but it does not capture the TAB key needed for this, but seems to capture other keys. Func WM_KEYDOWN($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam ConsoleWrite(_WinAPI_GetKeyNameText($lParam) & @CRLF) Return $GUI_RUNDEFMSG EndFunc ;==>WM_KEYDOWN I can use _IsPressed() but I will have to call that in the While loop and it will eat up the CPU Cycles. @Melba23 Do you know any other methods I can check if the Tab and Shift+Tab get pressed? Thanks, Sudeep
  20. I am building an application which needs a child panel in the GUI Control that needs to be scrolled as it contains controls that extend beyond the panel height. But I also need to have the users to be able to Tab through those controls. I don't seem to be able to to both working together. The Tabstops can be allowed on children by using $WS_EX_CONTROLPARENT and the Scrollbar creation using the GUIScrollBar.au3. If I set the $WS_EX_CONTROLPARENT it drags the entire child and does not allow the scroll, but if I remove it, the Scroll works but the tabstops don't. Please see the below sample application that can help reproduce this problem. #include <GUIConstants.au3> #include <GUIScrollbars.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode Global $width=500, $height=500, $titel="Tabtest in Childwindow" ; create the parentwindow $mainwindow = GUICreate($titel, $width, $height, -1, -1) GUISetBkColor(0x00ffff) ; show the parentwindow GUISetState(@SW_SHOW,$mainwindow) ; check on screen sleep(1000) ; create the childwindow with the scrollbars active ->TABSTOPS Dont work $childwindo1 = GUICreate("child", 220,$height, 10 ,0,$WS_CHILD, -1 ,$mainwindow) _GUIScrollBars_Init($childwindo1, 100, 100) GUISetBkColor(0xff0000, $childwindo1) GUISetState(@SW_SHOW, $childwindo1) $input_1 = GUICtrlCreateInput("Scroll Works",10,10) $input_2 = GUICtrlCreateInput("Tab Does Not",10,40) ; create the childwindow with the scrollbars active ->TABSTOPS Work, Scroll does not because window moves $childwindo2 = GUICreate("child", 220, $height, 240 ,0,$WS_CHILD, $WS_EX_CONTROLPARENT ,$mainwindow) _GUIScrollBars_Init($childwindo2, 100, 100) GUISetBkColor(0xff0000, $childwindo2) GUISetState(@SW_SHOW, $childwindo2) $input_3 = GUICtrlCreateInput("Tab Works",10,10) $input_4 = GUICtrlCreateInput("Scroll Does Not",10,40) GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL") ; register close GUISetOnEvent($GUI_EVENT_CLOSE, "close_it",$mainwindow) ;loop While 1 Sleep(100) ; Idle around WEnd Func close_it() ; exit application GUIDelete($mainwindow) exit EndFunc $childwindo = GUICreate("child",$width,$height,0,0,$WS_CHILD,-1,$mainwindow) GUISetBkColor(0xff0000) GUISetState(@SW_SHOW,$childwindo) Func WM_VSCROLL($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam, $lParam Local $iScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $iCharY, $iPosY Local $iMin, $iMax, $iPage, $iPos, $iTrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $iCharY = $__g_aSB_WindowInfo[$iIndex][3] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 ; Get all the vertial scroll bar information Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $iMin = DllStructGetData($tSCROLLINFO, "nMin") $iMax = DllStructGetData($tSCROLLINFO, "nMax") $iPage = DllStructGetData($tSCROLLINFO, "nPage") ; Save the position for comparison later on $iPosY = DllStructGetData($tSCROLLINFO, "nPos") $iPos = $iPosY $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $iScrollCode Case $SB_TOP ; user clicked the HOME keyboard key DllStructSetData($tSCROLLINFO, "nPos", $iMin) Case $SB_BOTTOM ; user clicked the END keyboard key DllStructSetData($tSCROLLINFO, "nPos", $iMax) Case $SB_LINEUP ; user clicked the top arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1) Case $SB_LINEDOWN ; user clicked the bottom arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1) Case $SB_PAGEUP ; user clicked the scroll bar shaft above the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage) Case $SB_PAGEDOWN ; user clicked the scroll bar shaft below the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos) EndSwitch ; // Set the position and then retrieve it. Due to adjustments ; // by Windows it may not be the same as the value set. DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) ;// If the position has changed, scroll the window and update it $iPos = DllStructGetData($tSCROLLINFO, "nPos") If ($iPos <> $iPosY) Then _GUIScrollBars_ScrollWindow($hWnd, 0, $iCharY * ($iPosY - $iPos)) $iPosY = $iPos EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_VSCROLL Any help to get both working together is appreciated. Thanks, Sudeep.
  21. I seemed to be having the same problem.. But ended up writing a library for it. You can use it to create and update Pivot tables and Pivot Charts.
  22. I was looking for a UDF using which I could Add and Update Pivot tables and Pivot Charts in Excel easily and could not find one that I could use. So I build this UDF. It has the following functions : _ExcelPivot_CreateCache ; Easily Create a pivot table data cache from a Sheet _ExcelPivot_CreateTable ; Create a table from a cache at a specified location on the sheet _ExcelPivot_RefreshTable ; Refresh the datatable data with a new cache _ExcelPivot_AddField ; Add a Field and Aggregate function to the Datatable _ExcelPivot_AddFilter ; Adds in the Filter to a specific field _ExcelPivot_ClearFilter ; Removes the filter for a field or all the filters in the table _ExcelPivot_GetRange ; Get specific areas of a Pivot as a Range Object _ExcelPivot_AddChart ; Add a Pivot Chart linked to a specific Pivot table Attached the UDF to this post. Please do let me know if I can improve or add additional functions to it. A detailed example on the usage is below. The excel file and the example can be downloaded from the Example.zip file attached. #include "ExcelPivot.au3" $oExcel = _Excel_Open() $oBook = _Excel_BookOpen($oExcel, @ScriptDir & "\TestPivot.xlsx") ;Create a Sheet to put the pivot into $pSheet = _Excel_SheetAdd($oBook, -1, False, 1) $pSheet.Name = "Pivot" ;Get the cache for the pivot table $pCache = _ExcelPivot_CreateCache($oBook, "Data") ;Add in the Pivot Table from the Cache _ExcelPivot_CreateTable($pCache, $pSheet, "A1", "FruitsPivot") ;Add in the Fields into the Pivot _ExcelPivot_AddField($pSheet, "FruitsPivot", "Category", "Filter") _ExcelPivot_AddField($pSheet, "FruitsPivot", "Product", "Row") _ExcelPivot_AddField($pSheet, "FruitsPivot", "Amount", "Value", "Sum", 1) ;Add in a Running total to the Pivot _ExcelPivot_AddField($pSheet, "FruitsPivot", "Amount", "Value", "Sum", 2, "PercentageRunningTotal", "Product") ;Filter only the fruits _ExcelPivot_Filter($pSheet, "FruitsPivot", "Category", "Fruit") ;Draw a Paretto Chart $chart = _ExcelPivot_AddChart($oBook, $pSheet, "FruitsPivot", "ColumnClustered", "Paretto", "E2", 570) $chart.Chart.FullSeriesCollection(1).ApplyDataLabels $chart.Chart.FullSeriesCollection(2).ChartType = 4 ;Change the percentage to a line graph $chart.Chart.FullSeriesCollection(2).AxisGroup = 2 ;Move it to secondary axis $chart.Chart.Axes(2, 2).MaximumScale = 1 ;Adjust to scale to 100% max ExcelPivot.au3 Example.zip
  23. I know this post is old, I came across is since I was looking for a solution to change the color of the items. I am creating the items with _GUICtrlListView_AddArray in most places in my program.. and manipulating the data by inserting new rows, deleting rows etc. So the UDF is a good option. The only way I could solve this problem was to recreate the items with the native GUICtrlCreateListItem and then use the _GUICtrlListView_GetItemParam to retreive the control ID. I hope this helps somebody who is also looking for the same answer. I dont know if there is a better way to do this.. But for me it works. ;Color the listview Func _GUICtrlListView_SetItemBkColor($hWnd, $Item_index, $Color_RGB) ;Assign ControlIDs to the ListView Items $cnt = _GUICtrlListView_GetItemCount($hWnd) Local $data[$cnt] For $i = 0 to $cnt-1 $data[$i] = _GUICtrlListView_GetItemTextString($hWnd, $i) Next _GUICtrlListView_DeleteAllItems($hWnd) For $i = 0 to $cnt-1 GUICtrlCreateListViewItem($data[$i], $hWnd) Next $ctrlID = _GUICtrlListView_GetItemParam($hWnd, $Item_index) GUICtrlSetBkColor($ctrlID, $Color_RGB) EndFunc ;==>_GUICtrlListView_SetItemBkColor
  24. I would like to share my version of this since I am using the Array functions... #include <GuiListView.au3> #include <Array.au3> Func _GUICtrlListView_GetItemsArray($hListView) $cnt = _GUICtrlListView_GetItemCount($hListView) If $cnt > 0 Then $firstLine = _GUICtrlListView_GetItemTextArray($hListView, 0) _ArrayTranspose($firstLine) If $cnt > 1 Then For $i = 1 to $cnt-1 $moreLine = _GUICtrlListView_GetItemTextArray($hListView, $i) _ArrayTranspose($moreLine) _ArrayConcatenate($firstLine, $moreLine) Next EndIf ;Remove the first columns as it contains the counts of each line _ArrayColDelete($firstLine, 0) Return $firstLine Else Return False EndIf EndFunc
  25. I was looking for a way to embed Windows Media Player into Autoit. I found 2 Windows Media Player UDF's but both of them seem to have used the OCX directly. The problem with using the OCX directly is that the video display size cannot be changed, and it takes the size of the video inherently. @seangriffin created the VLC GUI based on embedding the IE object into the GUI and that seems to work perfectly with Windows Media Player as well and it does not give the resize problem. I built the WMP.au3 around this concept and would like to share it with everybody. Attached is the WMP.au3 and the WMP_Example.au3 where it is used. Feedback is appreciated. This is my first UDF, so please be kind. SudeepJD WMP_Example.au3 WMP.au3
×
×
  • Create New...