Jump to content

need a little a help


Wollf
 Share

Recommended Posts

Hello i am very new to autoit and i need help for a small script i made the interface and it has 3 buttons and 1 input space.i need to know how to make it work i want when open it write something at the input space then when i press first button that text will be written and saved at the same place the au3 file is. then if i press the second button the txt file will be deleted and if i press the third button the script will close. but i need help and dont know how to make it work.

Link to comment
Share on other sites

Hello i am very new to autoit and i need help for a small script i made the interface and it has 3 buttons and 1 input space.i need to know how to make it work i want when open it write something at the input space then when i press first button that text will be written and saved at the same place the au3 file is. then if i press the second button the txt file will be deleted and if i press the third button the script will close. but i need help and dont know how to make it work.

Hi,

blablabla :) all functions are in help file but I give you simple example

GuiCreate("",250,35)
GuiCtrlCreateButton("Button",5,5,240,25);simple gui
GuiCtrlSetOnEvent(-1,"_Button");event button to function
GuiSetState();show gui

Func _Button()
Msgbox(64,"","hello!")
Filewrite("test.txt","christmas time - firefox");write in a file
Run(@SystemDir&"\notepad.exe"); run notepad
sleep(2000)
Send("something");simulate send keys by user
EndFunc

While 1;script loop
Sleep(250)
WEnd
Link to comment
Share on other sites

thanks for help i first want to make the button do a function when i press it using select case and cant make it work yet

in the place with bold letter i dont know what exactly i should write to work

i am sure its a a small stupid mistake .

help file helps sometimes but cant find something similar with buttons

i write

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("Notepad", 633, 447, 193, 125)

$1 = GUICtrlCreateButton("Create txt file", 36, 44, 105, 25, 0)

$2 = GUICtrlCreateButton("Exit", 36, 140, 105, 25, 0)

$Input1 = GUICtrlCreateInput("Write text for notepad", 160, 44, 241, 21)

$Pic1 = GUICtrlCreatePic("np.jpg", 168, 92, 100, 100)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###\

Select

case $1 = $1

Run("notepad")

case $2 = $2

Exit

EndSelect

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

WEnd

sry to bother u again

Edited by Wollf
Link to comment
Share on other sites

Link to comment
Share on other sites

Place your Case statements in the main message loop (aka in the While 1 loop). Also change it to Case $1 and not Case $1 = $1.

only the statements $1 and $2

and where exactly i put these statements between while 1 and $nmsg ?

Link to comment
Share on other sites

As far as im concerned, i don't like case statement in loop; you can use GuiCtrlSetOnEvent for every controls

ah yes i tried that now with function but still when i press button doesnt do anything

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("Notepad", 633, 447, 193, 125)

$1 = GUICtrlCreateButton("Create txt file", 36, 44, 105, 25, 0)

GUICtrlSetOnEvent(-1, "createtxtfile")

$Input1 = GUICtrlCreateInput("Write text for notepad", 160, 44, 241, 21)

$Pic1 = GUICtrlCreatePic("np.jpg", 168, 92, 100, 100)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###\

Func createtxtfile()

run("notepad")

EndFunc

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

WEnd

Link to comment
Share on other sites

ah yes i tried that now with function but still when i press button doesnt do anything

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("Notepad", 633, 447, 193, 125)

$1 = GUICtrlCreateButton("Create txt file", 36, 44, 105, 25, 0)

GUICtrlSetOnEvent(-1, "createtxtfile")

$Input1 = GUICtrlCreateInput("Write text for notepad", 160, 44, 241, 21)

$Pic1 = GUICtrlCreatePic("np.jpg", 168, 92, 100, 100)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###\

Func createtxtfile()

run("notepad")

EndFunc

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

WEnd

At the top of your script,with includes, add Opt("GuiSetOnEventMode",1)

Link to comment
Share on other sites

At the top of your script,with includes, add Opt("GuiSetOnEventMode",1)

Thanks very much i at last understand how make buttons work thank you very much. One last think i need is how ti make it save the file in the same destination as the au3 file is because at different computer hard disc has different name, and save screen it saves file at the last place they saved something.

Func createtxtfile()

WinWaitActive("Notepad")

send("{TAB 3}")

WinWaitActive("Notepad")

send("^c")

WinWaitActive("Notepad")

run("notepad")

WinWaitActive("Χωρίς τίτλο - Σημειωματάριο")

send("^v")

WinWaitActive("Χωρίς τίτλο - Σημειωματάριο")

send("^s")

WinWaitActive("Αποθήκευση ως")

send("windownotepad.txt")

WinWaitActive("Αποθήκευση ως")

send("{TAB 2}")

WinWaitActive("Αποθήκευση ως")

send("{Enter}")

WinWaitActive("windownotepad.txt")

winclose("windownotepad.txt")

EndFunc

Link to comment
Share on other sites

Filewrite(@ScriptDir&"\text.txt,"test")
at code where you write the text how can i change it to become ctrl-v?

i have ^c from input type but when i use filewrite for text "^v" it doesnt paste anything just write ^v at txt file instead of paste

sorry to bother u again

Link to comment
Share on other sites

at code where you write the text how can i change it to become ctrl-v?

i have ^c from input type but when i use filewrite for text "^v" it doesnt paste anything just write ^v at txt file instead of paste

sorry to bother u again

No problem,

use clipboard functions

if you want to paste something its better to use ClipGet

FileWrite(@ScriptDir&"\test.txt",ClipGet())
Edited by FireFox
Link to comment
Share on other sites

because example at help file isnt very clear where i exactly i putclip get and clipput.

i use 3 tabs to move to the input and there a i need to copy the text and write it to txt file

Func createtxtfile()

WinWaitActive("Notepad")

send("{TAB 3}")

WinWaitActive("Notepad")

send("^c")

FileOpen(@ScriptDir"exeb.txt", 1)

filewrite("exeb.txt", "^v")

fileclose("exeb.txt")

EndFunc

Link to comment
Share on other sites

Func createtxtfile()
    WinWaitActive("Notepad")
    send("{TAB 3}")
    WinWaitActive("Notepad")
    send("^a")
    send("^c")
    FileOpen(@ScriptDir&"\exeb.txt", 1)
    filewrite("exeb.txt", ClipGet())
    fileclose("exeb.txt")
EndFunc

Edit : you don't have to fileopen and file close just for filewrite :)

Edited by FireFox
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...