Sign in to follow this  
Followers 0
CyberAssassin

calling a function

5 posts in this topic

CODE
#include <GUIConstants.au3>

; GUI

GuiCreate("Converter", 400, 50)

; Button

$Button_1 = GuiCtrlCreateButton("Convert to Hex", 0, 0, 200, 50)

$Button_2 = GUICtrlCreateButton("Convert to String", 200, 0, 200, 50)

Func _StringInsert($hex)

$input = InputBox("Text to Binary Converter", "Text to Convert", "", "", 400, 25)

$Bin_convert = StringToBinary($input)

$convert = hex($bin_convert)

Run("notepad.exe")

WinWaitActive("Untitled - Notepad")

Send($convert)

EndFunc

Func _StringInsert($text)

$input = InputBox("Binary to Text Converter", " Convert to Text", "", "", 400, 25)

$Bin_convert = BinaryToString($input)

Run("notepad.exe")

WinWaitActive("Untitled - Notepad")

Send($convert)

EndFunc

GuiSetState()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $msg = $Button_1

Case $msg = $Button_2

EndSelect

WEnd

how do i call functions like i have two functions and when i press convert to hex i want the text to be converted to hex/binary then i want notepad to open and write the converted code. can someone help me please.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

The only thing I notice is that your Input should be outside the Functions.

EDIT:

Example:

; Button
$Button_1 = GuiCtrlCreateButton("Convert to Hex", 0, 0, 200, 50)

Func _StringInsert($hex)
$Bin_convert = StringToBinary($hex) ; Take Note, call $hex not $input
$convert = hex($bin_convert)

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send($convert)
EndFunc

GuiSetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Button_1
$input = InputBox("Text to Binary Converter", "Text to Convert", "", "", 400, 25)
$hex = GUICtrlRead($input)
_StringInsert($hex)

Case $msg = $Button_2

EndSelect
WEnd
Edited by aslani

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks!

Edited by CyberAssassin

Share this post


Link to post
Share on other sites

CODE
While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $msg = $Button_1

Case $msg = $Button_2

EndSelect

WEnd

how do i call functions like i have two functions and when i press convert to hex i want the text to be converted to hex/binary then i want notepad to open and write the converted code. can someone help me please.

Just put the function call right under the case:

CODE
While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $msg = $Button_1

_ButtonOneFunction()

Case $msg = $Button_2

_ButtonTwoFunction()

EndSelect

WEnd

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Just put the function call right under the case:

CODE
While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $msg = $Button_1

_ButtonOneFunction()

Case $msg = $Button_2

_ButtonTwoFunction()

EndSelect

WEnd

:)

lol, that works better :P

His Func _StringInsert($hex) threw me off since he had that $hex inside the parenthesis. ;)


[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

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