Sign in to follow this  
Followers 0
zaetep

How to click on a toolbar button while computer is locked

14 posts in this topic

Hi, I am writing a script to run a software package overnight.

The PC needs to be locked during this time ([windows key] + L).

The program presses various GUI controls on the 3rd party software in a certain order.

There is one toolbar button i need to press (as well as several buttons and menus which are no problem)

I am able to click buttons when it is locked using _GUICtrlButton_Click() as controlClick() won't work, but the toolbar version of this function _GUICtrlToolbar_ClickButton() needs to use the mouse pointer and so doesn't work when the computer is locked or the window isn't the active window.

Any help would be greatly appreciated

Share this post


Link to post
Share on other sites



Which version of windows. Please include full info. EG: Windows XP Professional Service Pack 3 64-bit


My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

MY PROJECTS


Active: IRC UDF, WindowEx UDF
Discontinued: GithubBubbleSort UDF

Share this post


Link to post
Share on other sites

Which version of windows. Please include full info. EG: Windows XP Professional Service Pack 3 64-bit

Windows XP Professional Service Pack 3 32-bit Version 2002

Share this post


Link to post
Share on other sites

Send an Alt keypress, which SHOULD go to the Toolbar, then use the left and right arrow keys to navigate to the toolbar item, then use spacebar (or enter) to open the toolbar. Feel free to modify this however it SHOULD work.


My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

MY PROJECTS


Active: IRC UDF, WindowEx UDF
Discontinued: GithubBubbleSort UDF

Share this post


Link to post
Share on other sites

Send an Alt keypress, which SHOULD go to the Toolbar, then use the left and right arrow keys to navigate to the toolbar item, then use spacebar (or enter) to open the toolbar. Feel free to modify this however it SHOULD work.

Thanks, however send commands don't seem to work while the PC is locked, no keyboard or mouse functions are available as there are no active windows.

Share this post


Link to post
Share on other sites
Totally failed there. Got my Linux and Windows knowledge mixed up. However try _GUICtrlToolbar_PressButton instead of _GUICtrlToolbar_ClickButton()

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

MY PROJECTS


Active: IRC UDF, WindowEx UDF
Discontinued: GithubBubbleSort UDF

Share this post


Link to post
Share on other sites

Totally failed there. Got my Linux and Windows knowledge mixed up. However try _GUICtrlToolbar_PressButton instead of _GUICtrlToolbar_ClickButton()

I've tried that but it doesn't seem to actually activate the control (even when not locked), i also tried pressing and releasing the button but it does nothing.

_GUICtrlToolbar_PressButton($b, "Channel")

Sleep(1000)

_GUICtrlToolbar_PressButton($b, "Channel", False)

_GUICtrlToolbar_ClickButton($b,"Channel") works but only when the window is active

Share this post


Link to post
Share on other sites
How about _GUICtrlToolbar_CheckButton()?

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

MY PROJECTS


Active: IRC UDF, WindowEx UDF
Discontinued: GithubBubbleSort UDF

Share this post


Link to post
Share on other sites

How about _GUICtrlToolbar_CheckButton()?

Once again just makes the button look like its pressed without actually activating it (although it seems to work when the PC is locked)

I have been trying to find something that can use: _GUICtrlToolbar_SetCmdID($b,4, $cd) and then use the identifier to operate the button directly (the way _GUICtrlButton_Click($cd) works)

Share this post


Link to post
Share on other sites

Is there a way of sending keystrokes while the machine is locked?

Share this post


Link to post
Share on other sites

have you tried ControlSend() yet ?


:alien: ~ Every Living Thing is a Code Snippet of World Application ~ :alien:

Share this post


Link to post
Share on other sites

Edit this Sppet and try it...

#include <WindowsConstants.au3>
#Include <winapi.au3>
#Include <GuiToolBar.au3>
ShellExecute("SnippingTool.exe")
WinWait("[CLASS:Microsoft-Windows-Tablet-SnipperToolbar]")
$winHndl = wingethandle("[CLASS:Microsoft-Windows-Tablet-SnipperToolbar]")
$toolbarHndl = ControlGetHandle($winHndl,"","[CLASS:ToolbarWindow32; INSTANCE:1]")

_sendclick()

Func _sendclick()
    Local $lParam = $toolbarHndl
    Local $BN_CLICKED = 0x0000FFFF
    Local $NID = 219
    local $wParam = _WinAPI_MakeLong($NID, $BN_CLICKED)
    $message = _WinAPI_PostMessage($winHndl,$WM_COMMAND,$wParam,$lParam)
EndFunc   ;==>_sendclick

Share this post


Link to post
Share on other sites

THANKYOU Monoscout!!!!!!!!!! Got it working

Local $w = WinGetHandle("MC", "")

Local $b = ControlGetHandle("MC", "", "[CLASSNN:ToolbarWindow321]")

Local $cid = _GUICtrlToolbar_IndexToCommand($b, 4)

Local $wParam = _WinAPI_MakeLong($cid, $BN_CLICKED)

