Wollf Posted December 2, 2008 Share Posted December 2, 2008 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 More sharing options...
youknowwho4eva Posted December 2, 2008 Share Posted December 2, 2008 Sounds like first you need to do the tutorials in the help file. then look at Filewrite, @scriptdir, filedelete. Giggity Link to comment Share on other sites More sharing options...
FireFox Posted December 2, 2008 Share Posted December 2, 2008 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 More sharing options...
Wollf Posted December 3, 2008 Author Share Posted December 3, 2008 (edited) 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 yetin the place with bold letter i dont know what exactly i should write to worki am sure its a a small stupid mistake .help file helps sometimes but cant find something similar with buttonsi 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 ###\Selectcase $1 = $1 Run("notepad")case $2 = $2 Exit EndSelectWhile 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitchWEndsry to bother u again Edited December 3, 2008 by Wollf Link to comment Share on other sites More sharing options...
dbzfanatic Posted December 3, 2008 Share Posted December 3, 2008 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. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
Wollf Posted December 3, 2008 Author Share Posted December 3, 2008 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 $2and where exactly i put these statements between while 1 and $nmsg ? Link to comment Share on other sites More sharing options...
FireFox Posted December 3, 2008 Share Posted December 3, 2008 only the statements $1 and $2and where exactly i put these statements between while 1 and $nmsg ?As far as im concerned, i don't like case statement in loop; you can use GuiCtrlSetOnEvent for every controls Link to comment Share on other sites More sharing options...
Wollf Posted December 3, 2008 Author Share Posted December 3, 2008 As far as im concerned, i don't like case statement in loop; you can use GuiCtrlSetOnEvent for every controlsah 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 EndSwitchWEnd Link to comment Share on other sites More sharing options...
FireFox Posted December 3, 2008 Share Posted December 3, 2008 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 EndSwitchWEndAt the top of your script,with includes, add Opt("GuiSetOnEventMode",1) Link to comment Share on other sites More sharing options...
Wollf Posted December 3, 2008 Author Share Posted December 3, 2008 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 More sharing options...
FireFox Posted December 3, 2008 Share Posted December 3, 2008 Hi, for save in the au3 directory use : @ScriptDir Filewrite(@ScriptDir&"\text.txt,"test") Link to comment Share on other sites More sharing options...
Wollf Posted December 3, 2008 Author Share Posted December 3, 2008 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 More sharing options...
FireFox Posted December 3, 2008 Share Posted December 3, 2008 (edited) 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 againNo problem, use clipboard functions if you want to paste something its better to use ClipGet FileWrite(@ScriptDir&"\test.txt",ClipGet()) Edited December 3, 2008 by FireFox Link to comment Share on other sites More sharing options...
Wollf Posted December 3, 2008 Author Share Posted December 3, 2008 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 More sharing options...
FireFox Posted December 3, 2008 Share Posted December 3, 2008 (edited) 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 December 3, 2008 by FireFox Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now