Jump to content

2 questions


Wollf
 Share

Recommended Posts

hello i need ur help i made an exe and dont know what exactly i need to make it work correctly. this code down there has 36 inputs in 3 collums. when you write some names or phones it adds them to notepad the problem is i dont want to copy empty inputs and put spaces into notepad.How exactly i can make it to not count empty input boxes?

Also the second question i have is i made a checkbox and i want that checkbox when checked you dont need to write all third columm only the first input of third columm and in the notepad it will take the first input at all other inputs in third collum

thanks in advance

#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=f:\autoit3\koda\forms\form1.kxf
$Form1_1 = GUICreate("Form1", 633, 447, 193, 125, -1, 0)
$Label1 = GUICtrlCreateLabel("Name", 28, 16, 52, 29)
GUICtrlSetFont(-1, 16, 800, 2, "Monotype Corsiva")
$Label2 = GUICtrlCreateLabel("Phone", 204, 16, 55, 29)
GUICtrlSetFont(-1, 16, 800, 2, "Monotype Corsiva")
$Message = GUICtrlCreateLabel("Message", 360, 16, 74, 29)
GUICtrlSetFont(-1, 16, 800, 2, "Monotype Corsiva")
$Checkbox1 = GUICtrlCreateCheckbox("Check box so all have same messages will be same", 20, 396, 437, 29)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Input29 = GUICtrlCreateInput("", 160, 308, 149, 21)
$Input2 = GUICtrlCreateInput("", 160, 56, 149, 21)
$Input3 = GUICtrlCreateInput("", 320, 56, 149, 21)
$Input4 = GUICtrlCreateInput("", 0, 84, 149, 21)
$Input5 = GUICtrlCreateInput("", 160, 84, 149, 21)
$Input6 = GUICtrlCreateInput("", 320, 84, 149, 21)
$Input7 = GUICtrlCreateInput("", 0, 112, 149, 21)
$Input8 = GUICtrlCreateInput("", 160, 112, 149, 21)
$Input9 = GUICtrlCreateInput("", 320, 112, 149, 21)
$Input10 = GUICtrlCreateInput("", 0, 140, 149, 21)
$Input11 = GUICtrlCreateInput("", 160, 140, 149, 21)
$Input12 = GUICtrlCreateInput("", 320, 140, 149, 21)
$Input13 = GUICtrlCreateInput("", 0, 168, 149, 21)
$Input14 = GUICtrlCreateInput("", 160, 168, 149, 21)
$Input15 = GUICtrlCreateInput("", 320, 168, 149, 21)
$Input16 = GUICtrlCreateInput("", 0, 196, 149, 21)
$Input17 = GUICtrlCreateInput("", 160, 196, 149, 21)
$Input18 = GUICtrlCreateInput("", 320, 196, 149, 21)
$Input19 = GUICtrlCreateInput("", 0, 224, 149, 21)
$Input20 = GUICtrlCreateInput("", 160, 224, 149, 21)
$Input21 = GUICtrlCreateInput("", 320, 224, 149, 21)
$Input22 = GUICtrlCreateInput("", 0, 252, 149, 21)
$Input23 = GUICtrlCreateInput("", 160, 252, 149, 21)
$Input24 = GUICtrlCreateInput("", 320, 252, 149, 21)
$Input25 = GUICtrlCreateInput("", 0, 280, 149, 21)
$Input26 = GUICtrlCreateInput("", 160, 280, 149, 21)
$Input27 = GUICtrlCreateInput("", 320, 280, 149, 21)
$Input28 = GUICtrlCreateInput("", 0, 308, 149, 21)
$Input1 = GUICtrlCreateInput("", 0, 52, 149, 21)
$Input30 = GUICtrlCreateInput("", 320, 308, 149, 21)
$Input31 = GUICtrlCreateInput("", 0, 336, 149, 21)
$Input32 = GUICtrlCreateInput("", 160, 336, 149, 21)
$Input33 = GUICtrlCreateInput("", 320, 336, 149, 21)
$Input34 = GUICtrlCreateInput("", 0, 364, 149, 21)
$Input35 = GUICtrlCreateInput("", 160, 364, 149, 21)
$Input36 = GUICtrlCreateInput("", 320, 364, 149, 21)
$Button1 = GUICtrlCreateButton("Send info", 492, 56, 117, 53, 0)
GUICtrlSetOnEvent(-1, "Button1")

GUICtrlSetFont(-1, 14, 800, 2, "Monotype Corsiva")
GUICtrlSetCursor (-1, 0)