$message = _WinAPI_PostMessage($w, $WM_COMMAND, $wParam, $:mellow:

(Thanks to everyone else who had a go too)

Share this post


Link to post
Share on other sites

Just for reference, here are apropriate MSDN links as explanation of this solution:

Toolbar

http://msdn.microsoft.com/en-us/library/bb760435%28v=VS.85%29.aspx

NM_CLICK (toolbar) Notification Code

http://msdn.microsoft.com/en-us/library/bb760490%28v=VS.85%29.aspx

BN_CLICKED Notification Code

http://msdn.microsoft.com/en-us/library/bb761825%28v=VS.85%29.aspx

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  
Followers 0

  • Similar Content

    • OtenMoten
      By OtenMoten
      Hello dear community,
       
      definitely I need external help now. I've did all 'ControlClick() - Tutorials' and read a lot of topics about interaction betweend AutoIT and external programs.
      The most of them are about "Clicking a button ...". In my case it's different because I need to click a specific element within the program.
       
      The 'program' what I am talking about is called Mendeley. It's library software for documents administration.
       
      In the attachements in picture '1.jpg' you can see the red marked Help element. 
      In the picture '2.jpg' you see the context menu of the Help element. This is what I'm trying to do with the ControlClick() function.
       
      Following I represent my code which not worked for me:
      #include <MsgBoxConstants.au3> Opt("WinTitleMatchMode", 2) $hWnd = WinGetHandle("Mendeley Desktop", "") MsgBox($MB_SYSTEMMODAL, "handle check", $hWnd) ControlClick($hWnd, "Mendeley Desktop", "Help") The MsgBox tells me the number of the handle of the Mendeley window. It's not 0 so for me it means the window is recognized correctly.
       
      When I'm execute the script the Help element is not clicked.
      Any suggestions for me?
       
      Kind regards
      OtenMoten


    • boy233
      By boy233
      I need to click on the text "Batch submission" but I can not!
      <div class="batchmenu2" onclick="Go('/lot/')" style="background-color: rgb(255, 255, 255);"> <span class="iconep">l</span> <div class="menu"> <b>Batch submission</b> <br> Bulk messages via file </div> </div> How could I do it?
      How can I click the specific OnClick?
       
    • SkysLastChance
      By SkysLastChance
      <input name="VsMasterPage$MainContent$LoginUserControl$LoginForm$FormsAuthLoginContainer$LoginButton$InternalButton" class="Button" id="VsMasterPage_MainContent_LoginUserControl_LoginForm_FormsAuthLoginContainer_LoginButton_InternalButton" onclick='javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("VsMasterPage$MainContent$LoginUserControl$LoginForm$FormsAuthLoginContainer$LoginButton$InternalButton", "", true, "Login", "", false, false))' type="submit" value="Sign In"> I am trying to click the sign in button on this page. 
      I have tried by class, text, etc 
      Here was my last attempt
      $oButtons = _IETagNameAllGetCollection($o_IE, "button") For $oButton in $oButtons If String($oButton.value) = "Sign In" Then Sleep (1000) _IEAction($oButton, "click") ExitLoop EndIf Next This did not work either.
    • 5ervant
      By 5ervant
      Go create a quick account in Zapier and go to https://zapier.com/app/dashboard and make some Zaps!
      Just need to click the specific instance of an .open-menu button and then click its a.run (anchor) element.
      Doing this IE.au3 script just causing to click its container element:
      $target = 1; Target the first instance #include <IE.au3> $oIE = _IEAttach("Dashboard - Zapier") $count = 0; $tags = _IETagNameGetCollection($oIE, "div") For $tag in $tags $class_value = $tag.GetAttribute("class") If $class_value = "open-menu" Then $count += 1 if $count = $target Then MsgBox(0, "Instance: ", $count) ; $tag.fireEvent("onmousedown") ; _IEAction($tag, "click") ; $tag.fireEvent("onmouseup") ; Or this but not working ; $tag.Click EndIf EndIf Next I also tried to do it using FF.au3
      $target = 1; Target the first instance #Include <Array.au3> #Include <FF.au3> $count = 0; If _FFConnect(Default, Default, 3000) Then $aArray = _FFXPath( "//div[@class='open-menu']", "", 7 ) ; _ArrayDisplay($aArray) For $tag in $aArray $count += 1 if $count = $target Then MsgBox(0, "Instance: ", $count) _FFClick($tag) EndIf Next EndIf Error: _FFClick ==> No match: $sElement: [number]
      Could some help me how to click such buttons on such kind of a dynamic page?
    • dejhost
      By dejhost
      Hi everybody,
      I have troubles using the function "GUISetCursor" properly.
      My script generates a small GUI and opens an image in IrfanView. If the user hits the button "$p_coord" on the GUI, the GUI shall be hidden, IrfanView shall become active and the mousepointer shall turn into a cross (as long hovering over IrfanView). Once clicked into IrfanView, the cursor shall turn into a nordinary mousepointer again.
      Unfortunately, the cross doesn't appear until the user clicks into IrfanView manually. Then the mousepointer changes for the duration of the click into the cross. Can anybody tell why this is happening?
      Here is the relevant code:
      GUISetState(@SW_SHOW, $hGUI) ;the autoit gui is hidden ; Loop until the user exits: While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $p_coord WinSetState("Bicon Coordinator","",@SW_HIDE) ;the autoit gui is hidden $Handle = WinActivate ( "IrfanView") ; IrfanView is activated GUISetCursor (15,1,$Handle) ;Cursor should be turned into a cross - this is what fails :-( While 1 If _IsPressed ("01", $hDLL) Then ;Once a mousclick by the user is performed... GUISetCursor (2) EndIf EndSwitch WEnd  
      dejhost