Jump to content
Sign in to follow this  
zaetep

How to click on a toolbar button while computer is locked

Recommended Posts

zaetep

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
rcmaehl

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
zaetep

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
rcmaehl

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
zaetep

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
rcmaehl
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
zaetep

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
rcmaehl
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
zaetep

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
zaetep

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

Share this post


Link to post
Share on other sites
aNewLyfe

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
monoscout999

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
zaetep

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
Zedna

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  

  • Similar Content

    • BrewManNH
      By BrewManNH
      I was looking for a toolbar modification for SciTE and I was checking various versions of SciTE that were available on the internet. They all had some problems for how I wanted to use the editor, so I looked here to see if there were any toolbar modifications for Scite. I found one very old script by YogiBear (Volly) from 2006 that looked promising, though there were issues with it. I decided to see what I could do to modify this script, and make some improvements to it if possible. This script is the result of that work.

      It's not perfect and definitely could use some tweaking, but I thought that it had matured enough, and was mostly stable enough to release the updated version.

      Changelog:
      Version 2.0.1
      Minor update to remove all the old Obfuscator directives and replaced them with #Au3Stripper directives instead. I also corrected a minor bug that only showed up for me on one computer I tried this on, and caused the tool bar to crash for others as well.
      SciTE toolbar version 2.0
      Changed the settings values to use constants instead of 'magic numbers' The icons on the toolbar weren't lining up with the separator characters or with the toolbar GUI because they weren't set with the resize setting for the icons, only for the separators. Changed to using arrays for everything, it makes it a lot easier to loop through the controls Added a line to use an alternate path to the SciTE program, so you can start it using, for example, the portable version instead of installed version for those that don't install AutoIt and/or SciTE4AutoIt3. It will accept a commmand line parameter that points to the SciTE executable. Removed a lot of Global variables by moving the GUI creation and monitoring to the Main function and passing variables from it. I embedded the icon files into the script so that there isn't a separate download of the icon files used here. Saves download time and makes the package smaller. Modification of tools is easier because the icon names, tooltip text, and SciTE command codes are saved in the INI file upon first start up. These can be modified after the script has been run once, even after it's been compiled, by changing the ini file information, you can modify this script to automate it, or you can change it manually in any text editor. The icon files are now using, in just my opinion, better looking icons, after all it's been 7 years and icon files have matured. I have included a file with all of the constants that SciTE uses for its menu commands which comes from the SciTE source file "scite.h", so you can use this file to help you modify the commands that the toolbar works with, by figuring out what each of these values represent in SciTE. The core of the script is pretty much the same, I've just fixed a couple of issues that it had, tweaked a few things, added some new functionality and "prettied" it up a bit.

      If anyone has any suggestions as to improvements, bugs/bugfixes, etc. please let me know.

       
      scitetoolbar.zip
    • dadalt
      By dadalt
      Hi!
      I have a button where I need to close it!
      I was doing through  clicking same position in screen but there are some id's that have different sizes.
      What are the possible ways to click this closable button?
      Is there a way to close it through id? Is there a way to get it's position through it's ID?  
      Thanks in advance!


    • Bitpicker
      By Bitpicker
      Not the most eloquent nor efficient, to be sure, but with the following functionality:
      MULTI_BAR Features: ----------------------------------------------------------------
          * Floating MULTIBAR Toolbar with four(4) Docking Positions
          * Drag MULTI bar to Dock at any Edge  position
          * Drag Edge bar to screen center to Float as a MULTI bar
          * FADING EDGE BARS for LEFT, TOP-LEFT, TOP-RIGHT, RIGHT Sides
          * All 4 EDGE BARS and MULTI BAR can exist and execute at one time
          * All Toolbars use common INI file format
          * Any Toolbar  can be displayed by any positional Service EXE
          * All ToolBars have common Controls
              Return to calling BAR [ORIGIN}
              Manual Edit the INI file [INIEDIT]
              Create and place a NEW Toolbar on a button [NEWBAR]
              Search Icon Initiator - search for a Toolbar or a Button Function
              Set AUTO mode for EDGE bar show/fade on cursor or click, [AUTOSW]
              Set AUTO mode for FLOAT bar to close or stay open on button click [AUTOSW]
              Rotate thru 3 button sizes, small, medium and large w/label [B-SIZE]
              EXIT this bar [EXIT]
          * User specifies Number of BUTTONS and Number of ROWS
          * Change Dynamically Number of BUTTONS or ROWS
              via NEWBAR Function Specifying SAME BARNAME with Changed BUTTONS & ROWS
          * Three(3) Button sizes - User can change on demand
          * Shrink to Fit - Will Auto reduce Button size on DOCKING if Bar too long    
          * Buttons can be any File OPEN function, web link, or Open another TOOLBAR_BAR
          * ToolBars can be cascaded down(DRILL DOWN - Button points to another ToolBar) to additional Toolbars
              with Return to previous Toolbar via Origin Function
          * 2 BAR TYPES:
              ACTION(Buttons do TOOLBAR, FILE or URL OPENS)
                  User drops a Link on Button
              DROP(Buttons are Folder Targets)dropped files are sorted to destination
                  MOVE or COPY: FILE, FILE(s) or FOLDERS(DIRs) to Button target
                  Recycle Bin(a Shortcut) is supported as a DROP target for FILE, FILE(s) or FOLDERs
          * Button Context functions
              DELETE the current function - empty the button
              EDIT the TOOLTIP for this Button
              EDIT the LABEL displayed on Large Button
              PLUCK this Button for move to new location on this bar -or-
                  ANY other Bar (in this TOOLBOX)  
              PLACE any PLUCKED Button, or PLACE any NEW TOOL_BAR
              OPEN file location of Button file
      UNZIP the attached to a folder which will be the folder for all toolbar definitions
          and executables. THIS FOLDER IS YOUR TOOLBOX.
          TOOLBOX\MULTIBAR\]README.doc or ]README.pdf provides detail on functions and implementing.
                  
      Appreciate all the SILENT help from the AUTOIT community for this and my many projects. Thanks to all menbers who have provided the best self help book on applied AutoIt.
      Please advise on errors or suggestions. MULTIBAR was developed on Windows 10. Other targets or themes may present errors.For your personal use. Accept no responsibility for its functionality. Enjoy, olbitpicker
      MULTIBAR.zip
    • Robdog1955
      By Robdog1955
      I'm trying to click a button on a web page. I have added a couple of MsgBox lines to allow me to watch what happens on the page. As you can see the first half of my script enters data into text boxes on the page. I have no problem there. I just cannot click on the region buttons. The "set focus" line causes an outline to appear around the EU button and the "click button" line causes the "Pick a Region" text to disappear. Here is the code I have so far.
      #include <IE.au3> Local $oIE = _IECreate("http://questchecker.com/") Local $iQuestID = "123456" Local $sCharacterName = "CharacterName" Local $colForms = _IEFormGetCollection($oIE) $iCount = 0 For $oForm In $colForms $oFormElements = _IEFormElementGetCollection($oForm) For $oFormElement In $oFormElements $iCount = $iCount + 1 Local $sTagName = StringLower($oFormElement.tagName) Local $sElementType = $oFormElement.type Local $sElementName = $oFormElement.name Switch $iCount Case 6 _IEFormElementSetValue($oFormElement, "MyRealm", 0) ; realm Case 7 _IEFormElementSetValue($oFormElement, $sCharacterName, 0) Case 8 _IEFormElementSetValue($oFormElement, $iQuestID, 0) EndSwitch Next Next Local $oButtons = _IEGetObjByName($oIE, "questForm") For $oButton In $oButtons If _IEFormElementGetValue($oButton) = "US" Then MsgBox(0, "", "Click Okay to set focus") _IEAction($oButton, "focus") MsgBox(0, "", "Click Okay to click button") _IEAction($oButton, "click") ExitLoop EndIf Next MsgBox(0, "", "Click Okay to quit") _IEQuit($oIE) Exit  
    • dadalt95
      By dadalt95
      Perform a simple google search!
      The script below works fine until fill the google form!
      What I can't find is how to submit the form, tried a couple of ways and none of them worked.

       
      #include <IE.au3> $oIE = _IECreate ("www.google.com") $o_form = _IEFormGetObjByName ($oIE, "f") $o_login = _IEFormElementGetObjByName ($o_form, "q") $username = "80251369" _IEFormElementSetValue ($o_login, $username) $o_numer = _IEGetObjByName($o_form, "btnK") _IEAction ($o_numer, "click")  
      The code runs without any problem.
      I don't know how to proceed!
      Thanks in advance!
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.