Sign in to follow this  
Followers 0
Killer69

Looping issue

10 posts in this topic

So, I'm trying to create a script that auto clicks the 9 key every 300ms or so... My gui is set with 3 buttons Play Pause and Exit.... I want the program to keep pressing the key until i hit the Pause button then pause/stop the program until i either press play or exit the program. I also put a PW on it from something i found in the forums here. I have searched for the past 3 hours through the help and the forums but im at a loss. Any help would be greatly appriciated.

; Script Start - Add your code below here
#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("My program!", 316, 266, 392, 348)
GUISetIcon("D:\002.ico")
$Button1 = GUICtrlCreateButton("&Play", 22, 203, 75, 25, 0)
GUICtrlSetTip(-1, "Starts the key clicking")
$Button2 = GUICtrlCreateButton("&Pause", 117, 204, 75, 25, 0)
GUICtrlSetTip(-1, "Pauses the program")
$Button3 = GUICtrlCreateButton("&Exit", 213, 204, 75, 25, 0)
GUICtrlSetTip(-1, "Quits the program")
$Pic1 = GUICtrlCreatePic("C:\Documents and Settings\J\My Documents\My Pictures\Fat guy.jpg", 16, 24, 276, 156, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$UserInput = "thief"
Do
    $answer = InputBox("Info is Required", "Please Input Your Access code.", "", "*")
    If $answer == $UserInput Then
       ; move on
    ElseIf @error = 1 Then
        Exit
    Else
        MsgBox(0, "Invalid", "Please enter the access code. Try Again.")
    EndIf
Until $answer == $UserInput             
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button2
    $var = EndFunc
Case $Button1
    $msg=GuiGetMsg()
    Do
        $var = Sleep(300)
        ControlSend("Program","",0,"9")
    Until $var = $Button2
Case $Button3
    Exit
EndSwitch
WEnd

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

; Script Start - Add your code below here
#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("My program!", 316, 266, 392, 348)
GUISetIcon("D:\002.ico")
$Button1 = GUICtrlCreateButton("&Play", 22, 203, 75, 25, 0)
GUICtrlSetTip(-1, "Starts the key clicking")
$Button2 = GUICtrlCreateButton("&Pause", 117, 204, 75, 25, 0)
GUICtrlSetTip(-1, "Pauses the program")
$Button3 = GUICtrlCreateButton("&Exit", 213, 204, 75, 25, 0)
GUICtrlSetTip(-1, "Quits the program")
$Pic1 = GUICtrlCreatePic("C:\Documents and Settings\J\My Documents\My Pictures\Fat guy.jpg", 16, 24, 276, 156, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$UserInput = "thief"
Do
    $answer = InputBox("Info is Required", "Please Input Your Access code.", "", "*")
    If $answer == $UserInput Then
      ; move on
    ElseIf @error = 1 Then
        Exit
    Else
        MsgBox(0, "Invalid", "Please enter the access code. Try Again.")
    EndIf
Until $answer == $UserInput   

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            AdlibEnable('_Send', 300);Use the _Send functione every 300 ms
        Case $Button2
            AdLibDisable()
        Case $Button3
            Exit
    EndSwitch
WEnd

Func _Send()
    ControlSend("Program","",0,"9")
    ConsoleWrite('9');Just to see if it's working
EndFunc
The AdLibEnable/AdlibDisable is what you were looking for. Look them up in the helpfile for more information...

Edited by Piano_Man

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites

Thank you so very much for the fast response.... I'm new to Autoit and didnt know about the Adlib function.. I really appreciate your help.

Share this post


Link to post
Share on other sites

Ok, now on that note.... I got it all working... well you did... Piano_man

And upon transferring it to my other comp I no longer have the pic displayed. I realize that it is linked from my original computer but my question is....

Is there a way to encode the picture into my .exe file so that the pic will go anywhere the program is opened

If you can just point me in the right direction i would appreciate it thanks again

Share this post


Link to post
Share on other sites

FileInstall()

You'll want a line like this at the top of your code:

FileInstall("C:\Documents and Settings\J\My Documents\My Pictures\Fat guy.jpg", 'C:\picture.jpg')

Look in the helpfile for more about fileinstall...


My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites

Thank you again Piano_Man youve been very helpful

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

One more question if it's not too much trouble. Now that I have this set to spam my one key I was thinking it would be a good idea to make this have an input box to select the key that I want to use. So I added an input box that pops up and removed the PW prompt. I have been reading all about GuiCtrlRead and searching these forums for a way to invoke my $variable inputbox input to work with this program and the help file as well.... I am a total noob to this programming language and my brain hurts and eyes are tired. Again, if you could just point me in the right direction I would appreciate it a lot. Thank you again.

#include <GUIConstants.au3>
FileInstall("C:\Documents and Settings\J\My Documents\My Pictures\Fat guy.jpg", 'C:\picture.jpg')
#Region ### START Koda GUI section ### Form=c:\documents and settings\j\desktop\koda\forms\form1.kxf
$Form1_1 = GUICreate("My Program!", 316, 273, 392, 348)
GUISetIcon("D:\002.ico")
GUISetBkColor(0x000000)
$Button1 = GUICtrlCreateButton("&Play", 22, 203, 75, 25, 0)
GUICtrlSetTip(-1, "Starts the key clicking")
$Button2 = GUICtrlCreateButton("&Pause", 117, 204, 75, 25, 0)
GUICtrlSetTip(-1, "Pauses the program")
$Button3 = GUICtrlCreateButton("&Exit", 213, 204, 75, 25, 0)
GUICtrlSetTip(-1, "Quits the program")
$Pic1 = GUICtrlCreatePic("C:\picture.jpg", 16, 24, 276, 156, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Replace_with_Key = GUICtrlCreateInput("Replace_with_Key", 96, 240, 121, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            AdlibEnable('GuiCtrlSendMsg', 300);Use the _Send functione every 300 ms
        Case $Button2
            AdLibDisable()
        Case $Button3
            Exit
    EndSwitch
WEnd

Func Guictrlsendmsg($Replace_with_Key,"Program",0,0);Doesnt this pick up what was entered in the test box???
    ConsoleWrite('9');Just to see if it's working
EndFunc
Edited by Killer69

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
FileInstall("C:\Documents and Settings\J\My Documents\My Pictures\Fat guy.jpg", 'C:\picture.jpg')
#Region ### START Koda GUI section ### Form=c:\documents and settings\j\desktop\koda\forms\form1.kxf
$Form1_1 = GUICreate("My Program!", 316, 273, 392, 348)
GUISetIcon("D:\002.ico")
GUISetBkColor(0x000000)
$Button1 = GUICtrlCreateButton("&Play", 22, 203, 75, 25, 0)
GUICtrlSetTip(-1, "Starts the key clicking")
$Button2 = GUICtrlCreateButton("&Pause", 117, 204, 75, 25, 0)
GUICtrlSetTip(-1, "Pauses the program")
$Button3 = GUICtrlCreateButton("&Exit", 213, 204, 75, 25, 0)
GUICtrlSetTip(-1, "Quits the program")
$Pic1 = GUICtrlCreatePic("C:\picture.jpg", 16, 24, 276, 156, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Replace_with_Key = GUICtrlCreateInput("Replace_with_Key", 96, 240, 121, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            AdlibEnable('_GuiCtrlSendMsg', 300);Use the _Send functione every 300 ms
        Case $Button2
            AdLibDisable()
        Case $Button3
            Exit
    EndSwitch
WEnd

Func _GuiCtrlSendMsg()
    Send(GuictrlRead($Replace_with_Key))
    ConsoleWrite(GuictrlRead($Replace_with_Key));Just to see if it's working
EndFunc
As far as I know calling a predefined function (GuiCrlSendMsg) with Adlibenable won't work because AdLibEnable can't use parameters... But this should let you see how the GuiCtrlRead function works... I also changed the adlibenable to _GuiCtrlSendMsg() and changed the function name to _GuiCtrlSendMsg() because it looks you were to rewrite the GuiCtrlSendMsg, which you can't do.


My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
FileInstall("C:\Documents and Settings\J\My Documents\My Pictures\Fat guy.jpg", 'C:\picture.jpg')
#Region ### START Koda GUI section ### Form=c:\documents and settings\j\desktop\koda\forms\form1.kxf
$Form1_1 = GUICreate("My Program!", 316, 273, 392, 348)
GUISetIcon("D:\002.ico")
GUISetBkColor(0x000000)
$Button1 = GUICtrlCreateButton("&Play", 22, 203, 75, 25, 0)
GUICtrlSetTip(-1, "Starts the key clicking")
$Button2 = GUICtrlCreateButton("&Pause", 117, 204, 75, 25, 0)
GUICtrlSetTip(-1, "Pauses the program")
$Button3 = GUICtrlCreateButton("&Exit", 213, 204, 75, 25, 0)
GUICtrlSetTip(-1, "Quits the program")
$Pic1 = GUICtrlCreatePic("C:\picture.jpg", 16, 24, 276, 156, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Replace_with_Key = GUICtrlCreateInput("Replace_with_Key", 96, 240, 121, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            AdlibEnable('_GuiCtrlSendMsg', 300);Use the _Send functione every 300 ms
        Case $Button2
            AdLibDisable()
        Case $Button3
            Exit
    EndSwitch
WEnd

Func _GuiCtrlSendMsg()
    Send(GuictrlRead($Replace_with_Key))
    ConsoleWrite(GuictrlRead($Replace_with_Key));Just to see if it's working
EndFunc
As far as I know calling a predefined function (GuiCrlSendMsg) with Adlibenable won't work because AdLibEnable can't use parameters... But this should let you see how the GuiCtrlRead function works... I also changed the adlibenable to _GuiCtrlSendMsg() and changed the function name to _GuiCtrlSendMsg() because it looks you were to rewrite the GuiCtrlSendMsg, which you can't do.


My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
FileInstall("C:\Documents and Settings\J\My Documents\My Pictures\Fat guy.jpg", 'C:\picture.jpg')
#Region ### START Koda GUI section ### Form=c:\documents and settings\j\desktop\koda\forms\form1.kxf
$Form1_1 = GUICreate("My Program!", 316, 273, 392, 348)
GUISetIcon("D:\002.ico")
GUISetBkColor(0x000000)
$Button1 = GUICtrlCreateButton("&Play", 22, 203, 75, 25, 0)
GUICtrlSetTip(-1, "Starts the key clicking")
$Button2 = GUICtrlCreateButton("&Pause", 117, 204, 75, 25, 0)
GUICtrlSetTip(-1, "Pauses the program")
$Button3 = GUICtrlCreateButton("&Exit", 213, 204, 75, 25, 0)
GUICtrlSetTip(-1, "Quits the program")
$Pic1 = GUICtrlCreatePic("C:\picture.jpg", 16, 24, 276, 156, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Replace_with_Key = GUICtrlCreateInput("Replace_with_Key", 96, 240, 121, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            AdlibEnable('_GuiCtrlSendMsg', 300);Use the _Send functione every 300 ms
        Case $Button2
            AdLibDisable()
        Case $Button3
            Exit
    EndSwitch
WEnd

Func _GuiCtrlSendMsg()
    Send(GuictrlRead($Replace_with_Key))
    ConsoleWrite(GuictrlRead($Replace_with_Key));Just to see if it's working
EndFunc
As far as I know calling a predefined function (GuiCrlSendMsg) with Adlibenable won't work because AdLibEnable can't use parameters... But this should let you see how the GuiCtrlRead function works... I also changed the adlibenable to _GuiCtrlSendMsg() and changed the function name to _GuiCtrlSendMsg() because it looks you were to rewrite the GuiCtrlSendMsg, which you can't do.

ahhh.... i see how you used the GuiCtrlSendMsg() this isnt exactly what im looking for but enough to get me going In the right direction. Thank you for your help again

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