Sign in to follow this  
Followers 0
Hello Me You

Can you help me make a script?

17 posts in this topic

#1 ·  Posted (edited)

Help me make a script

I want to help me make a script that has:

Small window size

Input box

And sending keys

More Info:
The window will has some input boxes (around 2-3). You type something in the input boxes, then you click "OK" button.
It will wait for a window to open (e.g. notepad) and type/send (e.g. in notepad) the text that you have insert in the input box.

I hope you understand because my English is not very good.

Edited by Hello Me You

Random

Share this post


Link to post
Share on other sites



Pretty easy to do, I got it I guess.. I will try to get the finished product in soon.


[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Share this post


Link to post
Share on other sites

I think this should work.. here's the code:

#include <GUIConstants.au3>

GUICreate("What should the title be?", 200, 200)
GUISetState(@SW_SHOW)
$box1 = GUICtrlCreateInput("", 50, 50, 100, 100)
$button = GUICtrlCreateButton("OK", 50, 170, 100, 10)

While 1
    $msg = GUIGetMsg()
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
        Exit
        
    Case $msg = $button
        Run("notepad.exe")
        $send1 = GUICtrlRead($box1)
        Send($send1)
EndSelect   
WEnd

[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Share this post


Link to post
Share on other sites

This is actually going to employ several different things. Research the following in the help manual:

For the Input Window

GUICreate

GUICtrlCreateButton

GUICtrlCreateInput

check the example folder for a good example of GUI creation

For NotePad Open

There are two method to use. You can either have the user see what is being typed or I recommend just doing a "stealth" method (it's better).

Run (the first method)

or

FileOpen (the second/"stealth" method)

For Writing to Notepad

ControlSend (the first method)

or

(the following four are for the second/"stealth" method)

FileWrite

GUICtrlRead

FileClose

NOTE: "Stealth" is misnomer and is only used to convey an operation in context of notepad. Please research through the manual to understand the usage of the listed items I've given.


A decision is a powerful thing

Share this post


Link to post
Share on other sites

I recommend not using send. Just my recommendation :whistle: It's a little to broad and can get you into trouble :)


A decision is a powerful thing

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I think this should work.. here's the code:

#include <GUIConstants.au3>

GUICreate("What should the title be?", 200, 200)
GUISetState(@SW_SHOW)
$box1 = GUICtrlCreateInput("", 50, 50, 100, 100)
$button = GUICtrlCreateButton("OK", 50, 170, 100, 10)

While 1
    $msg = GUIGetMsg()
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
        Exit
        
    Case $msg = $button
        Run("notepad.exe")
        $send1 = GUICtrlRead($box1)
        Send($send1)
EndSelect   
WEnd
i need and something else, r u online?

for example, after it reads the text that you have typed, i want to open notepad BUT say: You have typed "box1"

Edited by Hello Me You

Random

Share this post


Link to post
Share on other sites

I think this should work.. here's the code:

#include <GUIConstants.au3>

GUICreate("What should the title be?", 200, 200)
GUISetState(@SW_SHOW)
$box1 = GUICtrlCreateInput("", 50, 50, 100, 100)
$button = GUICtrlCreateButton("OK", 50, 170, 100, 10)

While 1
    $msg = GUIGetMsg()
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
        Exit
        
    Case $msg = $button
        Run("notepad.exe")
        $send1 = GUICtrlRead($box1)
        Send($send1)
EndSelect   
WEnd
Doesn't even open or run :whistle:

Share this post


Link to post
Share on other sites

i need and something else

for example, after it reads the text that you have typed, i want to open notepad BUT say: You have typed "box1"


Random

Share this post


Link to post
Share on other sites

Doesn't even open or run :whistle:

What does not open or run? The sample basically works (have you tried it)?

There is only a minor problem, which can be solved with WinWaitActive(),


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

i need and something else

for example, after it reads the text that you have typed, i want to open notepad BUT say: You have typed "box1"

well, then type "box1" into the input field and press the button !!


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

i need and something else

for example, after it reads the text that you have typed, i want to open notepad BUT say: You have typed "box1"

This is pitiful, you've been on this forum for over 6 months, and there are people really trying to learn to do something that have only been on the forum for days or hours, and here you are trying to get someone to do the work for you. I'd suggest no one helping this person, until they put forth their own effort.

Before you say you don't know how... There's a help file with plenty GUI information in it, and each one of those function comes with an example. On top of that, lookfar and lazycat have taken several hours out of their time to make a GUI creator for you that is provided in the Tools option of the SciTe editor. The fact that you've not posted any code, and or even attempted to do anything is an insult to everyone on this board.


[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

well, then type "box1" into the input field and press the button !!

are you kidddddding me? i am not so stupid. i mean to send:

You have typed: and the text that you entered


Random

Share this post


Link to post
Share on other sites

are you kidddddding me? i am not so stupid. i mean to send:

You have typed: and the text that you entered

?? Whats going on here? "Hello Me You" should be very grateful to have recieved any help, I've seen many more posts where the person gets chewed up for requesting a script. Plus very nice people like sandman did what you wanted, and its still not good enough? Then you practically insult /dev/null? I can't believe I'm going to do this, and I dont' even know what you want, but try this....

#include <GUIConstants.au3>

GUICreate("What should the title be?", 200, 200)
GUISetState(@SW_SHOW)
$box1 = GUICtrlCreateInput("", 50, 50, 100, 100)
$button = GUICtrlCreateButton("OK", 50, 170, 100, 10)

While 1
    $msg = GUIGetMsg()
   
    Select
        Case $msg = $GUI_EVENT_CLOSE
        Exit
       
    Case $msg = $button
        $send1 = GUICtrlRead($box1)
        MsgBox(0,"", $send1)
EndSelect   
WEnd

If thats not what you want take SmOke_N's suggestion and just read the helpfile.


While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Okay, tested this out and it works fine.

#include <GUIConstants.au3>

GUICreate("What should the title be?", 200, 200)
GUISetState(@SW_SHOW)
$box1 = GUICtrlCreateInput("", 50, 50, 100, 100)
$button = GUICtrlCreateButton("OK", 50, 170, 100, 10)

While 1
    $msg = GUIGetMsg()
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
        Exit
        
    Case $msg = $button
        Run("notepad.exe")
        $send1 = GUICtrlRead($box1)
        Sleep(1000)
        Send("You have typed " & $send1 & "!")
EndSelect   
WEnd

Notice what I have changed? I added a sleep() function to let Notepad load, and then had the script send it.

Edited by sandman

[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>

;Create the GUI window
GUICreate("What should the title be?", 200, 200)

;Create Input Box
$Box1 = GUICtrlCreateInput("", 50, 50, 100, 100)

;Create Button OK
$Button = GUICtrlCreateButton("OK", 50, 170, 100, 20)

;Show the GUI
GUISetState()

While 1
    ;Get msg ID
    $Msg = GUIGetMsg()
    
    Select
        ;If window was closed....
        Case $Msg = $GUI_EVENT_CLOSE
            Exit
        ;If Button OK was pressed
        Case $Msg = $Button
            ;If the Input Box is empty, show Message and continue the loop that it not run the notepad
            If GUICtrlRead($Box1) = "" Then
                MsgBox(48, "Error", "Type somthing in the Box ;) ")
                ContinueLoop
            EndIf
            ;Run Notepad
            Run("notepad.exe")
            ;Get text from Input Box
            $ReadBox1 = GUICtrlRead($Box1)
            ;Set Autoit option to mode that allow to get title by part of known title
            Opt("WinTitleMatchMode", 2)
            ;Get the notepad title
            $NotepadTitle = WinGetTitle("Notepad", "")
            ;Wait (10 seconds) for window of notepad
            WinWait($NotepadTitle, "", 10)
            ;Set needed text in Scintilla (Edit) of notepad
            ControlSetText($NotepadTitle, "", "Scintilla1", "You have typed <" & $ReadBox1 & ">")
    EndSelect   
WEnd

Follow after comments (lines with ; at the begining), and read the help file, in the begining, it is wery important to read more - don't expect that we do all for you, in the end, you must, and you will learn how to do things by your self.

Cheers. :whistle:


Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

Simple version...

#include <GUIConstants.au3>

GUICreate("What should the title be?", 200, 200)
GUISetState(@SW_SHOW)
$box1 = GUICtrlCreateEdit("For small inputs change it to GuiCtrlCreateInput, this is multiline version :P.", 50, 50, 100, 100)
$button = GUICtrlCreateButton("OK", 50, 170, 100, 40)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
        Exit
    Case $msg = $button
        GuiSetState(@SW_HIDE)
        Run("notepad.exe")
        $send1 = GUICtrlRead($box1)
        $send1 = "You are typed: " & $send1 & "!"
        FileWrite(@ScriptDir & "\youtyped.txt",$send1)
        ShellExecute(@ScriptDir & "\youtyped.txt")
        If MsgBox(36,"Question","Want to delete file?") = 6 then FileDelete(@ScriptDir & "\youtyped.txt")
        GuiSetState(@SW_SHOW)
EndSelect   
WEnd

It saves text in file youtyped.txt and it opens it. Later you can change it's name and save it as normal file. (As MsCreatoR says:

You must type something :whistle:

).

Edit:

I want to be mass spammer.

Moderators, you don't want to see that.

Edit2: Why just don't put spoiler?

Edited by i542

I can do signature me.

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