Jump to content

Calling A Function Through The Mouseclick Command?


Recommended Posts

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.

Link to comment
Share on other sites

  • Moderators

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.

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.

Link to comment
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
Link to comment
Share on other sites

  • Moderators

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: .

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • Moderators

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

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

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.

Link to comment
Share on other sites

  • Moderators

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

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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...