Jump to content

GUICtrlSetData Problem.


LokErik
 Share

Recommended Posts

Hi i need help to my script.

I Whant to read the text file from a FileOpenDialog, so the Text (inside) of *.txt Will be Shown In

GuiCtrlSetData.

I have tryed alot of diffrents things but no succeed.

I appreciate a little help :)

Thanks

The first error is one step closer to the perfect program.

Link to comment
Share on other sites

  • Moderators

Hi i need help to my script.

I Whant to read the text file from a FileOpenDialog, so the Text (inside) of *.txt Will be Shown In

GuiCtrlSetData.

I have tryed alot of diffrents things but no succeed.

I appreciate a little help :)

Thanks

ControlGetText

If that doesn't help, then you need to be much more specific on what app is producing the dialog, and how we can test it ourselves. (In other words... Where's the code?)

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

CODE
#include <GUIConstants.au3>

#include <string.au3>

#Include <File.au3>

#Include <Array.au3>

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

$Form1 = GUICreate("Kryptera", 274, 480, 193, 125)

$EditText = GUICtrlCreateEdit("", 0, 0, 273, 400)

$filemenu = GUICtrlCreateMenu ("&File")

$fileitem = GUICtrlCreateMenuitem ("Open",$filemenu)

$recentfilesmenu = GUICtrlCreateMenu ("Recent Files",$filemenu,1)

$Image1 = @ScriptDir & "\lock.ico"

$Image2 = @ScriptDir & "\unlock.ico"

$Button1 = GUICtrlCreateButton("Kyrptera", 15, 414, 28, 36, $BS_BITMAP)

GUICtrlSetImage ($Button1, $Image1,0, 4)

$Button2 = GUICtrlCreateButton("Dekrryptera", 220, 414, 28, 36, 0x0080)

GUICtrlSetImage ($Button2, $Image2, 0)

$pass = GUICtrlCreateInput("", 80, 428, 70, 19, 0x0020)

GUICtrlCreateLabel("Password", 80, 410, 70, 13, 0)

$Lvl = GUICtrlCreateInput("", 180, 428, 20, 19, 0x2001)

GUICtrlCreateLabel("KOD 1-9", 170, 410, 45, 13, 0)

GUISetState(@SW_SHOW)

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

Do

$nMsg = GUIGetMsg()

If $nMsg = $fileitem Then

$file = FileOpenDialog("Open File", "", "Text Fil (*.txt)")

;HERE IS THAT THE HELP IS NEEDED

If @error <> 1 Then GUICtrlCreateMenuitem ($file,$recentfilesmenu)

EndIf

If $nMsg = $Button1 Then ;krypterar

GuiSetState(@SW_DISABLE,$Form1) ; så du inte kan göra några ändringar

$string = GuiCtrlRead($EditText) ; Läser senare av

GuiCtrlSetData($EditText, "Krypterar")

Sleep(700)

GuiCtrlSetData($EditText, _StringEncrypt(1, $string, GUICtrlRead($pass), GUICtrlRead($Lvl))) ; Skriver det krypterade medelandet

GuiSetState(@SW_ENABLE,$Form1) ; låser upp gui för nyare medelanden

ElseIf $nMsg = $Button2 Then ; dekrypterar

GuiSetState(@SW_DISABLE,$Form1) ; så du inte kan göra några ändringar

$string = GuiCtrlRead($EditText) ; Läser senare av

GuiCtrlSetData($EditText, "Dekrypterar")

Sleep(700)

GuiCtrlSetData($EditText, _StringEncrypt(0, $string, GUICtrlRead($pass), GUICtrlRead($Lvl))) ;Skriver det dekrypterade medelandet

GuiSetState(@SW_ENABLE,$Form1) ; låser upp gui för nyare medelanden

EndIf

Until $nMsg = $GUI_EVENT_CLOSE

I have marked where i need help with ;HERE IS THAT THE HELP IS NEEDED . Right after Do begin.

I hope its easy. :)

Edited by LokErik

The first error is one step closer to the perfect program.

Link to comment
Share on other sites

  • Moderators

CODE
#include <GUIConstants.au3>

#include <string.au3>

#Include <File.au3>

#Include <Array.au3>

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

$Form1 = GUICreate("Kryptera", 274, 480, 193, 125)

$EditText = GUICtrlCreateEdit("", 0, 0, 273, 400)

$filemenu = GUICtrlCreateMenu ("&File")

