Sign in to follow this  
Followers 0
RacecarSoft

KeyPress Development

31 posts in this topic

#1 ·  Posted (edited)

This can be called a continuation of my previous thread, (http://www.autoitscript.com/forum/index.php?showtopic=85026).

I am currently working on KeyPress v1.1 now.

I made the UI with Koda v1.7.0.8 and modified it a bit in SCiTE.

I want to make the OK button minimize KeyPress and then type the keys repeatedly

(to stop, the user right-clicks the icon in task bar and clicks exit).

The Exit button works, but the OK just gives me an error noise/nothing happens.

I am using Windows XP SP3.

Here is the source code:

#Region;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Version=beta
#AutoIt3Wrapper_icon=My Pictures\KP.ico
#AutoIt3Wrapper_outfile=KeyPress 1.1 WIN32.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Res_Comment=Made by Racecar 56 at www.racecar56.b3ta.org.
#AutoIt3Wrapper_Res_Description=www.racecar56.b3ta.org
#AutoIt3Wrapper_Res_Fileversion=1.1.0.0
#AutoIt3Wrapper_Res_Language=1033
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=y
#AutoIt3Wrapper_Run_Tidy=y
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------
    
    AutoIt Version: 3.2.13.12
    Author: Racecar56
    Script Version: 1.1.0.0 Final
    
    Script Function:
    Press the specified keys numerous times.
    
#ce ----------------------------------------------------------------------------
; Script Start - Add your code below here

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
Opt('MustDeclareVars', 1)
Opt("GUICoordMode", 2)
Local $foo
main()
Func main()
    Dim $myedit, $msg, $TYPEME, $OK
    $foo = "foo"
    GUICreate("RacecarSoft KeyPress"); will create a dialog box that when displayed is centered
    $OK = GUICtrlCreateButton("OK", 0, 100, 100)
    GUICtrlCreateLabel("Right-click tray icon and click Exit to exit.", 100, -120, 100)
    $myedit = GUICtrlCreateEdit("" & $foo, -300, -28, 200, 97, $ES_AUTOVSCROLL + $WS_VSCROLL)
    GUISetState()
    Send("{END}")
; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $OK
                pressKeys()
        EndSelect
    WEnd
EndFunc  ;==>main
Func pressKeys()
    Dim $bar
    $bar = 0
    While $bar <= 0
        Send($foo)
        Sleep(05)
    WEnd
EndFunc  ;==>pressKeys

NEWS: Version 1.1 out!

Edited by RacecarSoft

[s]Visit My Website[/s] (this isn't up 24/7). (SITE DOWN) This is now a HP MediaSmart site, I'm trying to get my server working the way I want it to.24/7 site (make sure you have noscript, sorry!): 24/7 [u]WARNING: MUST have NoScript so you can block quantserve/quantcast![/u] If you don't, the evil freewebs/webs/quantcast/quantserve/WHATEVER virus will get you![spoiler]Hey, look! It's a spoiler![/spoiler]Software: KeyPress, Advanced Calculator (not autoit), WUK (Windows Update Killer)my account over a year old : >... I do Linux.

Share this post


Link to post
Share on other sites



The Exit button works, but the OK just gives me an error noise/nothing happens.

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $OK
            Send($foo) <<<-- Send to where? -->>>
        Case $Exit
            Exit
    EndSwitch
WEnd
To what program are you going to send $foo?

Share this post


Link to post
Share on other sites

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$foo = "Text to type."

$Form1_1 = GUICreate("KeyPress v1.1", 633, 447, 192, 124)
$Edit1 = GUICtrlCreateEdit("", 8, 8, 329, 129)
GUICtrlSetData( $Edit1 , $foo )
GUICtrlCreateLabel("RacecarSoft KeyPress v1.1" & @CRLF & "Build Date: 2008/12/14", 352, 8, 268, 25)
$OK = GUICtrlCreateButton("OK", 576, 408, 41, 25, 0)
$Exit = GUICtrlCreateButton("Exit", 528, 408, 41, 25, 0)

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $OK
            MsgBox( 0 , "" , $foo )
        Case $Exit
            Exit
    EndSwitch
WEnd

I got this to work. (so far =D )

Share this post


Link to post
Share on other sites

To what program are you going to send $foo?

Anything that just so happens to be open.

[s]Visit My Website[/s] (this isn't up 24/7). (SITE DOWN) This is now a HP MediaSmart site, I'm trying to get my server working the way I want it to.24/7 site (make sure you have noscript, sorry!): 24/7 [u]WARNING: MUST have NoScript so you can block quantserve/quantcast![/u] If you don't, the evil freewebs/webs/quantcast/quantserve/WHATEVER virus will get you![spoiler]Hey, look! It's a spoiler![/spoiler]Software: KeyPress, Advanced Calculator (not autoit), WUK (Windows Update Killer)my account over a year old : >... I do Linux.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

maybe: Send(GUICtrlRead($foo)) when you want to send the value of the control and also need to set the focus to the appropriate window first.

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

not really unless you don't want to use the Edit Control. :)

I actually found out it is not fixed (other words your are right).

How can I fix it now?

By the way, I am using AutoIt beta.


[s]Visit My Website[/s] (this isn't up 24/7). (SITE DOWN) This is now a HP MediaSmart site, I'm trying to get my server working the way I want it to.24/7 site (make sure you have noscript, sorry!): 24/7 [u]WARNING: MUST have NoScript so you can block quantserve/quantcast![/u] If you don't, the evil freewebs/webs/quantcast/quantserve/WHATEVER virus will get you![spoiler]Hey, look! It's a spoiler![/spoiler]Software: KeyPress, Advanced Calculator (not autoit), WUK (Windows Update Killer)my account over a year old : >... I do Linux.

Share this post


Link to post
Share on other sites

I actually found out it is not fixed (other words your are right).

How can I fix it now?

By the way, I am using AutoIt beta.

I gave the answer a few posts up.

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I gave the answer a few posts up.

It won't work.

[s]Visit My Website[/s] (this isn't up 24/7). (SITE DOWN) This is now a HP MediaSmart site, I'm trying to get my server working the way I want it to.24/7 site (make sure you have noscript, sorry!): 24/7 [u]WARNING: MUST have NoScript so you can block quantserve/quantcast![/u] If you don't, the evil freewebs/webs/quantcast/quantserve/WHATEVER virus will get you![spoiler]Hey, look! It's a spoiler![/spoiler]Software: KeyPress, Advanced Calculator (not autoit), WUK (Windows Update Killer)my account over a year old : >... I do Linux.

Share this post


Link to post
Share on other sites

Send(GUICtrlRead($Edit1))

That works but then if I type something else than 'Text to type.' in the dialog then it don't work.

[s]Visit My Website[/s] (this isn't up 24/7). (SITE DOWN) This is now a HP MediaSmart site, I'm trying to get my server working the way I want it to.24/7 site (make sure you have noscript, sorry!): 24/7 [u]WARNING: MUST have NoScript so you can block quantserve/quantcast![/u] If you don't, the evil freewebs/webs/quantcast/quantserve/WHATEVER virus will get you![spoiler]Hey, look! It's a spoiler![/spoiler]Software: KeyPress, Advanced Calculator (not autoit), WUK (Windows Update Killer)my account over a year old : >... I do Linux.

Share this post


Link to post
Share on other sites

That works but then if I type something else than 'Text to type.' in the dialog then it don't work.

It will when implemented correcty. Have you tried to understand and debug your script?

You need to show what you have before we can check why it doesn;t work as you expect.


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

It will when implemented correcty. Have you tried to understand and debug your script?

You need to show what you have before we can check why it doesn;t work as you expect.

I updated the source code on the first post.

[s]Visit My Website[/s] (this isn't up 24/7). (SITE DOWN) This is now a HP MediaSmart site, I'm trying to get my server working the way I want it to.24/7 site (make sure you have noscript, sorry!): 24/7 [u]WARNING: MUST have NoScript so you can block quantserve/quantcast![/u] If you don't, the evil freewebs/webs/quantcast/quantserve/WHATEVER virus will get you![spoiler]Hey, look! It's a spoiler![/spoiler]Software: KeyPress, Advanced Calculator (not autoit), WUK (Windows Update Killer)my account over a year old : >... I do Linux.

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Does this work like you want?

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$Form1_1 = GUICreate("KeyPress v1.1", 633, 447, 192, 124)
$Edit1 = GUICtrlCreateEdit("", 8, 8, 329, 129)
GUICtrlCreateLabel("RacecarSoft KeyPress v1.1" & @CRLF & "Build Date: 2008/12/14", 352, 8, 268, 25)
$OK = GUICtrlCreateButton("OK", 576, 408, 41, 25, 0)
$Exit = GUICtrlCreateButton("Exit", 528, 408, 41, 25, 0)

GUICtrlSetData( $Edit1 , "Text to type." )
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $OK
            $Edit1 = GuiCtrlRead( $Edit1 )
            ConsoleWrite( "$Edit1: " & $Edit1 & @crlf )
        Case $Exit
            Exit
    EndSwitch
WEnd
Edited by jaberwocky6669

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

Does this work like you want?

I was trying to get the OP to think about it and figure it out....

anyways: Your version will only work one time as you screw up the Edit control handle when Ok is pressed.

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

this is wrong:

$Edit1 = GUICtrlCreateEdit("", 8, 8, 329, 129)
$Edit1 = GUICtrlSetData(-1, $foo)
Put $foo where $Edit1 is?

[s]Visit My Website[/s] (this isn't up 24/7). (SITE DOWN) This is now a HP MediaSmart site, I'm trying to get my server working the way I want it to.24/7 site (make sure you have noscript, sorry!): 24/7 [u]WARNING: MUST have NoScript so you can block quantserve/quantcast![/u] If you don't, the evil freewebs/webs/quantcast/quantserve/WHATEVER virus will get you![spoiler]Hey, look! It's a spoiler![/spoiler]Software: KeyPress, Advanced Calculator (not autoit), WUK (Windows Update Killer)my account over a year old : >... I do Linux.

Share this post


Link to post
Share on other sites

Put $foo where $Edit1 is?

Nope. The variable $Edit1 contains the Handle to the Edit control. what happens when you perform GUICtrlSetData() ?

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I was trying to get the OP to think about it and figure it out....

anyways: Your version will only work one time as you screw up the Edit control handle when Ok is pressed.

Sorry! Thanks for letting me know about the bug in my code! I'm new to programming.

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

Nope. The variable $Edit1 contains the Handle to the Edit control. what happens when you perform GUICtrlSetData() ?

Not enough parameters error.

If I put "Text to type" in between those I get the same also.

Edited by RacecarSoft

[s]Visit My Website[/s] (this isn't up 24/7). (SITE DOWN) This is now a HP MediaSmart site, I'm trying to get my server working the way I want it to.24/7 site (make sure you have noscript, sorry!): 24/7 [u]WARNING: MUST have NoScript so you can block quantserve/quantcast![/u] If you don't, the evil freewebs/webs/quantcast/quantserve/WHATEVER virus will get you![spoiler]Hey, look! It's a spoiler![/spoiler]Software: KeyPress, Advanced Calculator (not autoit), WUK (Windows Update Killer)my account over a year old : >... I do Linux.

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