Docfxit

Pause script until mouse click

12 posts in this topic

I would like to know how to pause a script until I select the Delete button with the mouse.

Opt("WinWaitDelay",100)
Opt("WinTitleMatchMode",4)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)
While 1 = 1
WinWait("Bookmark Duplicate Cleaner","")
If Not WinActive("Bookmark Duplicate Cleaner","") Then WinActivate("Bookmark Duplicate Cleaner","")
WinWaitActive("Bookmark Duplicate Cleaner","")
;Select bookmark on the left column
Send("{TAB}{SPACE}")
;Select duplicate on the right
Send("{TAB}{DOWN}")
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
;I would like to pause Until I select the delete key with the mouse.
;      This gives me time to Select the bookmarks on the right
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
WEnd

bookmarksDuplicateCleaner.jpg

Thank you,

Docfxit

Share this post


Link to post
Share on other sites



I guess a combination of things could work.

Is that application yours? is it third-party?

For an application that's yours you could use something like this example:

$SearchCursorInfo = GUIGetCursorInfo($YOURGUI)
If $SearchCursorInfo[4] = $BUTTON Then ;is the cursor on top of the button?
If _IsPressed("01", $hDLL) Then ;was the left mouse button pressed?

For third party im not sure, maybe get the text of the control mouse is hovering and then detecting a mouse press.


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Share this post


Link to post
Share on other sites

Something like this maybe:

#include <Array.au3>
Opt("WinWaitDelay",100)

HotKeySet('^s', 'SelectBookMarks')
HotKeySet('^q', 'ExitScript')

While 1
    Sleep(100)
WEnd

Func SelectBookMarks()
    $hWnd = WinWait("Bookmark Duplicate Cleaner","")
    If Not WinActive($hWnd,"") Then WinActivate($hWnd,"")
    WinWaitActive($hWnd,"")

    ;~ Get Window Position
    $aWinPos = WinGetPos($hWnd,"")
    ;~ Select left hand column
    MouseClick('left', $aWinPos[0] + 30, $aWinPos[1] + 50)

    ;Select bookmark on the left column
    Send("{TAB}{SPACE}")
    ;Select duplicate on the right
    Send("{TAB 3}")

EndFunc

Func ExitScript()
    Exit
EndFunc

 

Share this post


Link to post
Share on other sites

Hi careca,

The application does not belong to me.  It's a free add-on to Firefox called Bookmark Duplicate Cleaner.  Your solution almost works.  I have commented out the first two lines, added an EndIf and an #include.  What happens is the script doesn't stop to wait for me to select the entries on the right column.  This is what I have:

Opt("WinWaitDelay", 100)
Opt("WinTitleMatchMode", 4)
Opt("WinDetectHiddenText", 1)
Opt("MouseCoordMode", 0)
#include <Misc.au3>
Local $YOURGUI, $BUTTON, $hDLL
While 1 = 1
    WinWait("Bookmark Duplicate Cleaner", "")
    If Not WinActive("Bookmark Duplicate Cleaner", "") Then WinActivate("Bookmark Duplicate Cleaner", "")
    WinWaitActive("Bookmark Duplicate Cleaner", "")
    ;Select bookmark on the left column
    Send("{TAB}{SPACE}")
    ;Select duplicate on the right
    Send("{TAB}{DOWN}")
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
    ;I would like to pause Until I select the delete key with the mouse.
    ;      This gives me time to Select the bookmarks on the right
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
    ;$SearchCursorInfo = GUIGetCursorInfo($YOURGUI)
    ;If $SearchCursorInfo[4] = $BUTTON Then ;is the cursor on top of the button?
    ;EndIf

    If _IsPressed("01", $hDLL) Then ;was the left mouse button pressed?

    EndIf
WEnd

Thank you,

Docfxit

Share this post


Link to post
Share on other sites

Hi Subz,

You solution almost works.  It doesn't let me select the bookmarks on the right.  When I press the "S" it automatically selects and deletes the last bookmark on the right.  I need it to allow me to select the bookmarks I want to delete and then I will press the Delete button.

Thank you,

Docfxit

Share this post


Link to post
Share on other sites

Strange because I have the app on my system and it works fine, are you pressing Ctrl+s?

Share this post


Link to post
Share on other sites

