Sign in to follow this  
Followers 0
shmuelw1

Wait for click

6 posts in this topic

I wrote a script to copy the filename of a file that I click on, and paste it over the filename of another file that I click on (but not over the file extension).

For some reason the script is never getting to Func Clicked() no many how many times I click.

Any ides?

; Copies filename and extension from selected file to another selected file, but 
; does not paste over the file extension of the 2nd file

; #include "Other\MyFunctions.au3"
#include <GUIConstantsEx.au3> ; defines various GUI events

Dim $numClicks = 0

Opt("GUIOnEventMode", 1)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "Clicked")

While 1
    Sleep(1000)
WEnd

Func Clicked()
    $numClicks = $numClicks + 1
    Select
        Case $numClicks = 1  ; on 1st nouse click, copy the filename
            Send("{APPSKEY}")
            Sleep(200)
            Send("{UP 2}")
            Send("{ENTER}")
            Sleep(200)
            Send("^c")
            Send("{ENTER}")
        Case $numClicks > 1 ; on 2nd nouse click, paste the filename
            Send("{APPSKEY}")
            Sleep(200)
            Send("{UP 2}")
            Send("{ENTER}")
            Sleep(200)
            Send("{LEFT 4}")
            Sleep(200)
            Send("^+{HOME}")
            Send("^v")
            Send("{ENTER}")
            Exit
    EndSelect
EndFunc

Share this post


Link to post
Share on other sites



shmuelw1,

That is because you do not have a GUI to click in! :P

You will have to use _IsPressed to register the clicks. :x

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thanks! I didn't know GUISetOnEvent and GUICtrlSetOnEvent were only for an AutoIt GUI.

That should be added it the AutiIt help, along with a reference to _IsPressed.

shmuelw1,

That is because you do not have a GUI to click in! :P

You will have to use _IsPressed to register the clicks. :x

M23

Share this post


Link to post
Share on other sites

shmuelw1,

The clue in the name (GUISetOnEvent and GUICtrlSetOnEvent) is not enough? :x

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

I don't use AutoIt for GUIs, so for me it was not enough. I just want a simple script for keystrokes in Windows programs, but I want it to pause until the next mouse click. I did some searching in the help and all I found was GUISetOnEvent and GUICtrlSetOnEvent.

So I think it would be helpful to have a reference in these functions to _IsPressed.

I did see IsPressed mentioned on the web, but I couldn't find it because they left out the underscore before it. At least this new topic should be find-able since I gave it a decent title :x

Thanks everyone for the help!

shmuelw1,

The clue in the name (GUISetOnEvent and GUICtrlSetOnEvent) is not enough? :P

M23

Share this post


Link to post
Share on other sites

OK, here it is, and it works.

Thanks Melba23!

; Copies filename and extension from selected file to another selected file, but 
; does not paste over the file extension of the 2nd file

#Include <Misc.au3> ; for _IsPressed

$dll = DllOpen("user32.dll")

While 1
    If _IsPressed("01", $dll) Or _IsPressed("02", $dll) Then ExitLoop
WEnd
Send("{APPSKEY}")
Sleep(200)
Send("{UP 2}")
Send("{ENTER}")
Sleep(200)
Send("^c")
Send("{ENTER}")
While 1
    If _IsPressed("01", $dll) Or _IsPressed("02", $dll) Then ExitLoop
WEnd
Send("{APPSKEY}")
Sleep(200)
Send("{UP 2}")
Send("{ENTER}")
Sleep(200)
Send("{LEFT 4}")
Sleep(200)
Send("^+{HOME}")
Send("^v")
Send("{ENTER}")
Exit

DllClose($dll)

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