Sign in to follow this  
Followers 0
gatsbysamericandream

Calling A Function Through The Mouseclick Command?

13 posts in this topic

Hi everyone, I'm new to the forums. I tried to avoid the noob thing and I atleast read the FAQ and searched for an answer to this first but couldn't find anything in the few pages I looked. Anyway, I have a few questions.

How would I go about Calling a function through the mouseclick("left") command?

How do you send text to an un-active (but opened) notepad file through autoit?

Is it possible to compile an eternal notepad file through autoit?

I hope you guys can help me out. I look forward to posting in this forum a lot. Thanks Team.

Share this post


Link to post
Share on other sites



Hi everyone, I'm new to the forums. I tried to avoid the noob thing and I atleast read the FAQ and searched for an answer to this first but couldn't find anything in the few pages I looked. Anyway, I have a few questions.

How would I go about Calling a function through the mouseclick("left") command?

How do you send text to an un-active (but opened) notepad file through autoit?

Is it possible to compile an eternal notepad file through autoit?

I hope you guys can help me out. I look forward to posting in this forum a lot. Thanks Team.

Question 1 needs Beta, it can be found in the Developers forum... Top up where the sticky's are: The function is _IsPressed() once downloaded you can view in the help file.

Question 2 you'll look at ControlSend() in the help file

Question 3 you'll look at FileInstall() in the help file

Welcome to the forums.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Hi everyone, I'm new to the forums. I tried to avoid the noob thing and I atleast read the FAQ and searched for an answer to this first but couldn't find anything in the few pages I looked. Anyway, I have a few questions.

How would I go about Calling a function through the mouseclick("left") command?

How do you send text to an un-active (but opened) notepad file through autoit?

Is it possible to compile an eternal notepad file through autoit?

I hope you guys can help me out. I look forward to posting in this forum a lot. Thanks Team.

Func _IsPressed($hexKey)
  Local $aR, $bO
 
  $hexKey = '0x' & $hexKey
  $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
  If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then
     $bO = 1
  Else
     $bO = 0
  EndIf
 
  Return $bO
EndFunc ;==>_IsPressed

while 1
if _isPressed(01) then
;do something
endif
wend

Share this post


Link to post
Share on other sites

Thanks a lot man. Fast response, very nice. I'll download the beta right now.

Share this post


Link to post
Share on other sites

Func _IsPressed($hexKey)
  Local $aR, $bO
 
  $hexKey = '0x' & $hexKey
  $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
  If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then
     $bO = 1
  Else
     $bO = 0
  EndIf
 
  Return $bO
EndFunc;==>_IsPressed
Just FYI pixartist, you can shorten that down to:
Func _IsPressed($s_hexKey, $v_dll = 'user32.dll')
    Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey)
    If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1
    Return 0
EndFunc  ;==>_Is_Key_Pressed
Not that it's necessary, but maybe that'll come in handy down the road for God knows whatever reason :think: .

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

To answer your questions:

How would I go about Calling a function through the mouseclick("left") command?

#include<misc.au3>

If _IsPressed ("01") then _yourfunc()

How do you send text to an un-active (but opened) notepad file through autoit?

if $window1 = winexist("name of notepad window") then

controlsend($window1, "", "edit1", "any text you like", 1)

Is it possible to compile an eternal notepad file through autoit?

You can, if you make a au3 file associated with notepad. then save the file as a au3. You would be much better off using Scite as your code editor. Once you use Scite, and all the tools that come with it, you will think: Notepad??? for coding???? why would I want to do that????? :think:

Edited by vollyman

Share this post


Link to post
Share on other sites

think: Notepad??? for coding???? why would I want to do that????? :think:

OH I USE SCITE!

Anyway, thanks for all the help guys. I think I got a handle on things now.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

OH I USE SCITE!

Anyway, thanks for all the help guys. I think I got a handle on things now.

Is it possible to compile an eternal notepad file through autoit?

you can use FileInstall() to install the notepad.exe within your script/program

maybe take a look at this ( very good examples )

http://www.autoitscript.com/forum/index.php?showtopic=21048#

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

Ok so I used _Ispressed to perform something IF it is clicked. How would I make it double click?

Share this post


Link to post
Share on other sites

MouseClick ( "button" [, x, y [, clicks [, speed ]]] )

So:
MouseClick('left', $x, $y, 2)
The 2 representing 2 clicks.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Silly Goose. I meant is there a way to make the _Ispressed function detect double clicks by adding a delay or something. I tried to figure it out but couldnt.

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Silly Goose. I meant is there a way to make the _Ispressed function detect double clicks by adding a delay or something. I tried to figure it out but couldnt.

Well you did say "make" it double click, not "show" it double clicked..

I made this a while back..

Global $PRIMARY, $SECONDARY
_MouseButton($PRIMARY, $SECONDARY)

While 1
    If DoubleClickCheck() Then MsgBox(0, 'Double', 'You double clicked')
Wend


Func DoubleClickCheck($t_Time_One = 2, $v_dll = 'user32.dll'); $t_Time_One is an optional paramater, you can set the delay longer if you like
    Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $PRIMARY)
    If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then 
        Do
            $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $PRIMARY)
        Until BitAND($a_R[0], 0x8000) <> 0x8000
        Local $Timer = TimerInit()
        While 1
            $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $PRIMARY)
            If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1
            If TimerDiff($Timer) / 1000 >= "." & $t_Time_One Then Return 0
        WEnd
    EndIf
    Return 0
EndFunc

Func _MouseButton(ByRef $PRIMARY, ByRef $SECONDARY)
    Local $k = ''
    $k = RegRead("HKEY_CURRENT_USER\Control Panel\Mouse", "SwapMouseButtons")
    If $k = 1 Then
        $PRIMARY = "02"
        $SECONDARY = "01"
    Else
        $PRIMARY = "01"
        $SECONDARY = "02"
    EndIf
EndFunc
If you want a longer delay, you can set that in the () parameter of _DoubleClickCheck()... so _DoubleClickCheck(3) would give it a 300th of a second delay rather than a 200th and so on.

Edit:

Made it one Function..., Other than determining what is the Primary or Secondary button, but you can just replace primary with whatever (left or right) if it just your computer your using it on.

Also... If you don't want to determine the button and you always want it to be the left:

While 1
    If DoubleClickCheck() Then MsgBox(0, 'Double', 'You double clicked')
Wend


Func DoubleClickCheck($t_Time_One = 2, $v_dll = 'user32.dll'); $t_Time_One is an optional paramater, you can set the delay longer if you like
    If Not IsDeclared('PRIMARY') Then $PRIMARY = '01'
    Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $PRIMARY)
    If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then 
        Do
            $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $PRIMARY)
        Until BitAND($a_R[0], 0x8000) <> 0x8000
        $Timer = TimerInit()
        While 1
            $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $PRIMARY)
            If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1
            If TimerDiff($Timer) / 1000 >= "." & $t_Time_One Then Return 0
        WEnd
    EndIf
    Return 0
EndFunc
This will take care of either way... if you delcare it ahead of time like the first example, but will be the 'left' button if not. Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

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