mixalis Posted September 22, 2010 Share Posted September 22, 2010 Hello to everyone,I am a beginner with AutoIt and i dont have a lot of knoledge with the 'language'I have to make an application automation.with the run command i try to run the program but the program stays in the taskbar its not fully openning!Should i type another command?????And,with which command can i 'press a button'???with th AutoIt Windows Info Tool i can find th ID number of the button..but then in order to activate this button what should i do??Thank you for your time,even if its a siple question! Link to comment Share on other sites More sharing options...
Tvern Posted September 22, 2010 Share Posted September 22, 2010 The reason the program only shows in the taskbar probably has more to do with the program you are trying to run and less with the run command. Does the program behave any different when you click the executable manually? If so, the only reason I can see for this behavior is that the working dir has to be set to the programs installation dir. If you normally run the program using a shortcut, there might be command line parameters you need to specify. It would help if we knew the program you are tying to run. For pressing the button you can use ControlClick. Link to comment Share on other sites More sharing options...
mixalis Posted September 22, 2010 Author Share Posted September 22, 2010 Actually it behaves with the same way,when im doing it manually!It goes in the task manages first and then i have to 'double-click' it. the program is the 'Wireless LAN USB Dongle' . Link to comment Share on other sites More sharing options...
Sticky Posted September 22, 2010 Share Posted September 22, 2010 (edited) Actually it behaves with the same way,when im doing it manually!It goes in the task manages first and then i have to 'double-click' it. the program is the 'Wireless LAN USB Dongle' . You can double click it with autoit like this using a function made by Melba23: #Include <GuiToolBar.au3> Dim $hToolBar = ControlGetHandle('[CLASS:Shell_TrayWnd]', '', '[CLASS:ToolbarWindow32]') _GUICtrlToolbar_ClickButton($hToolBar, Get_Systray_Index('Wireless LAN USB Dongle'), 'left', False, 2) ;following function was made by Melba23 Func Get_Systray_Index($sText) ; Find systray handle $hSysTray_Handle = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]') If @error Then MsgBox(16, "Error", "System tray not found") Exit EndIf ; Get systray item count Local $iSystray_ButCount = _GUICtrlToolbar_ButtonCount($hSysTray_Handle) If $iSystray_ButCount = 0 Then MsgBox(16, "Error", "No items found in system tray") Exit EndIf ; Look for tooltip For $iSystray_ButtonNumber = 0 To $iSystray_ButCount - 1 If StringInStr(_GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSystray_ButtonNumber), $sText) > 0 Then ExitLoop Next If $iSystray_ButtonNumber = $iSystray_ButCount Then Return SetError(1, 0, -1) ; Not found Else Return $iSystray_ButtonNumber ; Found EndIf EndFunc Edited September 22, 2010 by Sticky Link to comment Share on other sites More sharing options...
mixalis Posted September 23, 2010 Author Share Posted September 23, 2010 i tried but unfortunately is not working!! how about the processing ID??? the run command says that returns th PID . How can i do this???? :/ Link to comment Share on other sites More sharing options...
Sticky Posted September 23, 2010 Share Posted September 23, 2010 i tried but unfortunately is not working!! how about the processing ID??? the run command says that returns th PID . How can i do this???? :/The function uses StringInStr while it loops through all toolbar icons, so you must give it a string (doesn't have to be the full name). How are you obtaining the name 'Wireless LAN USB Dongle'? To correctly obtain a string that will work with the function, you must hover over the icon in the toolbar and use the tooltip text that shows up. Sorry I failed to mention this, you're probably using the window title after double-clicking, instead of the tooltip text of the toolbar icon for the program.Remember, you don't have to use the full string, so I would be less restrictive at first to get it working by only using one unique word from the tooltip. Link to comment Share on other sites More sharing options...
Tvern Posted September 23, 2010 Share Posted September 23, 2010 I don't think that function works for icons that are in the overflow menu of the systray. If that causes a problem you can either set your preferences so, that it's always shown, or you could do a search for a function that works with the overflow menu. I think I've seen a UDF for it at some point. I might have a look myself tomorrow. Link to comment Share on other sites More sharing options...
mixalis Posted September 28, 2010 Author Share Posted September 28, 2010 whats this function u are talking about Tvern?? can u help m?? I simply want to run a program.when i do it manually i go t the icon and press double click.then the program starts but goes to the task bar.from there left click and "open". Now i want to do this automatically!!with the run command it opens and goes to the task bar. whats the next step now in order th program to opens properly???? Link to comment Share on other sites More sharing options...
Tvern Posted September 29, 2010 Share Posted September 29, 2010 Completely forgot I was going to reply to this topic.The best option would still be using a command line to make the application visible from the start. However we don't know if the program supports command line parameters, or what they are and without any documentation it's anyones guess. Perhaps the website of the developer has some information. You could also just try to guess it with things like: -show -visible -help -? etc.In case command line arguments are not supported you could use winlist to check if perhaps the UI is created, but hidden and then use WinSetState to make it appear, but the Window is probably not created yet.If those options fail I think you're back to simulating keypresses. This UDF allows you to get information about all icons on the taskbar and in the overflow menu. (Which is Win7 only, I guess it's not an issue on previous versions)With a bit of a change to the example for the UDF I made a function that returns the handle to the right control:expandcollapse popup#include <_SysTray.au3> Local $sPath = "" ;your path here Local $nTimeout = 5000 ;after this amount of ms the function will fail if no matching icon is found Local $hIcon = _GetIconHandle(Run($sPath),$nTimeOut) If @error Then ConsoleWrite("No matching icon found!" & @CRLF) Else ConsoleWrite("Icon handle = " & $hIcon & @CRLF) EndIf Func _GetIconHandle($pidRun,$nTimeOut = 5000) Local $timer = TimerInit() Local $count, $handle, $pidIcon Do $count = _SysTrayIconCount() For $i = $count - 1 To 0 Step -1 $handle = _SysTrayIconHandle($i) $pidIcon = WinGetProcess($handle) If $pidIcon = -1 Then _SysTrayIconRemove($i) ElseIf $pidIcon = $pidRun Then Return $handle EndIf Next If @OSVersion = "WIN_7" Then $count = _SysTrayIconCount(2) For $i = $count - 1 To 0 Step -1 $handle = _SysTrayIconHandle($i, 2) $visible = _SysTrayIconVisible($i, 2) $pidIcon = WinGetProcess($handle) If $pidIcon = -1 Then _SysTrayIconRemove($i,2) ElseIf $pidIcon = $pidRun Then Return $handle EndIf Next EndIf Until TimerDiff($timer) > $nTimeOut Return SetError(1) EndFuncHowever I am having trouble clicking the icon. Perhaps someone else has an idea. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now