$Button2 = GUICtrlCreateButton("Exit", 492, 136, 113, 37, 0)
GUICtrlSetOnEvent(-1, "exit1")

GUICtrlSetFont(-1, 14, 800, 2, "Monotype Corsiva")
GUICtrlSetCursor (-1, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Func button1()
    ShellExecute("notepad.txt")
    WinWaitActive("C:\Documents and Settings\user\Επιφάνεια εργασίας\Tsagdis\Notepad.txt - Notepad++")
    Send(GUICtrlRead($Input1)&@TAB&GUICtrlRead($Input2)&@TAB&GUICtrlRead($Input3)&@CRLF)
    Send(GUICtrlRead($Input4)&@TAB&GUICtrlRead($Input5)&@TAB&GUICtrlRead($Input6)&@CRLF)
    Send(GUICtrlRead($Input7)&@TAB&GUICtrlRead($Input8)&@TAB&GUICtrlRead($Input9)&@CRLF)
    Send(GUICtrlRead($Input10)&@TAB&GUICtrlRead($Input11)&@TAB&GUICtrlRead($Input12)&@CRLF)
    Send(GUICtrlRead($Input13)&@TAB&GUICtrlRead($Input14)&@TAB&GUICtrlRead($Input15)&@CRLF)
    Send(GUICtrlRead($Input16)&@TAB&GUICtrlRead($Input17)&@TAB&GUICtrlRead($Input18)&@CRLF)
    Send(GUICtrlRead($Input19)&@TAB&GUICtrlRead($Input20)&@TAB&GUICtrlRead($Input21)&@CRLF)
    Send(GUICtrlRead($Input22)&@TAB&GUICtrlRead($Input23)&@TAB&GUICtrlRead($Input24)&@CRLF)
    Send(GUICtrlRead($Input25)&@TAB&GUICtrlRead($Input26)&@TAB&GUICtrlRead($Input27)&@CRLF)
    Send(GUICtrlRead($Input28)&@TAB&GUICtrlRead($Input29)&@TAB&GUICtrlRead($Input30)&@CRLF)
    Send(GUICtrlRead($Input31)&@TAB&GUICtrlRead($Input32)&@TAB&GUICtrlRead($Input33)&@CRLF)
    Send(GUICtrlRead($Input34)&@TAB&GUICtrlRead($Input35)&@TAB&GUICtrlRead($Input36)&@CRLF)
EndFunc

Func exit1()
    exit
    EndFunc






While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd
Link to comment
Share on other sites

i added that but inside the box there wasnt any text but it still said 2. dont know why that is happening also how i can put it to ignore some things like <2 and what is the code to ignore

$hi=StringLen($input1)

msgbox(1,"hwllo",$hi)

Link to comment
Share on other sites

i added that but inside the box there wasnt any text but it still said 2. dont know why that is happening also how i can put it to ignore some things like <2 and what is the code to ignore

$hi=StringLen($input1)

msgbox(1,"hwllo",$hi)

No, you need to evaluate the string length. Something like

if StringLen($input1)>2 then
msgbox(1,"hello",$input1)
endif

Try that example and see how you get on.

Link to comment
Share on other sites

i did that but with the code down doesnt seem to work if i choose >1 or >0 it still writes spaces in notepad and if i choose >2 it doesnt write nothing even if i write.

i tried to make a button with that comman $hi=StringLen($input1) msgbox(1,"hwllo",$hi) i wrote at every input and it still said it count 2 whats wrong here?

#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1) 
#Region ### START Koda GUI section ### Form=f:\autoit3\koda\forms\form1.kxf
$Form1_1 = GUICreate("SmS info adder", 633, 447, 193, 125, -1, 0)
$Label1 = GUICtrlCreateLabel("Name", 28, 16, 52, 29)
GUICtrlSetFont(-1, 16, 800, 2, "Monotype Corsiva")
$Label2 = GUICtrlCreateLabel("Phone", 204, 16, 55, 29)
GUICtrlSetFont(-1, 16, 800, 2, "Monotype Corsiva")
$Message = GUICtrlCreateLabel("Message", 360, 16, 74, 29)
GUICtrlSetFont(-1, 16, 800, 2, "Monotype Corsiva")
$Checkbox1 = GUICtrlCreateCheckbox("Check box so all have same messages will be same", 20, 396, 437, 29)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Input29 = GUICtrlCreateInput("", 160, 308, 149, 21)
$Input2 = GUICtrlCreateInput("", 160, 56, 149, 21)
$Input3 = GUICtrlCreateInput("", 320, 56, 149, 21)
$Input4 = GUICtrlCreateInput("", 0, 84, 149, 21)
$Input5 = GUICtrlCreateInput("", 160, 84, 149, 21)
$Input6 = GUICtrlCreateInput("", 320, 84, 149, 21)
$Input7 = GUICtrlCreateInput("", 0, 112, 149, 21)
$Input8 = GUICtrlCreateInput("", 160, 112, 149, 21)
$Input9 = GUICtrlCreateInput("", 320, 112, 149, 21)
$Input10 = GUICtrlCreateInput("", 0, 140, 149, 21)
$Input11 = GUICtrlCreateInput("", 160, 140, 149, 21)
$Input12 = GUICtrlCreateInput("", 320, 140, 149, 21)
$Input13 = GUICtrlCreateInput("", 0, 168, 149, 21)
$Input14 = GUICtrlCreateInput("", 160, 168, 149, 21)
$Input15 = GUICtrlCreateInput("", 320, 168, 149, 21)
$Input16 = GUICtrlCreateInput("", 0, 196, 149, 21)
$Input17 = GUICtrlCreateInput("", 160, 196, 149, 21)
$Input18 = GUICtrlCreateInput("", 320, 196, 149, 21)
$Input19 = GUICtrlCreateInput("", 0, 224, 149, 21)
$Input20 = GUICtrlCreateInput("", 160, 224, 149, 21)
$Input21 = GUICtrlCreateInput("", 320, 224, 149, 21)
$Input22 = GUICtrlCreateInput("", 0, 252, 149, 21)
$Input23 = GUICtrlCreateInput("", 160, 252, 149, 21)
$Input24 = GUICtrlCreateInput("", 320, 252, 149, 21)
$Input25 = GUICtrlCreateInput("", 0, 280, 149, 21)
$Input26 = GUICtrlCreateInput("", 160, 280, 149, 21)
$Input27 = GUICtrlCreateInput("", 320, 280, 149, 21)
$Input28 = GUICtrlCreateInput("", 0, 308, 149, 21)
$Input1 = GUICtrlCreateInput("", 0, 52, 149, 21)
$Input30 = GUICtrlCreateInput("", 320, 308, 149, 21)
$Input31 = GUICtrlCreateInput("", 0, 336, 149, 21)
$Input32 = GUICtrlCreateInput("", 160, 336, 149, 21)
$Input33 = GUICtrlCreateInput("", 320, 336, 149, 21)
$Input34 = GUICtrlCreateInput("", 0, 364, 149, 21)
$Input35 = GUICtrlCreateInput("", 160, 364, 149, 21)
$Input36 = GUICtrlCreateInput("", 320, 364, 149, 21)
$Button1 = GUICtrlCreateButton("Send info", 492, 56, 117, 53, 0)
GUICtrlSetOnEvent(-1, "Button1")

GUICtrlSetFont(-1, 14, 800, 2, "Monotype Corsiva")
GUICtrlSetCursor (-1, 0)

$Button2 = GUICtrlCreateButton("Exit", 492, 136, 113, 37, 0)
GUICtrlSetOnEvent(-1, "exit1")

GUICtrlSetFont(-1, 14, 800, 2, "Monotype Corsiva")
GUICtrlSetCursor (-1, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Func button1()
    ShellExecute("notepad.txt")
    WinWaitActive("C:\Documents and Settings\user\Επιφάνεια εργασίας\Tsagdis\Notepad.txt - Notepad++")
    If StringLen($Input1) > 2 Then
    Send(GUICtrlRead($Input1)&@TAB&GUICtrlRead($Input2)&@TAB&GUICtrlRead($Input3)&@CRLF)
EndIf
If StringLen($Input4) > 2 Then
    Send(GUICtrlRead($Input4)&@TAB&GUICtrlRead($Input5)&@TAB&GUICtrlRead($Input6)&@CRLF)
    EndIf
    If StringLen($Input7) > 2 Then
    Send(GUICtrlRead($Input7)&@TAB&GUICtrlRead($Input8)&@TAB&GUICtrlRead($Input9)&@CRLF)
    EndIf
    If StringLen($Input10) > 2 Then
    Send(GUICtrlRead($Input10)&@TAB&GUICtrlRead($Input11)&@TAB&GUICtrlRead($Input12)&@CRLF)
    EndIf
    If StringLen($Input13) > 2 Then
    Send(GUICtrlRead($Input13)&@TAB&GUICtrlRead($Input14)&@TAB&GUICtrlRead($Input15)&@CRLF)
    EndIf
    If StringLen($Input16) > 2 Then
    Send(GUICtrlRead($Input16)&@TAB&GUICtrlRead($Input17)&@TAB&GUICtrlRead($Input18)&@CRLF)
    EndIf
    If StringLen($Input19) > 2 Then
    Send(GUICtrlRead($Input19)&@TAB&GUICtrlRead($Input20)&@TAB&GUICtrlRead($Input21)&@CRLF)
    EndIf
    If StringLen($Input22) > 2 Then
    Send(GUICtrlRead($Input22)&@TAB&GUICtrlRead($Input23)&@TAB&GUICtrlRead($Input24)&@CRLF)
    EndIf
    If StringLen($Input25) > 2 Then
    Send(GUICtrlRead($Input25)&@TAB&GUICtrlRead($Input26)&@TAB&GUICtrlRead($Input27)&@CRLF)
    EndIf
    If StringLen($Input28) > 2 Then
    Send(GUICtrlRead($Input28)&@TAB&GUICtrlRead($Input29)&@TAB&GUICtrlRead($Input30)&@CRLF)
    EndIf
    If StringLen($Input31) > 2 Then
    Send(GUICtrlRead($Input31)&@TAB&GUICtrlRead($Input32)&@TAB&GUICtrlRead($Input33)&@CRLF)
    EndIf
    If StringLen($Input34) > 2 Then
    Send(GUICtrlRead($Input34)&@TAB&GUICtrlRead($Input35)&@TAB&GUICtrlRead($Input36)&@CRLF)
    EndIf
    
EndFunc

Func exit1()
    exit
    EndFunc
Edited by Wollf
Link to comment
Share on other sites

thanks it worked before it wasnt reading it and couldnt fouund any.

Also do anyone know how to make checkbox when checked to take only input 3 and paste it in all other third colum inputs?

example like this so you want need to write third colum inputs again and again?

mary 6798696 hello

george 34645645 hello

jim 4353454353 hello

Edited by Wollf
Link to comment
Share on other sites

Quick and dirty fix

Put this in you while loop:

$state = GUICtrlRead($Checkbox1)
    if $state = 1 Then
        $text = GUICtrlRead($input3)
        GUICtrlSetData($Input6,$text)
        GUICtrlSetData($Input9,$text)
        GUICtrlSetData($Input12,$text)
        GUICtrlSetData($Input15,$text)
        GUICtrlSetData($Input18,$text)
        GUICtrlSetData($Input21,$text)
        GUICtrlSetData($Input24,$text)
        GUICtrlSetData($Input27,$text)
        GUICtrlSetData($Input30,$text)
        GUICtrlSetData($Input33,$text)
        GUICtrlSetData($Input36,$text)
    ElseIf $state = 4 Then
        $text = ""
        GUICtrlSetData($Input6,$text)
        GUICtrlSetData($Input9,$text)
        GUICtrlSetData($Input12,$text)
        GUICtrlSetData($Input15,$text)
        GUICtrlSetData($Input18,$text)
        GUICtrlSetData($Input21,$text)
        GUICtrlSetData($Input24,$text)
        GUICtrlSetData($Input27,$text)
        GUICtrlSetData($Input30,$text)
        GUICtrlSetData($Input33,$text)
        GUICtrlSetData($Input36,$text)
    endif

Neo

[center][font="Arial"]--- The Neo and Only --- [/font][font="Arial"]--Projects---[/font]Image to Text converterText to ASCII converter[/center]

Link to comment
Share on other sites

thanks very much

1 more question

when i open notepad it has always the name of its location F:\portableapps\notepad++portable\sms.txt - Notepad++ but when i go at different computers the name changes F becomes H or E and winwaitactive doesnt work how can i change that?

and how i write altf4? i tried send ("!f4") but didnt work

Edited by Wollf
Link to comment
Share on other sites

oh just realized that with that checkbox code when box is checked or unchecked all the time i cant write anything at other input i can write only at input 3 doesnt let me write at input 6 or 9... ah ok i needed to delete the

GUICtrlSetData($Input6,$text)
 $text = ""
        GUICtrlSetData($Input9,$text)
        GUICtrlSetData($Input12,$text)
        GUICtrlSetData($Input15,$text)
        GUICtrlSetData($Input18,$text)
        GUICtrlSetData($Input21,$text)
        GUICtrlSetData($Input24,$text)
        GUICtrlSetData($Input27,$text)
        GUICtrlSetData($Input30,$text)
        GUICtrlSetData($Input33,$text)
        GUICtrlSetData($Input36,$text)
Edited by Wollf
Link to comment
Share on other sites

tried the

WinWaitActive(" - Notepad++")

didnt worked do you know if there is any other way? or is it possible for winwaitactive to find windows that have only 1 letter difference because the only prob is that F

Link to comment
Share on other sites

When I run notepad to open a file called test.txt (not the ++ version) from my Scriptdir or C:\ or D:\

And try the WinWaitActive with this..

WinWaitActive("test.txt")

It works like a charm.. not matter where the file is standing.

Neo

[center][font="Arial"]--- The Neo and Only --- [/font][font="Arial"]--Projects---[/font]Image to Text converterText to ASCII converter[/center]

Link to comment
Share on other sites

didnt helped again.My file isnt at scriptdir i use shellexecute to run it and it works fine but everything else i tried at winwaitactive doesnt work there should be a way.

ShellExecute("\portableapps\notepad++portable\sms.txt")
    WinWaitActive("F:\portableapps\notepad++portable\sms.txt - Notepad++")
Link to comment
Share on other sites

I hope you find this useful.

Line 45 You need to enter full path of File; and

Line 46 You need to enter the text from Title Bar of Notepad window.

#include <GUIConstants.au3>
#include <String.au3>

Opt("GUIOnEventMode", 1)

Global $Input[37]

$Form1_1 = GUICreate("Form1", 633, 447, 193, 125, -1, 0)
$Label1 = GUICtrlCreateLabel("Name", 28, 16, 52, 29)
GUICtrlSetFont(-1, 16, 800, 2, "Monotype Corsiva")
$Label2 = GUICtrlCreateLabel("Phone", 204, 16, 55, 29)
GUICtrlSetFont(-1, 16, 800, 2, "Monotype Corsiva")
$Message = GUICtrlCreateLabel("Message", 360, 16, 74, 29)
GUICtrlSetFont(-1, 16, 800, 2, "Monotype Corsiva")
$Checkbox1 = GUICtrlCreateCheckbox("Check box so all have same messages will be same", 20, 396, 437, 29)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")

$x = 0
$y = 52
For $iNum = 1 To 36
    $Input[$iNum] = GUICtrlCreateInput("", $x, $y, 149, 21)
    $x = Mod($x + 160, 480)
    $y += (Mod($iNum, 3) = 0) * 28
Next

$Button1 = GUICtrlCreateButton("Send info", 492, 56, 117, 53, 0)
GUICtrlSetOnEvent($Button1, "Button1")

GUICtrlSetFont(-1, 14, 800, 2, "Monotype Corsiva")
GUICtrlSetCursor(-1, 0)

$Button2 = GUICtrlCreateButton("Exit", 492, 136, 113, 37, 0)
GUICtrlSetOnEvent(-1, "exit1")

GUICtrlSetFont(-1, 14, 800, 2, "Monotype Corsiva")
GUICtrlSetCursor(-1, 0)
GUISetState(@SW_SHOW)

While 1
    Sleep(10)
WEnd

Func Button1()
    Local $String, $col1, $col2, $col3
    ShellExecute("C:\Documents and Settings\...........\notepad.txt") ; < == Enter full path of txt File
    WinWait("notepad.txt - Notepad")               ; <== Enter text from Title Bar of Notepad window
    
    For $iNum = 1 To 36 Step 3
        If GUICtrlRead($Input[$iNum]) <> "" Then
            $col1 = GUICtrlRead($Input[$iNum]) & _StringRepeat(Chr(32), (23 - StringLen(GUICtrlRead($Input[$iNum]))))
            $col2 = GUICtrlRead($Input[$iNum + 1]) & _StringRepeat(Chr(32), (23 - StringLen(GUICtrlRead($Input[$iNum + 1]))))
            If GUICtrlRead($Input[$iNum + 2]) <> "" Then $col3 = GUICtrlRead($Input[$iNum + 2])
            If GUICtrlRead($Checkbox1) = 1 And GUICtrlRead($Input[$iNum + 2]) = "" Then $col3 = GUICtrlRead($Input[3])
            $String = StringFormat("%-24s\t %-24s\t %-24s", $col1, $col2, $col3)
            Send($String & @CRLF)
        EndIf
        $String = ""
    Next
    Return
EndFunc   ;==>Button1

Func exit1()
    Exit
EndFunc   ;==>exit1
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...