Jump to content

Waiting Till Key Is Typed And Making Buttons


 Share

Recommended Posts

Hello,

1)i use this program now for some months

No do i want an simp[le script that wait till a key is pressed.

Like the q

Then i must do something

like type hello ore something ore open aprogram.

How can i do that?

Can someone give me i little script whit an few lines in it that waits till a key is pressed?

i do not want one key i think i need 5 keys ore someonthing whit each other function.

Can someone help me please?

2)

my second question is how can i make an window whit some buttons in it whit each other fnction?

When i open a program what i made i see rightdown an icon i used when i compiled it.

There do i have some functions like close and fause script.

How can i make some functions more link about ore something?

Greets Erik

I little problem, hard to find and fix

Link to comment
Share on other sites

maybe this will help you for starting :think:

#include <GUIConstants.au3>

HotKeySet("q","Message")

$main=GUICreate("Wait for Key",100,100,-1,-1)

$Label1=GUICtrlCreateLabel("Press q for action",10,80)

$button1=GUICtrlCreateButton("Click me",10,10)

GUICtrlSetState($button1,$GUI_HIDE);Hide button until user press "q"

GuiSetState()

While 1;==>Start gui

$msg = GuiGetMsg()

Select

Case $msg=$button1

MsgBox(0,"Test","User click button")

GUICtrlSetState($button1,$GUI_HIDE)

Case $msg = $GUI_EVENT_CLOSE

Exit

EndSelect

WEnd

Func Message()

MsgBox(0,"Test","Message")

GUICtrlSetState($button1,$GUI_SHOW)

EndFunc

Link to comment
Share on other sites

Well there is this one thing you could do called read the help-file

The below statement is False.The above statement is True.a lesson I learned from Greenmachine; give a man a code and he'll solve one problem. Teach a man to code and he'll solve all his problems.P.S please don't use autoIt as a virus creator/spyware maker(keyLogger especially)Cick this and help me[center]My Scripts:[/center][center]Port Scanner[/center]

Link to comment
Share on other sites

Hello.

Thanks for posting.

I already read the manual.

When i do this:

HotKeySet("q","Message")]

I got an error:ERROR: Message(): undefined function.

When i do all the script in my autoit i got this:

WARNING: $GUI_HIDE: possibly used before declaration.

WARNING: $GUI_EVENT_CLOSE: possibly used before declaration.

WARNING: $GUI_SHOW: possibly used before declaration.

ERROR: $GUI_HIDE: undeclared global variable.

I little problem, hard to find and fix

Link to comment
Share on other sites

  • Moderators

Question #1

You have to make a function called Message():

HotKeySet('q', 'Message')

While 1
    Sleep(1000)
WEnd

Func Message()
    MsgBox(64, 'Info:', 'You pressed the "q" key')
EndFunc
The help file shows this under HotKeySet

Question #2

When using variables, you must be sure that the variable is defined: $GUI_HIDE etc... are in the #include folder "GUIConstants.au3" which is located in your AutoIt folder in the ProgramFiles Directory.

#include <GUICONSTANTS.AU3>

;START OF GUI SCRIPT
You can read more about how to use that under #include in the help file.

Edit:

Typo

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

Thenks man.

Thanks works good.

Now i want to do that whit 5 buttons like 1,2,3,4,5

every numbver has his own function.

Now how to do that ?

The script is made for 1 number not for more so....

Should if work?

Thanks for the help!!

I little problem, hard to find and fix

Link to comment
Share on other sites

Someone?

Now you made a script for one key thats the q

Now how to made a script that waits till some omre jeys are pressed?

I would like to to this:

When i press q i get hello

When i press a i get byebye

Ect...

how to do that?

When i copy and paste something i won't work so...

I little problem, hard to find and fix

Link to comment
Share on other sites

STRAIGHT FROM HELP

#include <GUIConstants.au3>

GUICreate("My GUI Button"); will create a dialog box that when displayed is centered

Opt("GUICoordMode",2)
$Button_1 = GUICtrlCreateButton ("Run Notepad",  10, 30, 100)
$Button_2 = GUICtrlCreateButton ( "Button Test",  0, -1)

GUISetState ()   ; will display an  dialog box with 2 button

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Button_1
            Run('Notepad.exe')   ; Will Run/Open Notepad
        Case $msg = $Button_2
            MsgBox(0, 'Testing', 'Button 2 was pressed')   ; Will demonstrate Button 2 being pressed
    EndSelect
Wend

8)

NEWHeader1.png

Link to comment
Share on other sites

  • Moderators

Study the code and figure it out, read the help file under guictrlcreatebutton, find the AutoIt 123 tutorial... Every question you've asked is in the help file.

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