JustSomeone Posted June 6, 2014 Share Posted June 6, 2014 Hello again, Due recent update of the Hamachi, and them asking for dollars to use their awesome features, thus screwing up their client alot, i must ask - did someone tried to automate the poweron button of the program? i cannot manage to capture anything with the window tool, other approach is to right-click on the icon in the system tray then click on "poweron" but i have no idea how i can click on the right icon (maybe some sort of ocr to see the correct icon or something). in case someone use the hamach and don't have this problem : Hamachi starts as powered off, if you are using any sort of autologin OR use the windows feature to disable the login screen and login directly with x account Cheers ~ p.s. i have no idea from where i shall start p.p.s if someone have any other vpn solution i would accept that too p.p.p.s (no, i do not have 24/7/365 uptime machine to setup openvpn) Link to comment Share on other sites More sharing options...
JohnOne Posted June 6, 2014 Share Posted June 6, 2014 What is Hamachi? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JustSomeone Posted June 6, 2014 Author Share Posted June 6, 2014 What is Hamachi? https://secure.logmein.com/EU/products/hamachi/ tl;dr free vpn solution, allowing you to have free vpn access to 5 computers (per network) main problem is, that they "upgraded" it, and now if you are using the automatic login in Windows the client starts as powered off and you need to rightclick on the tray icon and power it on, or double left click on the tray icon, open the program and press that big power button it have. Link to comment Share on other sites More sharing options...
JohnOne Posted June 6, 2014 Share Posted June 6, 2014 M23 shows >here how to click on a tray icon. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
bogQ Posted June 6, 2014 Share Posted June 6, 2014 expandcollapse popup#Include <GuiToolBar.au3> _SysTray_ClickItem("Hamachi -- offline", "left", 2) ControlClick(WinWaitActive(WinActivate(WinWait('LogMeIn Hamachi'))),'','[CLASS:Button; INSTANCE:1]') ;~ If @error Then MsgBox(48, "Failure", "Required item not found") ;=========# _SysTray_ClickItem #====================================================== ; ;Function Name: _SysTray_ClickItem() ;Description: Click on item in Windows system tray by any substring in the title ;Parameters: $iTitle - The title of the item in Windows system tray (you can see the title of the item when mouse cursor hovered on item). ; $iButton - [optional] The button to click, "left" or "right". Default is the left button. ; $iClick - [optional] The number of times to click the mouse. Default is 1 ; $sMove = [optional] True = Mouse will be moved, False (default) = Mouse will not be moved ; $iSpeed = [optional] Mouse movement speed ;Return Value(s): Success - Returns 1 ; Failure - Returns 0 and sets @error to 1 if required item not found ;Requirement(s): AutoIt 3.2.10.0 and above ;Autor(s): R.Gilman (a.k.a rasim); Siao (Thanks for idea) ; ;==================================================================================== Func _SysTray_ClickItem($iTitle, $iButton = "left", $iClick = 1, $sMove = False, $iSpeed = 1) Local $hToolbar, $iButCount, $aRect, $hButton, $cID, $i $hToolbar = ControlGetHandle("[Class:Shell_TrayWnd]", "", "[Class:ToolbarWindow32;Instance:1]") If @error Then Return SetError(1, 0, 0) EndIf $iButCount = _GUICtrlToolbar_ButtonCount($hToolbar) If $iButCount = 0 Then Return SetError(1, 0, 0) EndIf $hButton = ControlGetHandle("[Class:Shell_TrayWnd]", "", "Button2") If $hButton <> "" Then ControlClick("[Class:Shell_TrayWnd]", "", "Button2") For $i = 0 To $iButCount - 1 $cID = _GUICtrlToolbar_IndexToCommand($hToolBar, $i) If StringInStr(_GUICtrlToolbar_GetButtonText($hToolBar, $cID), $iTitle) Then _GUICtrlToolbar_ClickButton($hToolbar, $cID, $iButton, $sMove, $iClick, $iSpeed) Return 1 EndIf Next Return SetError(1, 0, 0) EndFunc JustSomeone 1 TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
JustSomeone Posted June 6, 2014 Author Share Posted June 6, 2014 Will check that and post feedback, thanks to all of you Link to comment Share on other sites More sharing options...
Solution JustSomeone Posted June 6, 2014 Author Solution Share Posted June 6, 2014 (edited) expandcollapse popup#Include <GuiToolBar.au3> _SysTray_ClickItem("Hamachi -- offline", "left", 2) ControlClick(WinWaitActive(WinActivate(WinWait('LogMeIn Hamachi'))),'','[CLASS:Button; INSTANCE:1]') ;~ If @error Then MsgBox(48, "Failure", "Required item not found") ;=========# _SysTray_ClickItem #====================================================== ; ;Function Name: _SysTray_ClickItem() ;Description: Click on item in Windows system tray by any substring in the title ;Parameters: $iTitle - The title of the item in Windows system tray (you can see the title of the item when mouse cursor hovered on item). ; $iButton - [optional] The button to click, "left" or "right". Default is the left button. ; $iClick - [optional] The number of times to click the mouse. Default is 1 ; $sMove = [optional] True = Mouse will be moved, False (default) = Mouse will not be moved ; $iSpeed = [optional] Mouse movement speed ;Return Value(s): Success - Returns 1 ; Failure - Returns 0 and sets @error to 1 if required item not found ;Requirement(s): AutoIt 3.2.10.0 and above ;Autor(s): R.Gilman (a.k.a rasim); Siao (Thanks for idea) ; ;==================================================================================== Func _SysTray_ClickItem($iTitle, $iButton = "left", $iClick = 1, $sMove = False, $iSpeed = 1) Local $hToolbar, $iButCount, $aRect, $hButton, $cID, $i $hToolbar = ControlGetHandle("[Class:Shell_TrayWnd]", "", "[Class:ToolbarWindow32;Instance:1]") If @error Then Return SetError(1, 0, 0) EndIf $iButCount = _GUICtrlToolbar_ButtonCount($hToolbar) If $iButCount = 0 Then Return SetError(1, 0, 0) EndIf $hButton = ControlGetHandle("[Class:Shell_TrayWnd]", "", "Button2") If $hButton <> "" Then ControlClick("[Class:Shell_TrayWnd]", "", "Button2") For $i = 0 To $iButCount - 1 $cID = _GUICtrlToolbar_IndexToCommand($hToolBar, $i) If StringInStr(_GUICtrlToolbar_GetButtonText($hToolBar, $cID), $iTitle) Then _GUICtrlToolbar_ClickButton($hToolbar, $cID, $iButton, $sMove, $iClick, $iSpeed) Return 1 EndIf Next Return SetError(1, 0, 0) EndFunc This works like a charm, hoever if the hamachi is in power on state, it powers it off. I will try to rewrite it so it can read the tray and if it says "Hamachi -- ready" instead of "Hamachi -- offline" not to send the controlclick Edited June 6, 2014 by JustSomeone Link to comment Share on other sites More sharing options...
bogQ Posted June 6, 2014 Share Posted June 6, 2014 (edited) check if error on _SysTray_ClickItem and do ControlClick if no error Edited June 6, 2014 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
JustSomeone Posted June 10, 2014 Author Share Posted June 10, 2014 Bumping this I always get @error at 1, no matter what i do, even after i copy-paste the function above, and no modifications in the name it looks for seems to help .. Advice please Link to comment Share on other sites More sharing options...
bogQ Posted June 10, 2014 Share Posted June 10, 2014 And you did not post your code where you always get @error at 1 why? TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
JustSomeone Posted June 11, 2014 Author Share Posted June 11, 2014 (edited) #Include <GuiToolBar.au3> _SysTray_ClickItem("Hamachi -- offline", "left", 2) ========================== Func _SysTray_ClickItem($iTitle, $iButton = "left", $iClick = 1, $sMove = False, $iSpeed = 1) Local $hToolbar, $iButCount, $aRect, $hButton, $cID, $i $hToolbar = ControlGetHandle("[Class:Shell_TrayWnd]", "", "[Class:ToolbarWindow32;Instance:1]") If @error Then Return SetError(1, 0, 0) EndIf $iButCount = _GUICtrlToolbar_ButtonCount($hToolbar) If $iButCount = 0 Then Return SetError(1, 0, 0) EndIf $hButton = ControlGetHandle("[Class:Shell_TrayWnd]", "", "Button2") If $hButton <> "" Then ControlClick("[Class:Shell_TrayWnd]", "", "Button2") For $i = 0 To $iButCount - 1 $cID = _GUICtrlToolbar_IndexToCommand($hToolBar, $i) If StringInStr(_GUICtrlToolbar_GetButtonText($hToolBar, $cID), $iTitle) Then _GUICtrlToolbar_ClickButton($hToolbar, $cID, $iButton, $sMove, $iClick, $iSpeed) Return 1 EndIf Next Return SetError(1, 0, 0) EndFunc This function always return 0 and @error is always set to 1, and i tried different names of the tray item without success Edited June 11, 2014 by JustSomeone Link to comment Share on other sites More sharing options...
bogQ Posted June 11, 2014 Share Posted June 11, 2014 i still dont see where you use @error macro to check for errors after you cann your _SysTray_ClickItem func...so post code that will replicate problem with the "I always get @error at 1, no matter what i do".Coz i did check for errors and error is triggered correctly in my case, now i want to see how do you use @error in case you're doing something wrong. TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
JustSomeone Posted June 11, 2014 Author Share Posted June 11, 2014 To make it less crowded with code, i cut it a bit #Include <GuiToolBar.au3> ;some code removed from here _SysTray_ClickItem("Hamachi -- offline", "left", 2) $error = @error Consolewrite("Error - " & $error &@crlf) if $error = 0 Then ControlClick(WinWaitActive(WinActivate(WinWait('LogMeIn Hamachi'))),'','[CLASS:Button; INSTANCE:1]') Else Exit EndIf Func _SysTray_ClickItem($iTitle, $iButton = "left", $iClick = 1, $sMove = False, $iSpeed = 1) Local $hToolbar, $iButCount, $aRect, $hButton, $cID, $i $hToolbar = ControlGetHandle("[Class:Shell_TrayWnd]", "", "[Class:ToolbarWindow32;Instance:1]") If @error Then Return SetError(1, 0, 0) EndIf $iButCount = _GUICtrlToolbar_ButtonCount($hToolbar) If $iButCount = 0 Then Return SetError(1, 0, 0) EndIf $hButton = ControlGetHandle("[Class:Shell_TrayWnd]", "", "Button2") If $hButton <> "" Then ControlClick("[Class:Shell_TrayWnd]", "", "Button2") For $i = 0 To $iButCount - 1 $cID = _GUICtrlToolbar_IndexToCommand($hToolBar, $i) If StringInStr(_GUICtrlToolbar_GetButtonText($hToolBar, $cID), $iTitle) Then _GUICtrlToolbar_ClickButton($hToolbar, $cID, $iButton, $sMove, $iClick, $iSpeed) Return 1 EndIf Next Return SetError(1, 0, 0) EndFunc ;some other code removed from here Either i'm doing it in the wrong way, or something else is f***d up .. Link to comment Share on other sites More sharing options...
bogQ Posted June 11, 2014 Share Posted June 11, 2014 (edited) did you check if Hamachi icon have that title when its offline (go with your mouse over icon and look to what do toltip say about its name)? I have title "Hamachi -- offline" under XP and it works perfectly for me with_SysTray_ClickItem("Hamachi -- ready", "left", 2) if @error Then Exit MsgBox(0,'','Error') Else ControlClick(WinWaitActive(WinActivate(WinWait('LogMeIn Hamachi'))),'','[CLASS:Button; INSTANCE:1]') EndIfmaybe you have some other title to put in instead? Edited June 11, 2014 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
JustSomeone Posted June 11, 2014 Author Share Posted June 11, 2014 (edited) did you check if Hamachi icon have that title when its offline (go with your mouse over icon and look to what do toltip say about its name)? I have title "Hamachi -- offline" under XP and it works perfectly for me with _SysTray_ClickItem("Hamachi -- ready", "left", 2) if @error Then Exit MsgBox(0,'','Error') Else ControlClick(WinWaitActive(WinActivate(WinWait('LogMeIn Hamachi'))),'','[CLASS:Button; INSTANCE:1]') EndIf maybe you have some other title to put in instead? It is the same title, i also tried with "Hamachi -- ready" and "Hamachi" and wichever combination of the symbols inside, it always set the error to 1 will try to set the icon to always shown and try again, but it will be bit later (will post feedback), because atm it's being hidden in that box where all the tray icons stay on win7 EDIT: after setting the icon to be perma shown, the script work fine, i also modified it abit. ;some code removed from here _SysTray_ClickItem("Hamachi -- offline", "left", 2) $error = @error Consolewrite("Error - " & $error &@crlf) if $error = 0 Then WinSetState('LogMeIn Hamachi',"",@SW_HIDE) ControlClick(WinWaitActive(WinActivate(WinWait('LogMeIn Hamachi'))),'','[CLASS:Button; INSTANCE:1]') WinClose('LogMeIn Hamachi') Else Exit EndIf Edited June 11, 2014 by JustSomeone Link to comment Share on other sites More sharing options...
bogQ Posted June 11, 2014 Share Posted June 11, 2014 (edited) Aldo window is not shown (still hidden under xp) when using this lines, checking status from window and click with this code works like expected on my comp with no icon interaction needed.Maybe something like this can be better solution if it works on hidden icon under win7? pls see if its work when you got time. If ControlGetText('LogMeIn Hamachi','','[CLASS:Static; INSTANCE:2]') == 'offline' Then ControlClick(WinWaitActive(WinActivate(WinWait('LogMeIn Hamachi'))),'','[CLASS:Button; INSTANCE:1]') Edited June 11, 2014 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
JustSomeone Posted June 12, 2014 Author Share Posted June 12, 2014 Since i observe 2 threads on the case, this here this >here i will check both solutions and post back 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