$fileitem = GUICtrlCreateMenuitem ("Open",$filemenu)

$recentfilesmenu = GUICtrlCreateMenu ("Recent Files",$filemenu,1)

$Image1 = @ScriptDir & "\lock.ico"

$Image2 = @ScriptDir & "\unlock.ico"

$Button1 = GUICtrlCreateButton("Kyrptera", 15, 414, 28, 36, $BS_BITMAP)

GUICtrlSetImage ($Button1, $Image1,0, 4)

$Button2 = GUICtrlCreateButton("Dekrryptera", 220, 414, 28, 36, 0x0080)

GUICtrlSetImage ($Button2, $Image2, 0)

$pass = GUICtrlCreateInput("", 80, 428, 70, 19, 0x0020)

GUICtrlCreateLabel("Password", 80, 410, 70, 13, 0)

$Lvl = GUICtrlCreateInput("", 180, 428, 20, 19, 0x2001)

GUICtrlCreateLabel("KOD 1-9", 170, 410, 45, 13, 0)

GUISetState(@SW_SHOW)

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

Do

$nMsg = GUIGetMsg()

If $nMsg = $fileitem Then

$file = FileOpenDialog("Open File", "", "Text Fil (*.txt)")

;HERE IS THAT THE HELP IS NEEDED

If @error <> 1 Then GUICtrlCreateMenuitem ($file,$recentfilesmenu)

EndIf

If $nMsg = $Button1 Then ;krypterar

GuiSetState(@SW_DISABLE,$Form1) ; så du inte kan göra några ändringar

$string = GuiCtrlRead($EditText) ; Läser senare av

GuiCtrlSetData($EditText, "Krypterar")

Sleep(700)

GuiCtrlSetData($EditText, _StringEncrypt(1, $string, GUICtrlRead($pass), GUICtrlRead($Lvl))) ; Skriver det krypterade medelandet

GuiSetState(@SW_ENABLE,$Form1) ; låser upp gui för nyare medelanden

ElseIf $nMsg = $Button2 Then ; dekrypterar

GuiSetState(@SW_DISABLE,$Form1) ; så du inte kan göra några ändringar

$string = GuiCtrlRead($EditText) ; Läser senare av

GuiCtrlSetData($EditText, "Dekrypterar")

Sleep(700)

GuiCtrlSetData($EditText, _StringEncrypt(0, $string, GUICtrlRead($pass), GUICtrlRead($Lvl))) ;Skriver det dekrypterade medelandet

GuiSetState(@SW_ENABLE,$Form1) ; låser upp gui för nyare medelanden

EndIf

Until $nMsg = $GUI_EVENT_CLOSE

I have marked where i need help with ;HERE IS THAT THE HELP IS NEEDED . Right after Do begin.

I hope its easy. :)

I was under the assumption that you were using another application, but using FileOpenDialog, you must understand that nothing goes past that point until you click OK/Cancel (It works kind of like a message box where none of the commands below it are received until it is finished).

If you are only wanting specific extensions, $file holds the path of the file selected, when done, then just use _PathSplit and the extension option there.

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

Ok I have solve my problem Thanks for the Info SmOke_N

I add this code and now it works good.

CODE
$file = FileOpenDialog("Öppna Text", "", "Text Fil (*.txt)")

Dim $szDrive, $szDir, $szFName, $szExt

SplashImageOn("", @ScriptDir & "\bild\laddar bild.jpg", 274, 480, 193, 125) ; Gör en Bild, som täcker Notepad iaf andra gången.

$TestPath = _PathSplit($file, $szDrive, $szDir, $szFName, $szExt) ; för att kunna ta ut bara just filnamnet

ShellExecute($file) ; öppnar fileopendialog txt filen

Sleep(400)

WinMove($szFName & " - Anteckningar","", 193, 125, 270, 480) ;flyttar notpad under Bilden

Sleep(1000)

$var = ControlGetText($szFName & " - Anteckningar", "", "Edit1") ; Läser av den öppnade notepad filen

GUICtrlSetData($EditText, $var) ;skriver den i Guiedit:en

Sleep(200)

WinKill($szFName & " - Anteckningar", "") ; stänger Notepad

SplashOff() ; Här avslutas bilden.

I think you understand maby some mess but the thing is that it´s going :)

You can lock the topic now

And Thanks! :)

The first error is one step closer to the perfect program.

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