You could try this, it's a lot more complicated than using _IsPressed but it will only get called when a mouse event happens and only execute code when the left mouse button is released. I left those commented out $hParent and $iCtrlId in case you wanted to delve further. The WindowFromPoint should get the handle of the button, which you can compare in the If statement. But you might want to get the parent of that button and get the control id of a control from a handle

#include <WinAPI.au3>
#include <WindowsConstants.au3>

Global Const $tagMSLLHOOKSTRUCT = $tagPOINT & ";DWORD mouseData;DWORD flags; DWORD time;ULONG_PTR dwExtraInfo"
Global $hKeyProc = DllCallbackRegister("KeyProc", "long", "int;wparam;lparam")
Global $hKeyHookEx = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($hKeyProc), _WinAPI_GetModuleHandle(0))
OnAutoItExitRegister(Cleanup)

While 1
    Sleep(100)
WEnd

Func KeyProc($nCode, $wParam, $lParam)
    If ($nCode < 0) Then Return _WinAPI_CallNextHookEx($hKeyHookEx, $nCode, $wParam, $lParam)

    Switch ($wParam)
        Case $WM_LBUTTONUP
            Local $tMsllHookStruct = DllStructCreate($tagMSLLHOOKSTRUCT, $lParam)
            Local $hWindowUnderMouse = _WinAPI_WindowFromPoint($tMsllHookStruct)
            $tMsllHookStruct = Null
;~          Local $hParent = _WinAPI_GetParent($hWindowUndermouse)
;~          If (@Error) Then EndSwitch
;~          Local $iCtrlId = _WinAPI_GetDlgCtrlID($hWindowUndermouse)
;~          If (@Error) Then EndSwitch

            If ($hWindowUnderMouse = ControlGetHandle("Bookmark Duplicate Cleaner", "", "[Class:Button(BUTTON ID HERE)]")) Then
                ; Unpause script or do whatever you want
            EndIf
    EndSwitch

    Return _WinAPI_CallNextHookEx($hKeyHookEx, $nCode, $wParam, $lParam)
EndFunc   ;==>_KeyProc

Func Cleanup()
    _WinAPI_UnhookWindowsHookEx($hKeyHookEx)
    DllCallbackFree($hKeyProc)
    OnAutoItExitUnRegister(Cleanup)
EndFunc   ;==>Cleanup

 

Share this post


Link to post
Share on other sites

Hi InunoTaishou,

I tried getting the Button ID for the delete box.  The AutoIt Window Info program doesn't show a Control for the Delete box.  I wish it did.

Thanks,

Docfxit

Share this post


Link to post
Share on other sites

Hi Subz,

I modified it slightly and it's almost working.  I'm getting an error on the MouseClick because I added speed = 0

The error I get is undefined function.

#include <Array.au3>
Opt("WinWaitDelay", 100)
AutoItSetOption("TrayIconDebug", 1)

HotKeySet('^s', 'SelectBookMarks')
HotKeySet('^q', 'ExitScript')

While 1
    Sleep(100)
WEnd

Func SelectBookMarks()
    $hWnd = WinWait("Bookmark Duplicate Cleaner", "")
    If Not WinActive($hWnd, "") Then WinActivate($hWnd, "")
    WinWaitActive($hWnd, "")

;~ Get Window Position
    $aWinPos = WinGetPos($hWnd, "")
;~ Select left hand column
    MouseClick('left', $aWinPos[0] + 30, $aWinPos[1] + 70, 1, speed = 0)

    ;Select duplicate on the right
    Send("{TAB}{Down}{SPACE}")
    ;Move Mouse to right column
    MouseMove($aWinPos[0] + 530, $aWinPos[1] + 90, speed = 0)
    ;Select Delete Button
    Send("{TAB 3}")

EndFunc   ;==>SelectBookMarks

Func ExitScript()

Thanks,

Docfxit

Share this post


Link to post
Share on other sites

#10 ·  Posted

You'll need to replace speed = 0 with just 0 for example:

MouseMove($aWinPos[0] + 530, $aWinPos[1] + 90, 0)

Share this post


Link to post
Share on other sites

#11 ·  Posted

Hi Subz,

 

You are really great.  It works absolutely perfect.

Thank you very very much,

Docfxit

Share this post


Link to post
Share on other sites

#12 ·  Posted

11 hours ago, Docfxit said:

What happens is the script doesn't stop to wait for me to select the entries on the right column.

That would be the second part of the help, it was now i would point you in that direction.

Seeing that you have found another solution, im happy for you. =)


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

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